ECDH code working with SE050ARD but failing on SE050ARD-F

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

ECDH code working with SE050ARD but failing on SE050ARD-F

160件の閲覧回数
krsuresh
Contributor III

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
0 件の賞賛
返信
5 返答(返信)

143件の閲覧回数
Kan_Li
NXP TechSupport
NXP TechSupport

Hi @krsuresh ,

 

I am sorry, but this feature is not supported on SE050F2. Please kindly refer to the following for details.

Kan_Li_0-1760496911818.png

Please refer to https://www.nxp.com.cn/docs/en/application-note/AN12436.pdf for more details.

 

If you need a FIPS certified SE05x with ECDH support, please use SE052F instead.

Kan_Li_1-1760497101862.png

 

Please refer to https://www.nxp.com.cn/docs/en/application-note/AN14277.pdf for more details.

 

Hope that helps,

 

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

 

0 件の賞賛
返信

133件の閲覧回数
krsuresh
Contributor III

Hi @Kan_Li,

 

Thank you for your prompt response.

I have one additional question — could you please confirm whether it is possible to generate an ECC key using the NIST-P384 curve on the SE050C or SE050F device? I have verified that the applet version currently in use is 3.1.0.

Thank you for your assistance.

 

Thanks,

Sureshkumar R

0 件の賞賛
返信

127件の閲覧回数
Kan_Li
NXP TechSupport
NXP TechSupport

Hi @krsuresh ,

Yes, both SE050C1 and SE050F2 support generating an ECC key using the NIST-P384 curve. Please kindly refer to the following for details.

Kan_Li_0-1760514929426.png

 

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

 

0 件の賞賛
返信

121件の閲覧回数
krsuresh
Contributor III

Hi @Kan_Li 

Thanks for the quick response.

I am using the following code to generate a NIST P-384 ECC key, but the function Se05x_API_WriteECKey() returns an error.
The same implementation works correctly for NIST P-256 key generation.

Error Detail: 0x6985 -> "Conditions not satisfied"

Additional Information:

Applet version: 3.1.0
Device variant: SE050ARD

int sd_se05x_generate_eccp384_key()
{
SE05x_ECCurve_t curveID = kSE05x_ECCurve_NIST_P384;
smStatus_t status;
uint32_t keyID = 0x60000700;
SE05x_Result_t result;

status = Se05x_API_CheckObjectExists(&se05x_session, keyID, &result);
if (status != SM_OK) {
SMLOG_E("[SE050] Error in Se05x_API_CheckObjectExists \n");
return SE050_FAILURE;
}

if (result == kSE05x_Result_SUCCESS) {
curveID = kSE05x_ECCurve_NA;
}

status = Se05x_API_WriteECKey(
&se05x_session, NULL, 0, keyID, curveID, NULL, 0, NULL, 0, kSE05x_INS_NA, kSE05x_KeyPart_Pair);
if (status != SM_OK) {
SMLOG_E("[SE050] Error in Se05x_API_WriteECKey Status: 0x%x\n", status);
return SE050_FAILURE;
}

return SE050_SUCCESS;

}

 

Thanks,

Sureshkumar R

0 件の賞賛
返信

96件の閲覧回数
Kan_Li
NXP TechSupport
NXP TechSupport

Hi @krsuresh ,

 

Please make sure the ECCurve kSE05x_ECCurve_NIST_P384 exists before generating the ECCKey pair. and please also note, if you use the SSS APIs to generate the ECC key pair, the ECCurve is created automatically in case it doesn't exist. 

 

Hope that helps,

 

Have a great day,
Kan


-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 件の賞賛
返信