@@ -147,7 +147,7 @@ static int ateccx08a_cfg_initialized = 0;
147147 .devtype = MICROCHIP_DEV_TYPE ,
148148 .atcai2c = {
149149 #ifdef ATCA_ENABLE_DEPRECATED
150- .slave_addressus = 1 ,
150+ .slave_address = 1 ,
151151 #else
152152 .address = ATECC_I2C_ADDR ,
153153 #endif
@@ -451,13 +451,13 @@ int atmel_ecc_alloc(int slotType)
451451 break ;
452452 #endif
453453 case ATMEL_SLOT_ECDHE_ALICE :
454- /* not reserved in mSlotList, so return */
454+ /* reserve the fixed slot through the common allocation path */
455455 slotId = ATECC_SLOT_ECDHE_PRIV_ALICE ;
456- goto exit ;
456+ break ;
457457 case ATMEL_SLOT_ECDHE_BOB :
458- /* not reserved in mSlotList, so return */
458+ /* reserve the fixed slot through the common allocation path */
459459 slotId = ATECC_SLOT_ECDHE_PRIV_BOB ;
460- goto exit ;
460+ break ;
461461 case ATMEL_SLOT_ANY :
462462 for (i = 0 ; i < ATECC_MAX_SLOT ; i ++ ) {
463463 /* Find free slotId */
@@ -475,8 +475,7 @@ int atmel_ecc_alloc(int slotType)
475475 }
476476
477477 /* is slot available */
478- if (mSlotList [slotId ] != ATECC_INVALID_SLOT &&
479- mSlotList [slotId ] != slotId ) {
478+ if (mSlotList [slotId ] != ATECC_INVALID_SLOT ) {
480479 slotId = ATECC_INVALID_SLOT ;
481480 }
482481 else {
@@ -884,13 +883,20 @@ int wc_Microchip_rsa_create_key(struct RsaKey* key, int size, long e)
884883{
885884 ATCA_STATUS ret ;
886885 ta_element_attributes_t rKeyA , uKeyA ;
887- size_t uKey_len = TA_KEY_TYPE_RSA2048_SIZE ;
886+ size_t uKey_len = WOLFSSL_TA_KEY_TYPE_RSA_SIZE ;
888887
889- (void )size ;
890- (void )e ;
888+ if (key == NULL ) {
889+ return BAD_FUNC_ARG ;
890+ }
891+ if (size != (int )(WOLFSSL_TA_KEY_TYPE_RSA_SIZE * 8U )) {
892+ return BAD_FUNC_ARG ;
893+ }
894+ if (e != 0 && e != WC_RSA_EXPONENT ) {
895+ return BAD_FUNC_ARG ;
896+ }
891897
892898 /* Private key for signing AND decryption */
893- ret = talib_handle_init_private_key (& rKeyA , TA_KEY_TYPE_RSA2048 ,
899+ ret = talib_handle_init_private_key (& rKeyA , WOLFSSL_TA_KEY_TYPE_RSA ,
894900 TA_ALG_MODE_RSA_SSA_PSS , TA_PROP_SIGN_INT_EXT_DIGEST ,
895901 TA_PROP_KEY_AGREEMENT_OUT_BUFF );
896902 if (ret != ATCA_SUCCESS )
@@ -903,7 +909,7 @@ int wc_Microchip_rsa_create_key(struct RsaKey* key, int size, long e)
903909 return WC_HW_E ;
904910
905911 /* Public key - use 0, 0 for encryption support! */
906- ret = talib_handle_init_public_key (& uKeyA , TA_KEY_TYPE_RSA2048 ,
912+ ret = talib_handle_init_public_key (& uKeyA , WOLFSSL_TA_KEY_TYPE_RSA ,
907913 TA_ALG_MODE_RSA_SSA_PSS , 0 , 0 );
908914 if (ret != ATCA_SUCCESS )
909915 return WC_HW_E ;
@@ -942,7 +948,7 @@ int wc_Microchip_rsa_encrypt(const byte* in, word32 inLen, byte* out,
942948 printf ("outLen: %u\n" , outLen );
943949 printf ("out: %p\n" , out );
944950#endif
945- /* Use the 2048-specific function */
951+ /* The current wolfSSL TA100 backend uses the RSA-2048 RSAEnc path. */
946952 ret = talib_rsaenc_encrypt2048 (atcab_get_device (), key -> uKeyH ,
947953 (uint16_t )inLen , in ,
948954 (uint16_t )outLen , out );
@@ -955,7 +961,7 @@ int wc_Microchip_rsa_decrypt(const byte* in, word32 inLen, byte* out,
955961{
956962 int ret ;
957963
958-
964+ /* The current wolfSSL TA100 backend uses the RSA-2048 RSAEnc path. */
959965 ret = talib_rsaenc_decrypt2048 (atcab_get_device (), key -> rKeyH ,
960966 (uint16_t )inLen , in ,
961967 (uint16_t )outLen , out );
@@ -1310,7 +1316,7 @@ int atcatls_create_key_cb(WOLFSSL* ssl, ecc_key* key, unsigned int keySz,
13101316 return WC_HW_WAIT_E ;
13111317
13121318 /* generate new ephemeral key on device */
1313- ret = atmel_ecc_create_key (MAP_TO_HANDLE ( slotId ) , ecc_curve , peerKey );
1319+ ret = atmel_ecc_create_key (slotId , ecc_curve , peerKey );
13141320
13151321 /* load generated ECC508A public key into key, used by wolfSSL */
13161322 if (ret == 0 ) {
@@ -1387,8 +1393,7 @@ int atcatls_create_pms_cb(WOLFSSL* ssl, ecc_key* otherKey,
13871393 tmpKey .slot = slotId ;
13881394
13891395 /* generate new ephemeral key on device */
1390- ret = atmel_ecc_create_key (MAP_TO_HANDLE (slotId ), otherKey -> dp -> id ,
1391- peerKey );
1396+ ret = atmel_ecc_create_key (slotId , otherKey -> dp -> id , peerKey );
13921397 if (ret != ATCA_SUCCESS ) {
13931398 atmel_ecc_free (slotId );
13941399 goto exit ;
@@ -1663,6 +1668,7 @@ static int atcatls_set_certificates(WOLFSSL_CTX *ctx)
16631668 #endif
16641669
16651670 int ret = 0 ;
1671+ ATCA_STATUS status ;
16661672 size_t signerCertSize = ATCATLS_SIGNER_CERT_MAX_SIZE ;
16671673 size_t deviceCertSize = ATCATLS_DEVICE_CERT_MAX_SIZE ;
16681674 uint8_t certBuffer [ATCATLS_CERT_BUFF_MAX_SIZE ];
@@ -1672,7 +1678,6 @@ static int atcatls_set_certificates(WOLFSSL_CTX *ctx)
16721678#endif
16731679
16741680#ifdef WOLFSSL_ATECC_TNGTLS
1675- ATCA_STATUS status ;
16761681 ret = tng_atcacert_max_signer_cert_size (& signerCertSize );
16771682 if (ret != ATCACERT_E_SUCCESS ) {
16781683 #ifdef WOLFSSL_ATECC_DEBUG
@@ -1782,7 +1787,6 @@ static int atcatls_set_certificates(WOLFSSL_CTX *ctx)
17821787 return ret ;
17831788}
17841789#endif /* ATCA_TFLEX_SUPPORT */
1785- #endif /* ATCA_TFLEX_SUPPORT */
17861790
17871791int atcatls_set_callbacks (WOLFSSL_CTX * ctx )
17881792{
@@ -1921,11 +1925,12 @@ int wc_Microchip_aes_set_key(Aes* aes, const byte* key, word32 keylen,
19211925 status = talib_aes_gcm_keyload (atcab_get_device (), aes -> key_id , 0 );
19221926 CHECK_STATUS (status );
19231927
1924- /* Test if data zone is locked */
1928+ /* Provisioning must lock setup explicitly; do not lock it as a side
1929+ * effect of loading an AES key. */
19251930 status = talib_is_setup_locked (atcab_get_device (), & is_locked );
1931+ CHECK_STATUS (status );
19261932 if (!is_locked ) {
1927- status = talib_lock_setup (atcab_get_device ());
1928- CHECK_STATUS (status );
1933+ return WC_HW_E ;
19291934 }
19301935
19311936 return atmel_ecc_translate_err (status );
0 commit comments