Updates to the atmel.c code to allow easier customization of the hardware interface.
This commit is contained in:
parent
bb737ec99d
commit
177bf49fa6
@ -817,11 +817,16 @@ AC_ARG_WITH([cryptoauthlib],
|
||||
AC_MSG_ERROR([cryptoauthlib isn't found.
|
||||
If it's already installed, specify its path using --with-cryptoauthlib=/dir/])
|
||||
fi
|
||||
|
||||
AM_LDFLAGS="$AM_LDFLAGS -L$trylibatcadir/lib"
|
||||
AM_CFLAGS="$AM_CFLAGS -I$trylibatcadir/lib"
|
||||
AC_MSG_RESULT([yes])
|
||||
else
|
||||
AC_MSG_RESULT([yes])
|
||||
fi
|
||||
|
||||
ENABLED_CRYPTOAUTHLIB="yes"
|
||||
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ATECC508A"
|
||||
]
|
||||
)
|
||||
AM_CONDITIONAL([BUILD_CRYPTOAUTHLIB], [test "x$ENABLED_CRYPTOAUTHLIB" = "xyes"])
|
||||
|
@ -62,6 +62,17 @@ static byte mSlotList[ATECC_MAX_SLOT];
|
||||
static wolfSSL_Mutex mSlotMutex;
|
||||
#endif
|
||||
|
||||
/* Raspberry Pi uses /dev/i2c-1 */
|
||||
#ifndef ATECC_I2C_ADDR
|
||||
#define ATECC_I2C_ADDR 0xC0
|
||||
#endif
|
||||
#ifndef ATECC_I2C_BUS
|
||||
#define ATECC_I2C_BUS 1
|
||||
#endif
|
||||
#ifndef ATECC_DEV_TYPE
|
||||
#define ATECC_DEV_TYPE ATECC508A
|
||||
#endif
|
||||
static ATCAIfaceCfg cfg_ateccx08a_i2c_pi;
|
||||
#endif /* WOLFSSL_ATECC508A */
|
||||
|
||||
|
||||
@ -390,8 +401,18 @@ int atmel_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Setup the hardware interface */
|
||||
XMEMSET(&cfg_ateccx08a_i2c_pi, 0, sizeof(cfg_ateccx08a_i2c_pi));
|
||||
cfg_ateccx08a_i2c_pi.iface_type = ATCA_I2C_IFACE;
|
||||
cfg_ateccx08a_i2c_pi.devtype = ATECC_DEV_TYPE;
|
||||
cfg_ateccx08a_i2c_pi.atcai2c.slave_address = ATECC_I2C_ADDR;
|
||||
cfg_ateccx08a_i2c_pi.atcai2c.bus = ATECC_I2C_BUS;
|
||||
cfg_ateccx08a_i2c_pi.atcai2c.baud = 400000;
|
||||
cfg_ateccx08a_i2c_pi.wake_delay = 1500;
|
||||
cfg_ateccx08a_i2c_pi.rx_retries = 20;
|
||||
|
||||
/* Initialize the CryptoAuthLib to communicate with ATECC508A */
|
||||
status = atcab_init(&cfg_ateccx08a_i2c_default);
|
||||
status = atcab_init(&cfg_ateccx08a_i2c_pi);
|
||||
if (status != ATCA_SUCCESS) {
|
||||
WOLFSSL_MSG("Failed to initialize atcab");
|
||||
return WC_HW_E;
|
||||
|
@ -31,11 +31,10 @@
|
||||
#undef SHA_BLOCK_SIZE
|
||||
#define SHA_BLOCK_SIZE SHA_BLOCK_SIZE_REMAP
|
||||
#include <cryptoauthlib.h>
|
||||
#include <atcacert/atcacert_client.h>
|
||||
#undef SHA_BLOCK_SIZE
|
||||
#endif
|
||||
|
||||
/* ATECC508A only supports ECC-256 */
|
||||
/* ATECC508A only supports ECC P-256 */
|
||||
#define ATECC_KEY_SIZE (32)
|
||||
#define ATECC_PUBKEY_SIZE (ATECC_KEY_SIZE*2) /* X and Y */
|
||||
#define ATECC_SIG_SIZE (ATECC_KEY_SIZE*2) /* R and S */
|
||||
|
Loading…
Reference in New Issue
Block a user