From: Niels Möller Date: Fri, 15 Mar 2024 20:30:25 +0000 (+0100) Subject: Rework no-op version of _gcm_aes_encrypt and _gcm_aes_decrypt. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fppc64-gcm-aes;p=thirdparty%2Fnettle.git Rework no-op version of _gcm_aes_encrypt and _gcm_aes_decrypt. 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. --- diff --git a/Makefile.in b/Makefile.in index 4f751609..b1c03e85 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 \ diff --git a/fat-ppc.c b/fat-ppc.c index ec6d200e..a3ef1ec1 100644 --- 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 index 3b55c5ca..00000000 --- a/gcm-aes-crypt.c +++ /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 - -#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; -} diff --git a/gcm-internal.h b/gcm-internal.h index 5710bb9b..c1e11056 100644 --- a/gcm-internal.h +++ b/gcm-internal.h @@ -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 */