]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Add gcm-internal.h, declaring _gcm_aes_encrypt and _gcm_aes_decrypt.
authorNiels Möller <nisse@lysator.liu.se>
Thu, 14 Mar 2024 20:29:50 +0000 (21:29 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Sat, 13 Apr 2024 07:59:16 +0000 (09:59 +0200)
Change type of the rounds argument from size_t to unsigned.

Makefile.in
fat-ppc.c
fat-setup.h
gcm-aes-crypt.c
gcm-aes128.c
gcm-aes192.c
gcm-aes256.c
gcm-internal.h [new file with mode: 0644]
gcm.h

index ea093c0063047e7068b2963a94e5a449f9bf331c..145ec299169ac280f04d054d5f1ea0fb6f8c8903 100644 (file)
@@ -271,7 +271,7 @@ DISTFILES = $(SOURCES) $(HEADERS) getopt.h getopt_int.h \
        nettle.pc.in hogweed.pc.in \
        desdata.stamp $(des_headers) descore.README \
        aes-internal.h block-internal.h blowfish-internal.h bswap-internal.h \
-       camellia-internal.h \
+       camellia-internal.h gcm-internal.h \
        ghash-internal.h gost28147-internal.h poly1305-internal.h \
        serpent-internal.h cast128_sboxes.h desinfo.h desCode.h \
        ripemd160-internal.h md-internal.h sha2-internal.h \
index 70d8072e8609c92b405d831b61b0ae83b103451e..ec6d200e6d875195270842956389f50fa241a3b0 100644 (file)
--- a/fat-ppc.c
+++ b/fat-ppc.c
@@ -175,13 +175,13 @@ DECLARE_FAT_FUNC(_nettle_ghash_update, ghash_update_func)
 DECLARE_FAT_FUNC_VAR(ghash_update, ghash_update_func, c)
 DECLARE_FAT_FUNC_VAR(ghash_update, ghash_update_func, ppc64)
 
-DECLARE_FAT_FUNC(_nettle_gcm_aes_encrypt, gcm_aes_encrypt_func)
-DECLARE_FAT_FUNC_VAR(gcm_aes_encrypt, gcm_aes_encrypt_func, c)
-DECLARE_FAT_FUNC_VAR(gcm_aes_encrypt, gcm_aes_encrypt_func, ppc64)
+DECLARE_FAT_FUNC(_nettle_gcm_aes_encrypt, gcm_aes_crypt_func)
+DECLARE_FAT_FUNC_VAR(gcm_aes_encrypt, gcm_aes_crypt_func, c)
+DECLARE_FAT_FUNC_VAR(gcm_aes_encrypt, gcm_aes_crypt_func, ppc64)
 
-DECLARE_FAT_FUNC(_nettle_gcm_aes_decrypt, gcm_aes_decrypt_func)
-DECLARE_FAT_FUNC_VAR(gcm_aes_decrypt, gcm_aes_decrypt_func, c)
-DECLARE_FAT_FUNC_VAR(gcm_aes_decrypt, gcm_aes_decrypt_func, ppc64)
+DECLARE_FAT_FUNC(_nettle_gcm_aes_decrypt, gcm_aes_crypt_func)
+DECLARE_FAT_FUNC_VAR(gcm_aes_decrypt, gcm_aes_crypt_func, c)
+DECLARE_FAT_FUNC_VAR(gcm_aes_decrypt, gcm_aes_crypt_func, ppc64)
 
 DECLARE_FAT_FUNC(_nettle_chacha_core, chacha_core_func)
 DECLARE_FAT_FUNC_VAR(chacha_core, chacha_core_func, c);
@@ -312,12 +312,12 @@ DEFINE_FAT_FUNC(_nettle_ghash_update, const uint8_t *,
                (ctx, state, blocks, data))
 
 DEFINE_FAT_FUNC(_nettle_gcm_aes_encrypt, size_t,
-               (struct gcm_key *key, size_t rounds,
+               (struct gcm_key *key, unsigned rounds,
                  size_t len, uint8_t *dst, const uint8_t *src),
                (key, rounds, len, dst, src))
 
 DEFINE_FAT_FUNC(_nettle_gcm_aes_decrypt, size_t,
-               (struct gcm_key *key, size_t rounds,
+               (struct gcm_key *key, unsigned rounds,
                  size_t len, uint8_t *dst, const uint8_t *src),
                (key, rounds, len, dst, src))
 
index c665e1579d79e47a6be28aabf9dd118c5fadab79..37a600a839fc125168bee925c2f15a665f1d0fa6 100644 (file)
@@ -171,11 +171,8 @@ ghash_update_func (const struct gcm_key *ctx, union nettle_block16 *state,
                   size_t blocks, const uint8_t *data);
 
 typedef size_t
-gcm_aes_encrypt_func (struct gcm_key *key, size_t rounds,
-                      size_t len, uint8_t *dst, const uint8_t *src);
-typedef size_t
-gcm_aes_decrypt_func (struct gcm_key *key, size_t rounds,
-                      size_t len, uint8_t *dst, const uint8_t *src);
+gcm_aes_crypt_func (struct gcm_key *key, unsigned rounds,
+                   size_t len, uint8_t *dst, const uint8_t *src);
 
 typedef void *(memxor_func)(void *dst, const void *src, size_t n);
 typedef void *(memxor3_func)(void *dst_in, const void *a_in, const void *b_in, size_t n);
index 675ee6b0951cd715d57ab6efbf079b2afebf5b63..3b55c5ca4f7377f25fc13eb75868b9ff3017e55e 100644 (file)
 #include <assert.h>
 
 #include "gcm.h"
+#include "gcm-internal.h"
 
 /* For fat builds */
 #if HAVE_NATIVE_gcm_aes_encrypt
 size_t
-_gcm_aes_encrypt (struct gcm_key *key, size_t rounds,
+_gcm_aes_encrypt (struct gcm_key *key, unsigned rounds,
                   size_t len, uint8_t *dst, const uint8_t *src);
 #define _nettle_gcm_aes_encrypt _nettle_gcm_aes_encrypt_c
 #endif
 
 #if HAVE_NATIVE_gcm_aes_decrypt
 size_t
-_gcm_aes_decrypt (struct gcm_key *key, size_t rounds,
+_gcm_aes_decrypt (struct gcm_key *key, unsigned rounds,
                   size_t len, uint8_t *dst, const uint8_t *src);
 #define _nettle_gcm_aes_decrypt _nettle_gcm_aes_decrypt_c
 #endif
 
 size_t
-_gcm_aes_encrypt (struct gcm_key *key, size_t rounds,
+_gcm_aes_encrypt (struct gcm_key *key, unsigned rounds,
                   size_t len, uint8_t *dst, const uint8_t *src)
 {
   return 0;
 }
 
 size_t
-_gcm_aes_decrypt (struct gcm_key *key, size_t rounds,
+_gcm_aes_decrypt (struct gcm_key *key, unsigned rounds,
                   size_t len, uint8_t *dst, const uint8_t *src)
 {
   return 0;
index 580882a4d9ca465007544ca554360c245fd75922..7ff06199883a4ccd4c1af12a07546db7b5f3bb54 100644 (file)
@@ -38,6 +38,7 @@
 #include <assert.h>
 
 #include "gcm.h"
+#include "gcm-internal.h"
 
 void
 gcm_aes128_set_key(struct gcm_aes128_ctx *ctx, const uint8_t *key)
index 9fd2a15d104ce2416f7afe1b166a57de9b31e432..83c32e02e731cc9346db26c63b48b4f84b6eb737 100644 (file)
@@ -38,6 +38,7 @@
 #include <assert.h>
 
 #include "gcm.h"
+#include "gcm-internal.h"
 
 void
 gcm_aes192_set_key(struct gcm_aes192_ctx *ctx, const uint8_t *key)
index 84d44c6eb00b76ac4ef4438bc7776cbab015ed8b..4974001fae0c8f1e8c2c2f97403367b2ded40e47 100644 (file)
@@ -38,6 +38,7 @@
 #include <assert.h>
 
 #include "gcm.h"
+#include "gcm-internal.h"
 
 void
 gcm_aes256_set_key(struct gcm_aes256_ctx *ctx, const uint8_t *key)
diff --git a/gcm-internal.h b/gcm-internal.h
new file mode 100644 (file)
index 0000000..5710bb9
--- /dev/null
@@ -0,0 +1,55 @@
+/* gcm-internal.h
+
+   Copyright (C) 2024 Niels Möller
+
+   This file is part of GNU Nettle.
+
+   GNU Nettle is free software: you can redistribute it and/or
+   modify it under the terms of either:
+
+     * the GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 3 of the License, or (at your
+       option) any later version.
+
+   or
+
+     * the GNU General Public License as published by the Free
+       Software Foundation; either version 2 of the License, or (at your
+       option) any later version.
+
+   or both in parallel, as here.
+
+   GNU Nettle is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see http://www.gnu.org/licenses/.
+*/
+
+#ifndef NETTLE_GCM_INTERNAL_H_INCLUDED
+#define NETTLE_GCM_INTERNAL_H_INCLUDED
+
+#include "gcm.h"
+
+/* Name mangling */
+#define _gcm_aes_encrypt _nettle_gcm_aes_encrypt
+#define _gcm_aes_decrypt _nettle_gcm_aes_decrypt
+
+/* To reduce the number of arguments (e.g., maximum of 6 register
+   arguments on x86_64), pass a pointer to gcm_key, which really is a
+   pointer to the first member of the appropriate gcm_aes*_ctx
+   struct. */
+size_t
+_gcm_aes_encrypt (struct gcm_key *key,
+                 unsigned rounds,
+                 size_t size, uint8_t *dst, const uint8_t *src);
+
+size_t
+_gcm_aes_decrypt (struct gcm_key *CTX,
+                 unsigned rounds,
+                 size_t size, uint8_t *dst, const uint8_t *src);
+
+#endif /* NETTLE_GCM_INTERNAL_H_INCLUDED */
diff --git a/gcm.h b/gcm.h
index 52af4863bcd4f5b43b893c3c28bef142aa3b9801..39af5ab03bb16bd8cc2826d6bfb949378ca116b7 100644 (file)
--- a/gcm.h
+++ b/gcm.h
@@ -54,9 +54,6 @@ extern "C" {
 #define gcm_decrypt nettle_gcm_decrypt
 #define gcm_digest nettle_gcm_digest
 
-#define _gcm_aes_encrypt _nettle_gcm_aes_encrypt
-#define _gcm_aes_decrypt _nettle_gcm_aes_decrypt
-
 #define gcm_aes128_set_key nettle_gcm_aes128_set_key
 #define gcm_aes128_set_iv nettle_gcm_aes128_set_iv
 #define gcm_aes128_update nettle_gcm_aes128_update