Change type of the rounds argument from size_t to unsigned.
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 \
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);
(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))
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);
#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;
#include <assert.h>
#include "gcm.h"
+#include "gcm-internal.h"
void
gcm_aes128_set_key(struct gcm_aes128_ctx *ctx, const uint8_t *key)
#include <assert.h>
#include "gcm.h"
+#include "gcm-internal.h"
void
gcm_aes192_set_key(struct gcm_aes192_ctx *ctx, const uint8_t *key)
#include <assert.h>
#include "gcm.h"
+#include "gcm-internal.h"
void
gcm_aes256_set_key(struct gcm_aes256_ctx *ctx, const uint8_t *key)
--- /dev/null
+/* 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 */
#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