GMAC Split Test

This commit is contained in:
Florian Märkl 2019-04-12 14:37:53 +02:00
commit 52a293eadf
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
2 changed files with 76 additions and 0 deletions

View file

@ -216,6 +216,70 @@ static MunitResult test_gen_gmac_key(const MunitParameter params[], void *user)
}
static MunitResult test_gmac_split(const MunitParameter params[], void *user)
{
static const uint8_t gkcrypt_key[] = { 0x35, 0x95, 0x81, 0x87, 0xeb, 0xcb, 0x63, 0x54, 0x90, 0x00, 0xd7, 0xd5, 0xbd, 0xf4, 0xc5, 0xf4 };
static const uint8_t gkcrypt_iv[] = { 0xb8, 0xde, 0xfc, 0xa4, 0x48, 0xf0, 0x4c, 0x3f, 0xd5, 0x94, 0x0e, 0x1c, 0x04, 0x64, 0x63, 0xb1 };
static const uint8_t buf[] = { 0x2, 0x0, 0x1e, 0x0, 0x9, 0x0, 0x20, 0x8, 0x1, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xad,
0xf0, 0x2, 0x4e, 0x0, 0x2c, 0x6f, 0x3b, 0x6c, 0x2e, 0x4a, 0x27, 0x9c, 0x50, 0x34, 0x84, 0xea,
0x37, 0xc7, 0x76, 0xab, 0x92, 0x30, 0x43, 0x61, 0xc7, 0x1d, 0xcb, 0xc4, 0x35, 0x94, 0xcc, 0x44,
0xe2, 0xfa, 0x89, 0x86, 0x47, 0x5e, 0xc2, 0x1, 0x39, 0x4c, 0x9f, 0x67, 0xb3, 0x6e, 0x35, 0x44,
0x97, 0xf4, 0x28, 0xe2, 0x51, 0x12, 0xda, 0xf5, 0x2c, 0x43, 0x1c, 0x49, 0x46, 0x2c, 0x53, 0xe3,
0xe9, 0x76, 0x61, 0x87, 0x2b, 0x7a, 0xe3, 0x2f, 0xbb, 0x9f, 0x4d, 0x66, 0x8a, 0x31, 0xbc, 0x64,
0x9d, 0x6, 0xd, 0x4a, 0xdd, 0x42, 0x21, 0x73, 0x3c, 0x97, 0x21, 0x84, 0x53, 0x65, 0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0x26, 0xbd, 0xd1, 0xb0, 0x95, 0xbd, 0x26, 0xba, 0x49, 0xa6, 0x81, 0x7, 0x31, 0xd3,
0xe1, 0x25, 0xda, 0xab, 0x71, 0xb9, 0x65, 0x1d, 0x13, 0xab, 0x82, 0x52, 0x95, 0xb3, 0x62, 0xa6,
0x48, 0x48, 0xb8, 0xd8, 0x55, 0x26, 0x98, 0xa1, 0xc9, 0x57, 0x66, 0x1c, 0xac, 0xb1, 0xc7, 0x5f,
0xfa, 0x44, 0xc6, 0xd8, 0x19, 0x1, 0x8d, 0x41, 0x1f, 0xc7, 0xf, 0x89, 0x1d, 0xef, 0x34, 0x9a,
0x68, 0x77, 0x8c };
static const size_t key_pos = 0xadf0;
static const uint8_t gmac_expected[] = { 0xd6, 0x6a, 0x07, 0xb7 };
ChiakiGKCrypt gkcrypt;
memset(&gkcrypt, 0, sizeof(gkcrypt));
memcpy(gkcrypt.key_gmac_current, gkcrypt_key, sizeof(gkcrypt.key_gmac_current));
memcpy(gkcrypt.iv, gkcrypt_iv, sizeof(gkcrypt.iv));
gkcrypt.key_buf = NULL;
gkcrypt.key_buf_size = 0;
gkcrypt.key_gmac_index_current = 0;
uint8_t gmac[CHIAKI_GKCRYPT_GMAC_SIZE];
ChiakiErrorCode err = chiaki_gkcrypt_gmac(&gkcrypt, key_pos, buf, sizeof(buf), gmac);
if(err != CHIAKI_ERR_SUCCESS)
return MUNIT_ERROR;
munit_assert_memory_equal(sizeof(gmac), gmac, gmac_expected);
return MUNIT_OK;
}
MunitTest tests_gkcrypt[] = {
{
@ -258,5 +322,13 @@ MunitTest tests_gkcrypt[] = {
MUNIT_TEST_OPTION_NONE,
NULL
},
{
"/gmac_split",
test_gmac_split,
NULL,
NULL,
MUNIT_TEST_OPTION_NONE,
NULL
},
{ NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }
};