]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Rework no-op version of _gcm_aes_encrypt and _gcm_aes_decrypt.
authorNiels Möller <nisse@lysator.liu.se>
Fri, 15 Mar 2024 20:30:25 +0000 (21:30 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Sat, 13 Apr 2024 07:59:16 +0000 (09:59 +0200)
For fat builds, move definition to fat-ppc.c. For builds where the
functions are unavailable, define as macros returning zero, and rely
on the compiler to eliminate the code that uses the return value.

Makefile.in
fat-ppc.c
gcm-aes-crypt.c [deleted file]
gcm-internal.h

index 145ec299169ac280f04d054d5f1ea0fb6f8c8903..cfc83e0b46bca9b1fcb944a49004c169fa8cc83d 100644 (file)
@@ -112,7 +112,6 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c aes-decrypt-table.c \
                 ghash-set-key.c ghash-update.c \
                 siv-ghash-set-key.c siv-ghash-update.c \
                 gcm.c gcm-aes.c \
-                gcm-aes-crypt.c \
                 gcm-aes128.c gcm-aes128-meta.c \
                 gcm-aes192.c gcm-aes192-meta.c \
                 gcm-aes256.c gcm-aes256-meta.c \
index ec6d200e6d875195270842956389f50fa241a3b0..a3ef1ec14c8f175f6cec5eabdccdfb0a8f997cc1 100644 (file)
--- a/fat-ppc.c
+++ b/fat-ppc.c
@@ -211,6 +211,13 @@ DECLARE_FAT_FUNC(_nettle_poly1305_blocks, poly1305_blocks_func)
 DECLARE_FAT_FUNC_VAR(poly1305_blocks, poly1305_blocks_func, c)
 DECLARE_FAT_FUNC_VAR(poly1305_blocks, poly1305_blocks_func, ppc64)
 
+/* Nop implementation for _gcm_aes_encrypt and _gcm_aes_decrypt. */
+static size_t
+gcm_aes_crypt_c (struct gcm_key *key UNUSED, unsigned rounds UNUSED,
+                size_t size UNUSED, uint8_t *dst UNUSED, const uint8_t *src UNUSED)
+{
+  return 0;
+}
 
 static void CONSTRUCTOR
 fat_init (void)
@@ -249,8 +256,8 @@ fat_init (void)
       _nettle_aes_invert_vec = _nettle_aes_invert_c;
       _nettle_ghash_set_key_vec = _nettle_ghash_set_key_c;
       _nettle_ghash_update_vec = _nettle_ghash_update_c;
-      _nettle_gcm_aes_encrypt_vec = _nettle_gcm_aes_encrypt_c;
-      _nettle_gcm_aes_decrypt_vec = _nettle_gcm_aes_decrypt_c;
+      _nettle_gcm_aes_encrypt_vec = gcm_aes_crypt_c;
+      _nettle_gcm_aes_decrypt_vec = gcm_aes_crypt_c;
     }
   if (features.have_altivec)
     {
diff --git a/gcm-aes-crypt.c b/gcm-aes-crypt.c
deleted file mode 100644 (file)
index 3b55c5c..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* gcm-aes-crypt.c
-
-   Galois counter mode using AES as the underlying cipher.
-
-   Copyright (C) 2011, 2014 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/.
-*/
-
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#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, 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, 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, unsigned rounds,
-                  size_t len, uint8_t *dst, const uint8_t *src)
-{
-  return 0;
-}
-
-size_t
-_gcm_aes_decrypt (struct gcm_key *key, unsigned rounds,
-                  size_t len, uint8_t *dst, const uint8_t *src)
-{
-  return 0;
-}
index 5710bb9b43979b32d9d0bf717dd5f0d46b578a9c..c1e11056dcb146016bc01b6acc1a2b62cb94c906 100644 (file)
@@ -34,6 +34,8 @@
 
 #include "gcm.h"
 
+#if HAVE_NATIVE_gcm_aes_encrypt
+
 /* Name mangling */
 #define _gcm_aes_encrypt _nettle_gcm_aes_encrypt
 #define _gcm_aes_decrypt _nettle_gcm_aes_decrypt
@@ -51,5 +53,9 @@ size_t
 _gcm_aes_decrypt (struct gcm_key *CTX,
                  unsigned rounds,
                  size_t size, uint8_t *dst, const uint8_t *src);
+#else /* !HAVE_NATIVE_gcm_aes_encrypt */
+#define _gcm_aes_encrypt(key, rounds, size, dst, src) 0
+#define _gcm_aes_decrypt(key, rounds, size, dst, src) 0
+#endif /* !HAVE_NATIVE_gcm_aes_encrypt */
 
 #endif /* NETTLE_GCM_INTERNAL_H_INCLUDED */