diff --git a/ChangeLog b/ChangeLog index 075ab1978a654d546d2bb56697b98914af525571..8e79d4876a7136b02a8f425cc89e9dffe5446e8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2023-12-05 Niels Möller <nisse@lysator.liu.se> + + * examples/nettle-openssl.c: Trim openssl includes and defines, + and use Nettle's definition of sha1 and md5 constants. + (nettle_openssl_init): Deleted. + * examples/nettle-benchmark.c (main): Delete call to nettle_openssl_init. + 2023-12-04 Niels Möller <nisse@lysator.liu.se> * examples/nettle-openssl.c (nettle_openssl_blowfish128) diff --git a/examples/nettle-benchmark.c b/examples/nettle-benchmark.c index 37073a67a2804401eb273cecbb08e5c48f8c63cc..2a11a6949e74e13d3c7f2764e34cdb1099efedb1 100644 --- a/examples/nettle-benchmark.c +++ b/examples/nettle-benchmark.c @@ -908,10 +908,6 @@ main(int argc, char **argv) int c; const char *alg; -#if WITH_OPENSSL - nettle_openssl_init(); -#endif - const struct nettle_hash *hashes[] = { &nettle_md2, &nettle_md4, &nettle_md5, diff --git a/examples/nettle-openssl.c b/examples/nettle-openssl.c index 0d798617a937279e85f7cf11a2a461aeac497f3f..cb179416640ad4b705b3fa638116bdd49b27a794 100644 --- a/examples/nettle-openssl.c +++ b/examples/nettle-openssl.c @@ -40,20 +40,13 @@ #if WITH_OPENSSL -/* No ancient ssleay compatibility */ -#define NCOMPAT -#define OPENSSL_DISABLE_OLD_DES_SUPPORT - #include <assert.h> -#include <openssl/conf.h> #include <openssl/evp.h> -#include <openssl/err.h> - -#include <openssl/md5.h> -#include <openssl/sha.h> #include "non-nettle.h" +#include "md5.h" +#include "sha1.h" /* We use Openssl's EVP api for all openssl ciphers. This API selects platform-specific implementations if appropriate, e.g., using x86 @@ -69,18 +62,6 @@ struct openssl_hash_ctx { EVP_MD_CTX *evp; }; -void -nettle_openssl_init(void) -{ - ERR_load_crypto_strings(); - OpenSSL_add_all_algorithms(); -#if OPENSSL_VERSION_NUMBER >= 0x1010000 - CONF_modules_load_file(NULL, NULL, 0); -#else - OPENSSL_config(NULL); -#endif -} - static void openssl_evp_set_encrypt_key(void *p, const uint8_t *key, const EVP_CIPHER *cipher) @@ -315,7 +296,7 @@ static void \ openssl_##name##_init(void *p) \ { \ struct openssl_hash_ctx *ctx = p; \ - if ((ctx->evp = EVP_MD_CTX_new()) == NULL) \ + if ((ctx->evp = EVP_MD_CTX_new()) == NULL) \ return; \ \ EVP_DigestInit(ctx->evp, EVP_##name()); \ @@ -326,7 +307,7 @@ openssl_##name##_digest(void *p, \ size_t length, uint8_t *dst) \ { \ struct openssl_hash_ctx *ctx = p; \ - assert(length == NAME##_DIGEST_LENGTH); \ + assert(length == NAME##_DIGEST_SIZE); \ \ EVP_DigestFinal(ctx->evp, dst, NULL); \ EVP_DigestInit(ctx->evp, EVP_##name()); \ @@ -335,13 +316,13 @@ openssl_##name##_digest(void *p, \ const struct nettle_hash \ nettle_openssl_##name = { \ "openssl " #name, sizeof(struct openssl_hash_ctx), \ - NAME##_DIGEST_LENGTH, NAME##_CBLOCK, \ + NAME##_DIGEST_SIZE, NAME##_BLOCK_SIZE, \ openssl_##name##_init, \ openssl_hash_update, \ openssl_##name##_digest \ }; OPENSSL_HASH(MD5, md5) -OPENSSL_HASH(SHA, sha1) +OPENSSL_HASH(SHA1, sha1) #endif /* WITH_OPENSSL */ diff --git a/non-nettle.h b/non-nettle.h index 7075540a514d308807a28a538907434dd7d3e091..4da0cdde3f0683ffd8f61829bd25cfe61e5f0d5e 100644 --- a/non-nettle.h +++ b/non-nettle.h @@ -71,7 +71,6 @@ 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;