]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Add test for ocb with 96-bit tag.
authorNiels Möller <nisse@lysator.liu.se>
Mon, 6 Feb 2023 19:08:34 +0000 (20:08 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Mon, 6 Feb 2023 19:28:56 +0000 (20:28 +0100)
testsuite/ocb-test.c

index 5ff61acbd89ced734f71b407e70d9b669e919f4f..10821cf00e5da5b2d5e2c0d241235582f7db6fe7 100644 (file)
@@ -1,5 +1,15 @@
 #include "testutils.h"
 #include "nettle-internal.h"
+#include "ocb-internal.h"
+
+/* For 96-bit tag */
+static void
+set_nonce_tag96 (struct ocb_aes128_ctx *ctx, size_t length, const uint8_t *nonce)
+{
+  assert (length == OCB_NONCE_SIZE);
+  ocb_aes128_set_nonce (&ctx->ocb, &ctx->key,
+                       12, OCB_NONCE_SIZE, nonce);
+}
 
 void
 test_main(void)
@@ -145,6 +155,18 @@ test_main(void)
            SHEX("BBAA9988776655443322110F"), /* nonce */
            SHEX("479AD363AC366B95 A98CA5F3000B1479")); /* tag */
 
+  /* Test with 96-bit tag. */
+  test_aead(&nettle_ocb_aes128, (nettle_hash_update_func *) set_nonce_tag96,
+           SHEX("0F0E0D0C0B0A09080706050403020100"), /* key */
+           SHEX("000102030405060708090A0B0C0D0E0F1011121314151617"
+                "18191A1B1C1D1E1F2021222324252627"), /* auth data */
+           SHEX("000102030405060708090A0B0C0D0E0F1011121314151617"
+                "18191A1B1C1D1E1F2021222324252627"), /* plaintext */
+           SHEX("1792A4E31E0755FB03E31B22116E6C2DDF9EFD6E33D536F1"
+                "A0124B0A55BAE884ED93481529C76B6A"), /* ciphertext */
+           SHEX("BBAA9988776655443322110D"), /* nonce */
+           SHEX("D0C515F4D1CDD4FDAC4F02AA")); /* tag */
+
   /* 16 blocks, not verified with other implementations or any
      authoritative test vector.not an authoritative test vector. */
   test_aead(&nettle_ocb_aes128, NULL,