+2023-11-23 Niels Möller <nisse@lysator.liu.se>
+
+ * nettle-internal.h: Keep only declarations actually used
+ internally in the library.
+ * non-nettle.h: New file, contents extracted from
+ nettle-internal.h, for use in test and benchmark code.
+ * non-nettle.c: New file, renamed from ...
+ * nettle-internal.c: ... old name, deleted.
+ * Makefile.in (internal_SOURCES, DISTFILES): Updated accordingly.
+
2023-11-22 Niels Möller <nisse@lysator.liu.se>
Revert part of the 2023-08-05 change.
getopt_SOURCES = getopt.c getopt1.c
getopt_TARGETS = $(getopt_SOURCES:.c=.$(OBJEXT))
-internal_SOURCES = nettle-internal.c
+internal_SOURCES = non-nettle.c
internal_TARGETS = $(internal_SOURCES:.c=.$(OBJEXT))
TARGETS = $(getopt_TARGETS) $(internal_TARGETS) \
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 \
- memxor-internal.h nettle-internal.h nettle-write.h \
+ memxor-internal.h nettle-internal.h non-nettle.h nettle-write.h \
ctr-internal.h chacha-internal.h sha3-internal.h \
salsa20-internal.h umac-internal.h hogweed-internal.h \
rsa-internal.h pkcs1-internal.h dsa-internal.h eddsa-internal.h \
#include "nettle-meta.h"
#include "nettle-internal.h"
+#include "non-nettle.h"
#include "getopt.h"
#include <openssl/md5.h>
#include <openssl/sha.h>
-#include "nettle-internal.h"
+#include "non-nettle.h"
/* We use Openssl's EVP api for all openssl ciphers. This API selects
platform-specific implementations if appropriate, e.g., using x86
/* nettle-internal.h
- Things that are used only by the testsuite and benchmark, and
- not included in the library.
+ Misc internal definitions.
Copyright (C) 2002, 2014 Niels Möller
/* Needed for alloca on bsd systems. */
#include <stdlib.h>
-#include "nettle-meta.h"
-#include "ocb.h"
-#include "aes.h"
-
/* For definition of NETTLE_MAX_HASH_CONTEXT_SIZE. */
#include "sha3.h"
branch free code on all compilers. Requires that x is at most 31 bits. */
#define IS_ZERO_SMALL(x) (((uint32_t) (x) - 1U) >> 31)
-/* Doesn't quite fit with the other algorithms, because of the weak
- * keys. Weak keys are not reported, the functions will simply crash
- * if you try to use a weak key. */
-
-extern const struct nettle_cipher nettle_des;
-extern const struct nettle_cipher nettle_des3;
-
-extern const struct nettle_cipher nettle_blowfish128;
-
-extern const struct nettle_cipher nettle_unified_aes128;
-extern const struct nettle_cipher nettle_unified_aes192;
-extern const struct nettle_cipher nettle_unified_aes256;
-
-/* Stream ciphers treated as aead algorithms with no authentication. */
-extern const struct nettle_aead nettle_arcfour128;
-extern const struct nettle_aead nettle_chacha;
-extern const struct nettle_aead nettle_salsa20;
-extern const struct nettle_aead nettle_salsa20r12;
-
-/* All-in-one CBC encrypt functinos treated as AEAD with no
- authentication and no decrypt method. */
-extern const struct nettle_aead nettle_cbc_aes128;
-extern const struct nettle_aead nettle_cbc_aes192;
-extern const struct nettle_aead nettle_cbc_aes256;
-
-extern const struct nettle_aead nettle_openssl_gcm_aes128;
-extern const struct nettle_aead nettle_openssl_gcm_aes192;
-extern const struct nettle_aead nettle_openssl_gcm_aes256;
-
-
-/* Glue to openssl, for comparative benchmarking. Code in
- * examples/nettle-openssl.c. */
-extern void nettle_openssl_init(void);
-extern const struct nettle_cipher nettle_openssl_aes128;
-extern const struct nettle_cipher nettle_openssl_aes192;
-extern const struct nettle_cipher nettle_openssl_aes256;
-extern const struct nettle_cipher nettle_openssl_blowfish128;
-extern const struct nettle_cipher nettle_openssl_des;
-extern const struct nettle_cipher nettle_openssl_cast128;
-
-extern const struct nettle_hash nettle_openssl_md5;
-extern const struct nettle_hash nettle_openssl_sha1;
-
extern const struct nettle_hash * const _nettle_hashes[];
-/* OCB-declarations to be moved to a public header file, once it's
- settled which nonce and tag sizes to use. */
-#define OCB_NONCE_SIZE 12
-
-struct ocb_aes128_ctx
-{
- struct ocb_ctx ocb;
- struct ocb_aes128_encrypt_key key;
- struct aes128_ctx decrypt;
-};
-
-extern const struct nettle_aead nettle_ocb_aes128;
-
#endif /* NETTLE_INTERNAL_H_INCLUDED */
-/* nettle-internal.c
+/* non-nettle.c
Things that are used only by the testsuite and benchmark, and
not included in the library.
#include <stdlib.h>
#include <string.h>
-#include "nettle-internal.h"
+#include "non-nettle.h"
#include "arcfour.h"
#include "blowfish.h"
#include "cbc.h"
NULL, NULL,
(nettle_crypt_func *) arcfour_crypt,
(nettle_crypt_func *) arcfour_crypt,
- NULL,
+ NULL,
};
const struct nettle_aead
--- /dev/null
+/* non-nettle.h
+
+ Things that are used only by the testsuite and benchmark, and
+ not included in the library.
+
+ Copyright (C) 2002, 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/.
+*/
+
+#ifndef NETTLE_NON_NETTLE_H_INCLUDED
+#define NETTLE_INTERNAL_H_INCLUDED
+
+#include "nettle-meta.h"
+#include "ocb.h"
+#include "aes.h"
+
+/* Doesn't quite fit with the other algorithms, because of the weak
+ * keys. Weak keys are not reported, the functions will simply crash
+ * if you try to use a weak key. */
+
+extern const struct nettle_cipher nettle_des;
+extern const struct nettle_cipher nettle_des3;
+
+extern const struct nettle_cipher nettle_blowfish128;
+
+extern const struct nettle_cipher nettle_unified_aes128;
+extern const struct nettle_cipher nettle_unified_aes192;
+extern const struct nettle_cipher nettle_unified_aes256;
+
+/* Stream ciphers treated as aead algorithms with no authentication. */
+extern const struct nettle_aead nettle_arcfour128;
+extern const struct nettle_aead nettle_chacha;
+extern const struct nettle_aead nettle_salsa20;
+extern const struct nettle_aead nettle_salsa20r12;
+
+/* All-in-one CBC encrypt functinos treated as AEAD with no
+ authentication and no decrypt method. */
+extern const struct nettle_aead nettle_cbc_aes128;
+extern const struct nettle_aead nettle_cbc_aes192;
+extern const struct nettle_aead nettle_cbc_aes256;
+
+extern const struct nettle_aead nettle_openssl_gcm_aes128;
+extern const struct nettle_aead nettle_openssl_gcm_aes192;
+extern const struct nettle_aead nettle_openssl_gcm_aes256;
+
+
+/* Glue to openssl, for comparative benchmarking. Code in
+ * examples/nettle-openssl.c. */
+extern void nettle_openssl_init(void);
+extern const struct nettle_cipher nettle_openssl_aes128;
+extern const struct nettle_cipher nettle_openssl_aes192;
+extern const struct nettle_cipher nettle_openssl_aes256;
+extern const struct nettle_cipher nettle_openssl_blowfish128;
+extern const struct nettle_cipher nettle_openssl_des;
+extern const struct nettle_cipher nettle_openssl_cast128;
+
+extern const struct nettle_hash nettle_openssl_md5;
+extern const struct nettle_hash nettle_openssl_sha1;
+
+/* OCB-declarations to be moved to a public header file, once it's
+ settled which nonce and tag sizes to use. */
+#define OCB_NONCE_SIZE 12
+
+struct ocb_aes128_ctx
+{
+ struct ocb_ctx ocb;
+ struct ocb_aes128_encrypt_key key;
+ struct aes128_ctx decrypt;
+};
+
+extern const struct nettle_aead nettle_ocb_aes128;
+
+
+#endif /* NETTLE_INTERNAL_H_INCLUDED */
#include "aes.h"
#include "cbc.h"
#include "knuth-lfib.h"
-#include "nettle-internal.h"
+#include "non-nettle.h"
/* Test with more data and inplace decryption, to check that the
* cbc_decrypt buffering works. */
#include "testutils.h"
-#include "nettle-internal.h"
+#include "non-nettle.h"
void
test_main(void)
#include "testutils.h"
-#include "nettle-internal.h"
+#include "non-nettle.h"
#include "des.h"
void
#include "testutils.h"
-#include "nettle-internal.h"
+#include "non-nettle.h"
struct ocb_aes128_message_key
{
static void
set_nonce_tag96 (struct ocb_aes128_ctx *ctx, size_t length, const uint8_t *nonce)
{
- assert (length == OCB_NONCE_SIZE);
+ ASSERT (length == OCB_NONCE_SIZE);
ocb_aes128_set_nonce (&ctx->ocb, &ctx->key,
12, OCB_NONCE_SIZE, nonce);
}