]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Add aes_gmac() as a wrapper for AES GMAC operations using GCM
authorJouni Malinen <j@w1.fi>
Sun, 9 Sep 2012 10:37:50 +0000 (13:37 +0300)
committerJouni Malinen <j@w1.fi>
Sun, 9 Sep 2012 10:37:50 +0000 (13:37 +0300)
This is otherwise identical to aes_gcm_ae() but does not use the
plain/crypt pointers since no data is encrypted.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/crypto/aes-gcm.c
src/crypto/aes_wrap.h
tests/test-aes.c

index d3105edaff180538484d28939ee58ff6713c1aa3..f6f4074b06084ac95217b560dca0777fdd8c0be8 100644 (file)
@@ -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);
+}
index 5b0928e205b713aab7f68b0495b47c4045692e7a..63925dfdc941828e3e73a70b9de80165d4598d42 100644 (file)
@@ -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 */
index d917b73bf189283320551f9b4f98ae6e59398c98..84c959cbd173adba52da6f882d8339ad8b421fb8 100644 (file)
@@ -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);