@@ -288,7 +288,7 @@ static int stsafe_create_key(stsafe_slot_t* pSlot, stsafe_curve_id_t curve_id,
288288 * but stsafe_curve_id_t values match stse_ecc_key_type_t enum values */
289289 ret = stse_generate_ecc_key_pair (& g_stse_handler , slot ,
290290 (stse_ecc_key_type_t )curve_id ,
291- 255 , /* usage_limit */
291+ STSAFE_PERSISTENT_KEY_USAGE_LIMIT ,
292292 pPubKeyRaw );
293293 if (ret != STSE_OK ) {
294294 STSAFE_INTERFACE_PRINTF ("stse_generate_ecc_key_pair error: %d\n" , ret );
@@ -454,7 +454,7 @@ static int stsafe_shared_secret_ecdhe(stsafe_curve_id_t curve_id,
454454 /* Compute shared secret using ephemeral slot (0xFF)
455455 * The ephemeral private key was generated by stse_generate_ECDHE_key_pair() */
456456 ret = stse_ecc_establish_shared_secret (& g_stse_handler ,
457- STSAFE_KEY_SLOT_EPHEMERAL , curve_id , peerPubKey , pSharedSecret );
457+ STSAFE_KEY_SLOT_EPHEMERAL , ( stse_ecc_key_type_t ) curve_id , peerPubKey , pSharedSecret );
458458 if (ret != STSE_OK ) {
459459 STSAFE_INTERFACE_PRINTF ("stse_ecc_establish_shared_secret (ECDHE) error: %d\n" ,
460460 ret );
@@ -1554,7 +1554,7 @@ int wolfSSL_STSAFE_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
15541554 slot = STSAFE_KEY_SLOT_1 ; /* Use persistent slot for ECDSA signing */
15551555 ret = stse_generate_ecc_key_pair (& g_stse_handler , slot ,
15561556 (stse_ecc_key_type_t )curve_id ,
1557- 255 , /* usage_limit for persistent keys */
1557+ STSAFE_PERSISTENT_KEY_USAGE_LIMIT ,
15581558 pubKeyRaw );
15591559 if (ret != STSE_OK ) {
15601560 STSAFE_INTERFACE_PRINTF ("stse_generate_ecc_key_pair (slot 1) error: %d\n" , ret );
@@ -1852,6 +1852,7 @@ int wolfSSL_STSAFE_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
18521852 }
18531853
18541854 if (need_ephemeral_key ) {
1855+ #ifdef WOLFSSL_STSAFEA120
18551856 /* Key is in slot 1 (for ECDSA), but ECDH requires ephemeral slot.
18561857 * Generate ephemeral key pair for ECDH. Note: This will overwrite any
18571858 * existing key in ephemeral slot, so for bidirectional ECDH, both keys
@@ -1886,6 +1887,13 @@ int wolfSSL_STSAFE_CryptoDevCb(int devId, wc_CryptoInfo* info, void* ctx)
18861887 }
18871888 }
18881889 }
1890+ #else /* WOLFSSL_STSAFEA100 */
1891+ /* For A100/A110, ephemeral key generation in ECDH callback
1892+ * is not supported. Keys must be generated in ephemeral slot
1893+ * from the start for ECDH operations. */
1894+ WOLFSSL_MSG ("STSAFE: ECDH requires ephemeral slot - key must be generated in ephemeral slot" );
1895+ rc = WC_HW_E ;
1896+ #endif
18891897 } else {
18901898 /* Key is already in ephemeral slot, use it */
18911899 slot = STSAFE_KEY_SLOT_EPHEMERAL ;
0 commit comments