mirror of
https://github.com/espressif/openthread.git
synced 2026-09-10 11:10:08 +00:00
Remove globals from mbedcrypto.cpp.
This commit is contained in:
@@ -31,7 +31,10 @@
|
||||
#include <common/debug.hpp>
|
||||
#include <string.h>
|
||||
|
||||
#include <crypto/hmac_sha256.h>
|
||||
#include <crypto/hmac_sha256.hpp>
|
||||
#include <crypto/mbedtls.hpp>
|
||||
|
||||
static Thread::Crypto::MbedTls mbedtls;
|
||||
|
||||
extern"C" void otSignalTaskletPending(void)
|
||||
{
|
||||
@@ -43,7 +46,7 @@ void TestHmacSha256(void)
|
||||
{
|
||||
const char *key;
|
||||
const char *data;
|
||||
uint8_t hash[otCryptoSha256Size];
|
||||
uint8_t hash[Thread::Crypto::HmacSha256::kHashSize];
|
||||
} tests[] =
|
||||
{
|
||||
{
|
||||
@@ -63,13 +66,14 @@ void TestHmacSha256(void)
|
||||
},
|
||||
};
|
||||
|
||||
uint8_t hash[otCryptoSha256Size];
|
||||
Thread::Crypto::HmacSha256 hmac;
|
||||
uint8_t hash[Thread::Crypto::HmacSha256::kHashSize];
|
||||
|
||||
for (int i = 0; tests[i].key != NULL; i++)
|
||||
{
|
||||
otCryptoHmacSha256Start(tests[i].key, static_cast<uint16_t>(strlen(tests[i].key)));
|
||||
otCryptoHmacSha256Update(tests[i].data, static_cast<uint16_t>(strlen(tests[i].data)));
|
||||
otCryptoHmacSha256Finish(hash);
|
||||
hmac.Start(reinterpret_cast<const uint8_t *>(tests[i].key), static_cast<uint16_t>(strlen(tests[i].key)));
|
||||
hmac.Update(reinterpret_cast<const uint8_t *>(tests[i].data), static_cast<uint16_t>(strlen(tests[i].data)));
|
||||
hmac.Finish(hash);
|
||||
|
||||
VerifyOrQuit(memcmp(hash, tests[i].hash, sizeof(tests[i].hash)) == 0,
|
||||
"HMAC-SHA-256 failed\n");
|
||||
|
||||
Reference in New Issue
Block a user