目前我在 stm32f7 核板上测试了 mbedTLS 的 sha256 性能。我用cycle counter register
. 测量公式如下所示:
DWT->CYCCNT = 0;
uint32_t dwtStart = DWT->CYCCNT;
//uncomment for mbed calculation mbedtls_sha256();
//uncomment for atecc508a calculation atecc508a_sha256();
uint32_t dwtStop = DWT->CYCCNT;
double dStart = (double) dwtStart;
double dStop = (double) dwtStop;
// SystemCoreClock is a constant = 216000000
double result_in_milliseconds = (dStop-Start)/SystemCoreClock * 1000;
我已经在sha
执行硬件散列的微芯片 atecc508a 上测试了命令,它需要18ms
散列 32 字节的数据。
使用 mbedTLS 在软件中只需要0.05ms
散列 32 字节的数据。
我知道我必须记住,通过 i2c 进行的通信需要额外的时间进行操作,但这些结果是否合法?这两个操作之间会存在这样的差异吗?
两个操作都将相应的哈希返回到某个 32 字节的输入。
如果有人能回答我的问题,将非常感谢。