aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/crypto/aes-gcm.c8
-rw-r--r--src/crypto/aes_wrap.h3
-rw-r--r--tests/test-aes.c14
3 files changed, 25 insertions, 0 deletions
diff --git a/src/crypto/aes-gcm.c b/src/crypto/aes-gcm.c
index d3105ed..f6f4074 100644
--- a/src/crypto/aes-gcm.c
+++ b/src/crypto/aes-gcm.c
@@ -311,3 +311,11 @@ int aes_gcm_ad(const u8 *key, size_t key_len, const u8 *iv, size_t iv_len,
return 0;
}
+
+
+int aes_gmac(const u8 *key, size_t key_len, const u8 *iv, size_t iv_len,
+ const u8 *aad, size_t aad_len, u8 *tag)
+{
+ return aes_gcm_ae(key, key_len, iv, iv_len, NULL, 0, aad, aad_len, NULL,
+ tag);
+}
diff --git a/src/crypto/aes_wrap.h b/src/crypto/aes_wrap.h
index 5b0928e..63925df 100644
--- a/src/crypto/aes_wrap.h
+++ b/src/crypto/aes_wrap.h
@@ -49,5 +49,8 @@ int __must_check aes_gcm_ad(const u8 *key, size_t key_len,
const u8 *crypt, size_t crypt_len,
const u8 *aad, size_t aad_len, const u8 *tag,
u8 *plain);
+int __must_check aes_gmac(const u8 *key, size_t key_len,
+ const u8 *iv, size_t iv_len,
+ const u8 *aad, size_t aad_len, u8 *tag);
#endif /* AES_WRAP_H */
diff --git a/tests/test-aes.c b/tests/test-aes.c
index d917b73..84c959c 100644
--- a/tests/test-aes.c
+++ b/tests/test-aes.c
@@ -407,6 +407,20 @@ static int test_gcm(void)
ret++;
}
+ if (p_len == 0) {
+ if (aes_gmac(k, k_len, iv, iv_len, aad, aad_len, tag) <
+ 0) {
+ printf("GMAC failed (test case %d)\n", i);
+ ret++;
+ continue;
+ }
+
+ if (os_memcmp(tag, t, sizeof(tag)) != 0) {
+ printf("GMAC tag mismatch (test case %d)\n", i);
+ ret++;
+ }
+ }
+
if (aes_gcm_ad(k, k_len, iv, iv_len, c, p_len, aad, aad_len,
t, tmp) < 0) {
printf("GCM-AD failed (test case %d)\n", i);