Hi Team,
As per the below sample ECDH code, the functionality works correctly with the SE050ARD board. However, the same code does not work on the SE050ARD-F board.
Could you please provide details or guidance on what changes are required to make this ECDH example work with the SE050ARD-F device?
const uint8_t nist256PubKey[] = {
0x04, 0xF2, 0x24, 0xBC, 0x5E, 0xEA, 0x74, 0x28, 0xA1, 0x20, 0xD3, 0xD2, 0x69, 0xFE, 0x22, 0xF3,
0x59, 0x9C, 0x20, 0x33, 0xA2, 0xE0, 0xCB, 0x81, 0xC2, 0xCE, 0xA9, 0xD6, 0xD4, 0x66, 0xC3, 0x68,
0xF8, 0xB6, 0xA8, 0x9C, 0xDE, 0x08, 0x88, 0xB5, 0x49, 0xCD, 0xED, 0x85, 0xD3, 0xB5, 0x88, 0x72,
0x0A, 0xDC, 0x26, 0x32, 0xB0, 0x30, 0xBF, 0xB1, 0x67, 0xD0, 0xFD, 0xBC, 0x89, 0xE7, 0x2B, 0x9C,
0xC1,
};
int ex_ecdh(pSe05xSession_t session_ctx)
{
smStatus_t status;
uint32_t keyID = TEST_ID_BASE + __LINE__;
SE05x_Result_t result;
SE05x_ECCurve_t curveID = kSE05x_ECCurve_NIST_P256;
uint8_t sharedSecret[32] = {
0,
};
size_t sharedSecret_len = sizeof(sharedSecret);
/* Check if the object exists in se05x already */
status = Se05x_API_CheckObjectExists(session_ctx, keyID, &result);
if (status != SM_OK) {
SMLOG_E("Error in Se05x_API_CheckObjectExists \n");
goto exit;
}
if (result == kSE05x_Result_SUCCESS) {
/* If key already exists, set curveID = NA */
curveID = kSE05x_ECCurve_NA;
}
/* Generate nist256 key */
status = Se05x_API_WriteECKey(
session_ctx, NULL, 0, keyID, curveID, NULL, 0, NULL, 0, kSE05x_INS_NA, kSE05x_KeyPart_Pair);
if (status != SM_OK) {
SMLOG_E("Error in Se05x_API_WriteECKey \n");
goto exit;
}
/* Calulate ECDH key using key pair at location 'keyID' and public key in buffer 'nist256PubKey' */
status = Se05x_API_ECDHGenerateSharedSecret(
session_ctx, keyID, nist256PubKey, sizeof(nist256PubKey), sharedSecret, &sharedSecret_len);
if (status != SM_OK) {
SMLOG_E("Error in Se05x_API_ECDHGenerateSharedSecret \n");
goto exit;
}
status = Se05x_API_DeleteSecureObject(session_ctx, keyID);
if (status != SM_OK) {
SMLOG_E("Error in Se05x_API_DeleteSecureObject \n");
goto exit;
}
EX_PASS;
exit:
EX_FAIL;
}
Thanks,
Sureshkumar R