mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 02:55:49 +03:00
test-crypto: Add a test for #2488
This commit is contained in:
parent
c883bab62a
commit
a3f51089d2
Notes:
sideshowbarker
2024-07-19 05:50:28 +09:00
Author: https://github.com/alimpfard Commit: https://github.com/SerenityOS/serenity/commit/a3f51089d20 Pull-request: https://github.com/SerenityOS/serenity/pull/2495 Issue: https://github.com/SerenityOS/serenity/issues/2488
@ -959,6 +959,32 @@ void hmac_sha256_test_process()
|
||||
} else
|
||||
PASS;
|
||||
}
|
||||
{
|
||||
I_TEST((HMAC - SHA256 | DataSize > FinalBlockDataSize));
|
||||
Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac("Well Hello Friends");
|
||||
u8 result[] = {
|
||||
0x9b, 0xa3, 0x9e, 0xf3, 0xb4, 0x30, 0x5f, 0x6f, 0x67, 0xd0, 0xa8, 0xb0, 0xf0, 0xcb, 0x12, 0xf5, 0x85, 0xe2, 0x19, 0xba, 0x0c, 0x8b, 0xe5, 0x43, 0xf0, 0x93, 0x39, 0xa8, 0xa3, 0x07, 0xf1, 0x95
|
||||
};
|
||||
auto mac = hmac.process("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
||||
if (memcmp(result, mac.data, hmac.digest_size()) != 0) {
|
||||
FAIL(Invalid mac);
|
||||
print_buffer(ByteBuffer::wrap(mac.data, hmac.digest_size()), -1);
|
||||
} else
|
||||
PASS;
|
||||
}
|
||||
{
|
||||
I_TEST((HMAC - SHA256 | DataSize == BlockSize));
|
||||
Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac("Well Hello Friends");
|
||||
u8 result[] = {
|
||||
0x1d, 0x90, 0xce, 0x68, 0x45, 0x0b, 0xba, 0xd6, 0xbe, 0x1c, 0xb2, 0x3a, 0xea, 0x7f, 0xac, 0x4b, 0x68, 0x08, 0xa4, 0x77, 0x81, 0x2a, 0xad, 0x5d, 0x05, 0xe2, 0x15, 0xe8, 0xf4, 0xcb, 0x06, 0xaf
|
||||
};
|
||||
auto mac = hmac.process("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
|
||||
if (memcmp(result, mac.data, hmac.digest_size()) != 0) {
|
||||
FAIL(Invalid mac);
|
||||
print_buffer(ByteBuffer::wrap(mac.data, hmac.digest_size()), -1);
|
||||
} else
|
||||
PASS;
|
||||
}
|
||||
{
|
||||
I_TEST((HMAC - SHA256 | Reuse));
|
||||
Crypto::Authentication::HMAC<Crypto::Hash::SHA256> hmac("Well Hello Friends");
|
||||
|
Loading…
Reference in New Issue
Block a user