+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)
#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
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)
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()); \
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()); \
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 */