]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Test non-block pieces of aead associated data.
authorNiels Möller <nisse@lysator.liu.se>
Sun, 10 Mar 2024 09:32:46 +0000 (10:32 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Sun, 10 Mar 2024 09:32:46 +0000 (10:32 +0100)
testsuite/testutils.c

index 8b4fbd1134046a815b055a027b1789e55cd70bd7..24b1c15649fe3e0c5149e425c3ec556fe2717770 100644 (file)
@@ -20,6 +20,8 @@
 # include <valgrind/valgrind.h>
 #endif
 
+#define MIN(a,b) (((a) < (b)) ? (a) : (b))
+
 void
 die(const char *format, ...)
 {
@@ -866,7 +868,7 @@ test_aead(const struct nettle_aead *aead,
            }
          if (aead->update)
            {
-             size_t a_offset = offset <= authtext->length ? offset : authtext->length;
+             size_t a_offset = MIN(authtext->length, offset / aead->block_size);
              aead->update(ctx, a_offset, authtext->data);
              aead->update(ctx, 0, NULL);
              aead->update(ctx, authtext->length - a_offset, authtext->data + a_offset);