mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
code cleanup based on PR review comments
This commit is contained in:
@ -190,7 +190,11 @@ int wolfCrypt_ATECC_SetConfig(ATCAIfaceCfg* cfg)
|
|||||||
XMEMSET(&cfg_ateccx08a_i2c_pi, 0, sizeof(cfg_ateccx08a_i2c_pi));
|
XMEMSET(&cfg_ateccx08a_i2c_pi, 0, sizeof(cfg_ateccx08a_i2c_pi));
|
||||||
cfg_ateccx08a_i2c_pi.iface_type = cfg->iface_type;
|
cfg_ateccx08a_i2c_pi.iface_type = cfg->iface_type;
|
||||||
cfg_ateccx08a_i2c_pi.devtype = cfg->devtype;
|
cfg_ateccx08a_i2c_pi.devtype = cfg->devtype;
|
||||||
|
#ifdef ATCA_ENABLE_DEPRECATED
|
||||||
|
cfg_ateccx08a_i2c_pi.atcai2c.slave_address = cfg->atcai2c.slave_address;
|
||||||
|
#else
|
||||||
cfg_ateccx08a_i2c_pi.atcai2c.address = cfg->atcai2c.address;
|
cfg_ateccx08a_i2c_pi.atcai2c.address = cfg->atcai2c.address;
|
||||||
|
#endif
|
||||||
cfg_ateccx08a_i2c_pi.atcai2c.bus = cfg->atcai2c.bus;
|
cfg_ateccx08a_i2c_pi.atcai2c.bus = cfg->atcai2c.bus;
|
||||||
cfg_ateccx08a_i2c_pi.atcai2c.baud = cfg->atcai2c.baud;
|
cfg_ateccx08a_i2c_pi.atcai2c.baud = cfg->atcai2c.baud;
|
||||||
cfg_ateccx08a_i2c_pi.wake_delay = cfg->wake_delay;
|
cfg_ateccx08a_i2c_pi.wake_delay = cfg->wake_delay;
|
||||||
@ -389,7 +393,7 @@ void atmel_show_rev_info(void)
|
|||||||
#ifdef WOLFSSL_ATECC_DEBUG
|
#ifdef WOLFSSL_ATECC_DEBUG
|
||||||
word32 revision = 0;
|
word32 revision = 0;
|
||||||
atmel_get_rev_info(&revision);
|
atmel_get_rev_info(&revision);
|
||||||
printf("ATECC508A Revision: %x\r\n", (word32)revision);
|
printf("ATECC608 Revision: %x\n", (word32)revision);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,7 +517,12 @@ int atmel_init(void)
|
|||||||
XMEMSET(&cfg_ateccx08a_i2c_pi, 0, sizeof(cfg_ateccx08a_i2c_pi));
|
XMEMSET(&cfg_ateccx08a_i2c_pi, 0, sizeof(cfg_ateccx08a_i2c_pi));
|
||||||
cfg_ateccx08a_i2c_pi.iface_type = ATCA_I2C_IFACE;
|
cfg_ateccx08a_i2c_pi.iface_type = ATCA_I2C_IFACE;
|
||||||
cfg_ateccx08a_i2c_pi.devtype = ATECC_DEV_TYPE;
|
cfg_ateccx08a_i2c_pi.devtype = ATECC_DEV_TYPE;
|
||||||
|
#ifdef ATCA_ENABLE_DEPRECATED
|
||||||
|
cfg_ateccx08a_i2c_pi.atcai2c.slave_address = ATECC_I2C_ADDR;
|
||||||
|
#else
|
||||||
cfg_ateccx08a_i2c_pi.atcai2c.address = ATECC_I2C_ADDR;
|
cfg_ateccx08a_i2c_pi.atcai2c.address = ATECC_I2C_ADDR;
|
||||||
|
#endif
|
||||||
|
cfg_ateccx08a_i2c_pi.atcai2c.address = ATECC_I2C_ADDR;
|
||||||
cfg_ateccx08a_i2c_pi.atcai2c.bus = ATECC_I2C_BUS;
|
cfg_ateccx08a_i2c_pi.atcai2c.bus = ATECC_I2C_BUS;
|
||||||
cfg_ateccx08a_i2c_pi.atcai2c.baud = 400000;
|
cfg_ateccx08a_i2c_pi.atcai2c.baud = 400000;
|
||||||
cfg_ateccx08a_i2c_pi.wake_delay = 1500;
|
cfg_ateccx08a_i2c_pi.wake_delay = 1500;
|
||||||
@ -921,7 +930,7 @@ static int atcatls_set_certificates(WOLFSSL_CTX *ctx)
|
|||||||
size_t deviceCertSize=0;
|
size_t deviceCertSize=0;
|
||||||
uint8_t *certBuffer;
|
uint8_t *certBuffer;
|
||||||
|
|
||||||
/*fetch signer cert size*/
|
/* fetch signer cert size */
|
||||||
status=tng_atcacert_read_signer_cert(NULL, &signerCertSize);
|
status=tng_atcacert_read_signer_cert(NULL, &signerCertSize);
|
||||||
if (ATCA_SUCCESS != status) {
|
if (ATCA_SUCCESS != status) {
|
||||||
#ifdef WOLFSSL_ATECC_DEBUG
|
#ifdef WOLFSSL_ATECC_DEBUG
|
||||||
@ -930,7 +939,7 @@ static int atcatls_set_certificates(WOLFSSL_CTX *ctx)
|
|||||||
return WOLFSSL_FAILURE;
|
return WOLFSSL_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*fetch device cert size*/
|
/* fetch device cert size */
|
||||||
status=tng_atcacert_read_device_cert(NULL, &deviceCertSize, NULL);
|
status=tng_atcacert_read_device_cert(NULL, &deviceCertSize, NULL);
|
||||||
if (ATCA_SUCCESS != status) {
|
if (ATCA_SUCCESS != status) {
|
||||||
#ifdef WOLFSSL_ATECC_DEBUG
|
#ifdef WOLFSSL_ATECC_DEBUG
|
||||||
@ -938,7 +947,7 @@ static int atcatls_set_certificates(WOLFSSL_CTX *ctx)
|
|||||||
#endif
|
#endif
|
||||||
return WOLFSSL_FAILURE;
|
return WOLFSSL_FAILURE;
|
||||||
}
|
}
|
||||||
certBuffer=XMALLOC(signerCertSize+deviceCertSize, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
certBuffer=(uint8_t*)XMALLOC(signerCertSize+deviceCertSize, NULL, DYNAMIC_TYPE_TMP_BUFFER);
|
||||||
if(NULL == certBuffer){
|
if(NULL == certBuffer){
|
||||||
#ifdef WOLFSSL_ATECC_DEBUG
|
#ifdef WOLFSSL_ATECC_DEBUG
|
||||||
printf("Failed allocating space for certBuffer\r\n");
|
printf("Failed allocating space for certBuffer\r\n");
|
||||||
@ -946,8 +955,8 @@ static int atcatls_set_certificates(WOLFSSL_CTX *ctx)
|
|||||||
return WOLFSSL_FAILURE;
|
return WOLFSSL_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Read signer cert*/
|
/* Read signer cert */
|
||||||
status = tng_atcacert_read_signer_cert(&certBuffer[deviceCertSize],\
|
status = tng_atcacert_read_signer_cert(&certBuffer[deviceCertSize],
|
||||||
&signerCertSize);
|
&signerCertSize);
|
||||||
if (ATCA_SUCCESS != status) {
|
if (ATCA_SUCCESS != status) {
|
||||||
#ifdef WOLFSSL_ATECC_DEBUG
|
#ifdef WOLFSSL_ATECC_DEBUG
|
||||||
@ -958,7 +967,7 @@ static int atcatls_set_certificates(WOLFSSL_CTX *ctx)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Read device cert signed by the signer above*/
|
/* Read device cert signed by the signer above */
|
||||||
status = tng_atcacert_read_device_cert(certBuffer, &deviceCertSize,\
|
status = tng_atcacert_read_device_cert(certBuffer, &deviceCertSize,\
|
||||||
&certBuffer[deviceCertSize]);
|
&certBuffer[deviceCertSize]);
|
||||||
if (ATCA_SUCCESS != status) {
|
if (ATCA_SUCCESS != status) {
|
||||||
|
Reference in New Issue
Block a user