mirror of
https://github.com/espressif/openthread.git
synced 2026-08-13 22:27:47 +00:00
[mbedtls] move heap into otInstance. (#1996)
This commit is contained in:
@@ -63,19 +63,23 @@ void TestHmacSha256(void)
|
||||
};
|
||||
|
||||
otInstance *instance = testInitInstance();
|
||||
ot::Crypto::HmacSha256 hmac;
|
||||
uint8_t hash[ot::Crypto::HmacSha256::kHashSize];
|
||||
|
||||
VerifyOrQuit(instance != NULL, "Null OpenThread instance");
|
||||
|
||||
for (int i = 0; tests[i].key != NULL; i++)
|
||||
// Make sure hmac is destructed before freeing instance.
|
||||
{
|
||||
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);
|
||||
ot::Crypto::HmacSha256 hmac;
|
||||
uint8_t hash[ot::Crypto::HmacSha256::kHashSize];
|
||||
|
||||
VerifyOrQuit(memcmp(hash, tests[i].hash, sizeof(tests[i].hash)) == 0,
|
||||
"HMAC-SHA-256 failed\n");
|
||||
VerifyOrQuit(instance != NULL, "Null OpenThread instance");
|
||||
|
||||
for (int i = 0; tests[i].key != NULL; i++)
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
testFreeInstance(instance);
|
||||
|
||||
Reference in New Issue
Block a user