]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
accelerated: support GCM_DIGEST in Nettle 4
authorDaiki Ueno <ueno@gnu.org>
Wed, 25 Feb 2026 23:17:43 +0000 (08:17 +0900)
committerDaiki Ueno <ueno@gnu.org>
Fri, 27 Feb 2026 23:37:41 +0000 (08:37 +0900)
Signed-off-by: Daiki Ueno <ueno@gnu.org>
lib/accelerated/x86/aes-gcm-padlock.c
lib/accelerated/x86/aes-gcm-x86-aesni.c
lib/accelerated/x86/aes-gcm-x86-ssse3.c

index 7dbe572b928d4ebd2b5d8fbe20b7ab19f01e9e29..89bac29b4beed97417921ae06822cd49819cc60e 100644 (file)
@@ -35,6 +35,7 @@
 #include "x86-common.h"
 #include <byteswap.h>
 #include <nettle/gcm.h>
+#include <nettle/version.h>
 #include "aes-padlock.h"
 
 #define GCM_BLOCK_SIZE 16
@@ -176,8 +177,14 @@ static int aes_gcm_auth(void *_ctx, const void *src, size_t src_size)
 static void aes_gcm_tag(void *_ctx, void *tag, size_t tagsize)
 {
        struct gcm_padlock_aes_ctx *ctx = _ctx;
+       uint8_t buffer[GCM_DIGEST_SIZE];
 
-       GCM_DIGEST(&ctx->inner, padlock_aes_encrypt, tagsize, tag);
+#if NETTLE_VERSION_MAJOR >= 4
+       GCM_DIGEST(&ctx->inner, padlock_aes_encrypt, buffer);
+#else
+       GCM_DIGEST(&ctx->inner, padlock_aes_encrypt, sizeof(buffer), buffer);
+#endif
+       memcpy(tag, buffer, tagsize);
 }
 
 #include "aes-gcm-aead.h"
index 8f0d23e949f2283915dbb2377cac04ba0c2199d2..d155062f6e3959d9049d246d7019c2d3dfb51b3e 100644 (file)
@@ -36,6 +36,7 @@
 #include "x86-common.h"
 #include <byteswap.h>
 #include <nettle/gcm.h>
+#include <nettle/version.h>
 
 /* GCM mode 
  * It is used when the CPU doesn't include the PCLMUL instructions.
@@ -168,8 +169,14 @@ static int aes_gcm_auth(void *_ctx, const void *src, size_t src_size)
 static void aes_gcm_tag(void *_ctx, void *tag, size_t tagsize)
 {
        struct gcm_x86_aes_ctx *ctx = _ctx;
+       uint8_t buffer[GCM_DIGEST_SIZE];
 
-       GCM_DIGEST(&ctx->inner, x86_aes_encrypt, tagsize, tag);
+#if NETTLE_VERSION_MAJOR >= 4
+       GCM_DIGEST(&ctx->inner, x86_aes_encrypt, buffer);
+#else
+       GCM_DIGEST(&ctx->inner, x86_aes_encrypt, tagsize, buffer);
+#endif
+       memcpy(tag, buffer, tagsize);
 }
 
 static void aes_gcm_deinit(void *_ctx)
index bb2fe3743da7cb47695a4945015c10c4d3f1b9c2..81839585d1e2f38d08ec9cc6d630648d21748732 100644 (file)
@@ -36,6 +36,7 @@
 #include "x86-common.h"
 #include <byteswap.h>
 #include <nettle/gcm.h>
+#include <nettle/version.h>
 #include <assert.h>
 
 /* GCM mode 
@@ -177,8 +178,14 @@ static int aes_gcm_auth(void *_ctx, const void *src, size_t src_size)
 static void aes_gcm_tag(void *_ctx, void *tag, size_t tagsize)
 {
        struct gcm_x86_aes_ctx *ctx = _ctx;
+       uint8_t buffer[GCM_DIGEST_SIZE];
 
-       GCM_DIGEST(&ctx->inner, x86_aes_encrypt, tagsize, tag);
+#if NETTLE_VERSION_MAJOR >= 4
+       GCM_DIGEST(&ctx->inner, x86_aes_encrypt, buffer);
+#else
+       GCM_DIGEST(&ctx->inner, x86_aes_encrypt, tagsize, buffer);
+#endif
+       memcpy(tag, buffer, tagsize);
 }
 
 static void aes_gcm_deinit(void *_ctx)