@@ -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
@@ -449,13 +449,13 @@ int atmel_ecc_alloc(int slotType)
449449 break ;
450450 #endif
451451 case ATMEL_SLOT_ECDHE_ALICE :
452- /* not reserved in mSlotList, so return */
452+ /* reserve the fixed slot through the common allocation path */
453453 slotId = ATECC_SLOT_ECDHE_PRIV_ALICE ;
454- goto exit ;
454+ break ;
455455 case ATMEL_SLOT_ECDHE_BOB :
456- /* not reserved in mSlotList, so return */
456+ /* reserve the fixed slot through the common allocation path */
457457 slotId = ATECC_SLOT_ECDHE_PRIV_BOB ;
458- goto exit ;
458+ break ;
459459 case ATMEL_SLOT_ANY :
460460 for (i = 0 ; i < ATECC_MAX_SLOT ; i ++ ) {
461461 /* Find free slotId */
@@ -473,8 +473,7 @@ int atmel_ecc_alloc(int slotType)
473473 }
474474
475475 /* is slot available */
476- if (mSlotList [slotId ] != ATECC_INVALID_SLOT &&
477- mSlotList [slotId ] != slotId ) {
476+ if (mSlotList [slotId ] != ATECC_INVALID_SLOT ) {
478477 slotId = ATECC_INVALID_SLOT ;
479478 }
480479 else {
@@ -882,13 +881,20 @@ int wc_Microchip_rsa_create_key(struct RsaKey* key, int size, long e)
882881{
883882 ATCA_STATUS ret ;
884883 ta_element_attributes_t rKeyA , uKeyA ;
885- size_t uKey_len = TA_KEY_TYPE_RSA2048_SIZE ;
884+ size_t uKey_len = WOLFSSL_TA_KEY_TYPE_RSA_SIZE ;
886885
887- (void )size ;
888- (void )e ;
886+ if (key == NULL ) {
887+ return BAD_FUNC_ARG ;
888+ }
889+ if (size != (int )(WOLFSSL_TA_KEY_TYPE_RSA_SIZE * 8U )) {
890+ return BAD_FUNC_ARG ;
891+ }
892+ if (e != 0 && e != WC_RSA_EXPONENT ) {
893+ return BAD_FUNC_ARG ;
894+ }
889895
890896 /* Private key for signing AND decryption */
891- ret = talib_handle_init_private_key (& rKeyA , TA_KEY_TYPE_RSA2048 ,
897+ ret = talib_handle_init_private_key (& rKeyA , WOLFSSL_TA_KEY_TYPE_RSA ,
892898 TA_ALG_MODE_RSA_SSA_PSS , TA_PROP_SIGN_INT_EXT_DIGEST ,
893899 TA_PROP_KEY_AGREEMENT_OUT_BUFF );
894900 if (ret != ATCA_SUCCESS )
@@ -901,7 +907,7 @@ int wc_Microchip_rsa_create_key(struct RsaKey* key, int size, long e)
901907 return WC_HW_E ;
902908
903909 /* Public key - use 0, 0 for encryption support! */
904- ret = talib_handle_init_public_key (& uKeyA , TA_KEY_TYPE_RSA2048 ,
910+ ret = talib_handle_init_public_key (& uKeyA , WOLFSSL_TA_KEY_TYPE_RSA ,
905911 TA_ALG_MODE_RSA_SSA_PSS , 0 , 0 );
906912 if (ret != ATCA_SUCCESS )
907913 return WC_HW_E ;
@@ -940,7 +946,7 @@ int wc_Microchip_rsa_encrypt(const byte* in, word32 inLen, byte* out,
940946 printf ("outLen: %u\n" , outLen );
941947 printf ("out: %p\n" , out );
942948#endif
943- /* Use the 2048-specific function */
949+ /* The current wolfSSL TA100 backend uses the RSA-2048 RSAEnc path. */
944950 ret = talib_rsaenc_encrypt2048 (atcab_get_device (), key -> uKeyH ,
945951 (uint16_t )inLen , in ,
946952 (uint16_t )outLen , out );
@@ -953,7 +959,7 @@ int wc_Microchip_rsa_decrypt(const byte* in, word32 inLen, byte* out,
953959{
954960 int ret ;
955961
956-
962+ /* The current wolfSSL TA100 backend uses the RSA-2048 RSAEnc path. */
957963 ret = talib_rsaenc_decrypt2048 (atcab_get_device (), key -> rKeyH ,
958964 (uint16_t )inLen , in ,
959965 (uint16_t )outLen , out );
@@ -1308,7 +1314,7 @@ int atcatls_create_key_cb(WOLFSSL* ssl, ecc_key* key, unsigned int keySz,
13081314 return WC_HW_WAIT_E ;
13091315
13101316 /* generate new ephemeral key on device */
1311- ret = atmel_ecc_create_key (MAP_TO_HANDLE ( slotId ) , ecc_curve , peerKey );
1317+ ret = atmel_ecc_create_key (slotId , ecc_curve , peerKey );
13121318
13131319 /* load generated ECC508A public key into key, used by wolfSSL */
13141320 if (ret == 0 ) {
@@ -1385,8 +1391,7 @@ int atcatls_create_pms_cb(WOLFSSL* ssl, ecc_key* otherKey,
13851391 tmpKey .slot = slotId ;
13861392
13871393 /* generate new ephemeral key on device */
1388- ret = atmel_ecc_create_key (MAP_TO_HANDLE (slotId ), otherKey -> dp -> id ,
1389- peerKey );
1394+ ret = atmel_ecc_create_key (slotId , otherKey -> dp -> id , peerKey );
13901395 if (ret != ATCA_SUCCESS ) {
13911396 atmel_ecc_free (slotId );
13921397 goto exit ;
@@ -1661,6 +1666,7 @@ static int atcatls_set_certificates(WOLFSSL_CTX *ctx)
16611666 #endif
16621667
16631668 int ret = 0 ;
1669+ ATCA_STATUS status ;
16641670 size_t signerCertSize = ATCATLS_SIGNER_CERT_MAX_SIZE ;
16651671 size_t deviceCertSize = ATCATLS_DEVICE_CERT_MAX_SIZE ;
16661672 uint8_t certBuffer [ATCATLS_CERT_BUFF_MAX_SIZE ];
@@ -1670,7 +1676,6 @@ static int atcatls_set_certificates(WOLFSSL_CTX *ctx)
16701676#endif
16711677
16721678#ifdef WOLFSSL_ATECC_TNGTLS
1673- ATCA_STATUS status ;
16741679 ret = tng_atcacert_max_signer_cert_size (& signerCertSize );
16751680 if (ret != ATCACERT_E_SUCCESS ) {
16761681 #ifdef WOLFSSL_ATECC_DEBUG
@@ -1780,7 +1785,6 @@ static int atcatls_set_certificates(WOLFSSL_CTX *ctx)
17801785 return ret ;
17811786}
17821787#endif /* ATCA_TFLEX_SUPPORT */
1783- #endif /* ATCA_TFLEX_SUPPORT */
17841788
17851789int atcatls_set_callbacks (WOLFSSL_CTX * ctx )
17861790{
@@ -1919,11 +1923,12 @@ int wc_Microchip_aes_set_key(Aes* aes, const byte* key, word32 keylen,
19191923 status = talib_aes_gcm_keyload (atcab_get_device (), aes -> key_id , 0 );
19201924 CHECK_STATUS (status );
19211925
1922- /* Test if data zone is locked */
1926+ /* Provisioning must lock setup explicitly; do not lock it as a side
1927+ * effect of loading an AES key. */
19231928 status = talib_is_setup_locked (atcab_get_device (), & is_locked );
1929+ CHECK_STATUS (status );
19241930 if (!is_locked ) {
1925- status = talib_lock_setup (atcab_get_device ());
1926- CHECK_STATUS (status );
1931+ return WC_HW_E ;
19271932 }
19281933
19291934 return atmel_ecc_translate_err (status );
0 commit comments