Created
May 24, 2024 16:01
-
-
Save cwyang/a4ea1e4e724384cf4e44d499cbd51aaa to your computer and use it in GitHub Desktop.
bug reporting on VPP native aes_gcm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/plugins/crypto_native/aes_gcm.c | |
static void test_aes_gcm() | |
{ | |
u8 src[32] = {0}, dst[32] = {0}, check[32] = {0}; | |
u8 aad[32] = {0}, iv[12] = {0}, tag[16] = {0}, key[32]; | |
aes_key_size_t ks = AES_KEY_256; | |
aes_gcm_key_data_t kd; | |
// prepare key | |
for (int i = 0; i < 32; i++) | |
key[i] = i; | |
clib_aes_gcm_key_expand (&kd, key, ks); | |
for (i32 len = 32; len >= 0; len -= 16) | |
{ | |
clib_warning("testing for len %d", len); | |
aes_gcm (src, dst, | |
aad, iv, tag, len, 32, 16, | |
&kd, AES_KEY_ROUNDS (ks), | |
AES_GCM_OP_ENCRYPT); | |
int rv = aes_gcm (dst, check, | |
aad, iv, tag, len, 32, 16, | |
&kd, AES_KEY_ROUNDS (ks), | |
AES_GCM_OP_DECRYPT); | |
int rv2 = memcmp(src, check, len); | |
ASSERT(rv2 == 0); | |
ASSERT(rv != 0); | |
clib_warning("testing for len %d OK!", len); | |
} | |
} | |
... | |
crypto_native aes_gcm_init() { | |
crypto_native_main_t *cm = &crypto_native_main; | |
test_aes_gcm(); | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can see where the above test function fails: