summaryrefslogtreecommitdiffstats
path: root/crypto/evp
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2019-12-18 14:46:01 +1000
committerShane Lontis <shane.lontis@oracle.com>2019-12-18 14:46:01 +1000
commitb2055d67f0d6cc3156ac89dae255e4abc8881b69 (patch)
tree953d8331bae9fd2980f2380cd35cb341d842af29 /crypto/evp
parent1ac7e15375be39c8f03171c02658cf703f58217a (diff)
Cleanup legacy digest methods.
Macros have been added to generate the simple legacy methods. Engines and EVP_MD_METH_get methods still require access to the old legacy methods, so they needed to be added back in. They may only be removed after engines are deprecated and removed. Removed some unnecessary #includes and #ifndef guards (which are done in build.info instead). Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10602)
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/build.info13
-rw-r--r--crypto/evp/legacy_blake2.c30
-rw-r--r--crypto/evp/legacy_md2.c18
-rw-r--r--crypto/evp/legacy_md4.c18
-rw-r--r--crypto/evp/legacy_md5.c18
-rw-r--r--crypto/evp/legacy_md5_sha1.c24
-rw-r--r--crypto/evp/legacy_mdc2.c19
-rw-r--r--crypto/evp/legacy_meth.h40
-rw-r--r--crypto/evp/legacy_ripemd.c28
-rw-r--r--crypto/evp/legacy_sha.c186
-rw-r--r--crypto/evp/legacy_wp.c28
-rw-r--r--crypto/evp/m_ripemd.c55
-rw-r--r--crypto/evp/m_wp.c54
13 files changed, 254 insertions, 277 deletions
diff --git a/crypto/evp/build.info b/crypto/evp/build.info
index 681201d521..156b26050b 100644
--- a/crypto/evp/build.info
+++ b/crypto/evp/build.info
@@ -7,7 +7,7 @@ SOURCE[../../libcrypto]=$COMMON\
e_des.c e_bf.c e_idea.c e_des3.c e_camellia.c\
e_rc4.c e_aes.c names.c e_seed.c e_aria.c e_sm4.c \
e_xcbc_d.c e_rc2.c e_cast.c e_rc5.c \
- m_null.c m_wp.c m_ripemd.c \
+ m_null.c \
p_open.c p_seal.c p_sign.c p_verify.c p_lib.c p_enc.c p_dec.c \
bio_md.c bio_b64.c bio_enc.c evp_err.c e_null.c \
c_allc.c c_alld.c bio_ok.c \
@@ -17,7 +17,7 @@ SOURCE[../../libcrypto]=$COMMON\
e_aes_cbc_hmac_sha1.c e_aes_cbc_hmac_sha256.c e_rc4_hmac_md5.c \
e_chacha20_poly1305.c \
pkey_mac.c exchange.c \
- legacy_sha.c legacy_md5_sha1.c
+ legacy_sha.c
IF[{- !$disabled{md2} -}]
SOURCE[../../libcrypto]=legacy_md2.c
@@ -26,7 +26,7 @@ IF[{- !$disabled{md4} -}]
SOURCE[../../libcrypto]=legacy_md4.c
ENDIF
IF[{- !$disabled{md5} -}]
- SOURCE[../../libcrypto]=legacy_md5.c
+ SOURCE[../../libcrypto]=legacy_md5.c legacy_md5_sha1.c
ENDIF
IF[{- !$disabled{mdc2} -}]
SOURCE[../../libcrypto]=legacy_mdc2.c
@@ -34,7 +34,12 @@ ENDIF
IF[{- !$disabled{blake2} -}]
SOURCE[../../libcrypto]=legacy_blake2.c
ENDIF
-
+IF[{- !$disabled{whirlpool} -}]
+ SOURCE[../../libcrypto]=legacy_wp.c
+ENDIF
+IF[{- !$disabled{rmd160} -}]
+ SOURCE[../../libcrypto]=legacy_ripemd.c
+ENDIF
SOURCE[../../providers/libfips.a]=$COMMON
diff --git a/crypto/evp/legacy_blake2.c b/crypto/evp/legacy_blake2.c
index 04b1e84865..e03403406f 100644
--- a/crypto/evp/legacy_blake2.c
+++ b/crypto/evp/legacy_blake2.c
@@ -7,25 +7,23 @@
* https://www.openssl.org/source/license.html
*/
-#include <openssl/opensslconf.h>
+#include "crypto/evp.h"
+#include "prov/blake2.h" /* diverse BLAKE2 macros */
+#include "legacy_meth.h"
-#ifndef OPENSSL_NO_BLAKE2
+#define blake2b_init blake2b512_init
+#define blake2s_init blake2s256_init
-# include <openssl/obj_mac.h>
-# include "crypto/evp.h"
-# include "prov/blake2.h" /* diverse BLAKE2 macros */
+IMPLEMENT_LEGACY_EVP_MD_METH_LC(blake2s_int, blake2s)
+IMPLEMENT_LEGACY_EVP_MD_METH_LC(blake2b_int, blake2b)
static const EVP_MD blake2b_md = {
NID_blake2b512,
0,
BLAKE2B_DIGEST_LENGTH,
0,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- BLAKE2B_BLOCKBYTES,
+ LEGACY_EVP_MD_METH_TABLE(blake2b_int_init, blake2b_int_update,
+ blake2b_int_final, NULL, BLAKE2B_BLOCKBYTES),
};
const EVP_MD *EVP_blake2b512(void)
@@ -38,17 +36,11 @@ static const EVP_MD blake2s_md = {
0,
BLAKE2S_DIGEST_LENGTH,
0,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- BLAKE2S_BLOCKBYTES,
+ LEGACY_EVP_MD_METH_TABLE(blake2s_int_init, blake2s_int_update,
+ blake2s_int_final, NULL, BLAKE2S_BLOCKBYTES),
};
const EVP_MD *EVP_blake2s256(void)
{
return &blake2s_md;
}
-
-#endif /* OPENSSL_NO_BLAKE2 */
diff --git a/crypto/evp/legacy_md2.c b/crypto/evp/legacy_md2.c
index d399095f47..6d2e60539c 100644
--- a/crypto/evp/legacy_md2.c
+++ b/crypto/evp/legacy_md2.c
@@ -7,29 +7,21 @@
* https://www.openssl.org/source/license.html
*/
-#include <openssl/opensslconf.h>
+#include <openssl/md2.h>
+#include "crypto/evp.h"
+#include "legacy_meth.h"
-#ifndef OPENSSL_NO_MD2
-
-# include <openssl/md2.h>
-# include "crypto/evp.h"
+IMPLEMENT_LEGACY_EVP_MD_METH(md2, MD2)
static const EVP_MD md2_md = {
NID_md2,
NID_md2WithRSAEncryption,
MD2_DIGEST_LENGTH,
0,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- MD2_BLOCK,
+ LEGACY_EVP_MD_METH_TABLE(md2_init, md2_update, md2_final, NULL, MD2_BLOCK)
};
const EVP_MD *EVP_md2(void)
{
return &md2_md;
}
-
-#endif /* OPENSSL_NO_MD2 */
diff --git a/crypto/evp/legacy_md4.c b/crypto/evp/legacy_md4.c
index fa57e98b78..b68a59fb85 100644
--- a/crypto/evp/legacy_md4.c
+++ b/crypto/evp/legacy_md4.c
@@ -7,29 +7,21 @@
* https://www.openssl.org/source/license.html
*/
-#include <openssl/opensslconf.h>
+#include <openssl/md4.h>
+#include "crypto/evp.h"
+#include "legacy_meth.h"
-#ifndef OPENSSL_NO_MD4
-
-# include <openssl/md4.h>
-# include "crypto/evp.h"
+IMPLEMENT_LEGACY_EVP_MD_METH(md4, MD4)
static const EVP_MD md4_md = {
NID_md4,
NID_md4WithRSAEncryption,
MD4_DIGEST_LENGTH,
0,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- MD4_CBLOCK,
+ LEGACY_EVP_MD_METH_TABLE(md4_init, md4_update, md4_final, NULL, MD4_CBLOCK),
};
const EVP_MD *EVP_md4(void)
{
return &md4_md;
}
-
-#endif /* OPENSSL_NO_MD4 */
diff --git a/crypto/evp/legacy_md5.c b/crypto/evp/legacy_md5.c
index f125b33f91..9bb1258e47 100644
--- a/crypto/evp/legacy_md5.c
+++ b/crypto/evp/legacy_md5.c
@@ -7,29 +7,21 @@
* https://www.openssl.org/source/license.html
*/
-#include <openssl/opensslconf.h>
+#include <openssl/md5.h>
+#include "crypto/evp.h"
+#include "legacy_meth.h"
-#ifndef OPENSSL_NO_MD5
-
-# include <openssl/md5.h>
-# include "crypto/evp.h"
+IMPLEMENT_LEGACY_EVP_MD_METH(md5, MD5)
static const EVP_MD md5_md = {
NID_md5,
NID_md5WithRSAEncryption,
MD5_DIGEST_LENGTH,
0,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- MD5_CBLOCK,
+ LEGACY_EVP_MD_METH_TABLE(md5_init, md5_update, md5_final, NULL, MD5_CBLOCK)
};
const EVP_MD *EVP_md5(void)
{
return &md5_md;
}
-
-#endif /* OPENSSL_NO_MD5 */
diff --git a/crypto/evp/legacy_md5_sha1.c b/crypto/evp/legacy_md5_sha1.c
index a23febfd53..6da6b4fd95 100644
--- a/crypto/evp/legacy_md5_sha1.c
+++ b/crypto/evp/legacy_md5_sha1.c
@@ -7,31 +7,27 @@
* https://www.openssl.org/source/license.html
*/
-#include <openssl/opensslconf.h>
-
+#include "crypto/evp.h"
#include "prov/md5_sha1.h" /* diverse MD5_SHA1 macros */
+#include "legacy_meth.h"
-#ifndef OPENSSL_NO_MD5
-
-# include <openssl/obj_mac.h>
-# include "crypto/evp.h"
+IMPLEMENT_LEGACY_EVP_MD_METH_LC(md5_sha1_int, md5_sha1)
+static int md5_sha1_int_ctrl(EVP_MD_CTX *ctx, int cmd, int mslen, void *ms)
+{
+ return md5_sha1_ctrl(EVP_MD_CTX_md_data(ctx), cmd, mslen, ms);
+}
static const EVP_MD md5_sha1_md = {
NID_md5_sha1,
NID_md5_sha1,
MD5_SHA1_DIGEST_LENGTH,
0,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- MD5_SHA1_CBLOCK,
+ LEGACY_EVP_MD_METH_TABLE(md5_sha1_int_init, md5_sha1_int_update,
+ md5_sha1_int_final, md5_sha1_int_ctrl,
+ MD5_SHA1_CBLOCK),
};
const EVP_MD *EVP_md5_sha1(void)
{
return &md5_sha1_md;
}
-
-#endif /* OPENSSL_NO_MD5 */
diff --git a/crypto/evp/legacy_mdc2.c b/crypto/evp/legacy_mdc2.c
index 5b51b015ea..9144a5715c 100644
--- a/crypto/evp/legacy_mdc2.c
+++ b/crypto/evp/legacy_mdc2.c
@@ -7,29 +7,22 @@
* https://www.openssl.org/source/license.html
*/
-#include <openssl/opensslconf.h>
+#include <openssl/mdc2.h>
+#include "crypto/evp.h"
+#include "legacy_meth.h"
-#ifndef OPENSSL_NO_MDC2
-
-# include <openssl/mdc2.h>
-# include "crypto/evp.h"
+IMPLEMENT_LEGACY_EVP_MD_METH(mdc2, MDC2)
static const EVP_MD mdc2_md = {
NID_mdc2,
NID_mdc2WithRSA,
MDC2_DIGEST_LENGTH,
0,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- MDC2_BLOCK,
+ LEGACY_EVP_MD_METH_TABLE(mdc2_init, mdc2_update, mdc2_final, NULL,
+ MDC2_BLOCK),
};
const EVP_MD *EVP_mdc2(void)
{
return &mdc2_md;
}
-
-#endif /* OPENSSL_NO_MDC2 */
diff --git a/crypto/evp/legacy_meth.h b/crypto/evp/legacy_meth.h
new file mode 100644
index 0000000000..0a23efd05a
--- /dev/null
+++ b/crypto/evp/legacy_meth.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2019 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#define IMPLEMENT_LEGACY_EVP_MD_METH(nm, fn) \
+static int nm##_init(EVP_MD_CTX *ctx) \
+{ \
+ return fn##_Init(EVP_MD_CTX_md_data(ctx)); \
+} \
+static int nm##_update(EVP_MD_CTX *ctx, const void *data, size_t count) \
+{ \
+ return fn##_Update(EVP_MD_CTX_md_data(ctx), data, count); \
+} \
+static int nm##_final(EVP_MD_CTX *ctx, unsigned char *md) \
+{ \
+ return fn##_Final(md, EVP_MD_CTX_md_data(ctx)); \
+}
+
+#define IMPLEMENT_LEGACY_EVP_MD_METH_LC(nm, fn) \
+static int nm##_init(EVP_MD_CTX *ctx) \
+{ \
+ return fn##_init(EVP_MD_CTX_md_data(ctx)); \
+} \
+static int nm##_update(EVP_MD_CTX *ctx, const void *data, size_t count) \
+{ \
+ return fn##_update(EVP_MD_CTX_md_data(ctx), data, count); \
+} \
+static int nm##_final(EVP_MD_CTX *ctx, unsigned char *md) \
+{ \
+ return fn##_final(md, EVP_MD_CTX_md_data(ctx)); \
+}
+
+
+#define LEGACY_EVP_MD_METH_TABLE(init, update, final, ctrl, blksz) \
+ init, update, final, NULL, NULL, blksz, 0, ctrl
diff --git a/crypto/evp/legacy_ripemd.c b/crypto/evp/legacy_ripemd.c
new file mode 100644
index 0000000000..8edcbba371
--- /dev/null
+++ b/crypto/evp/legacy_ripemd.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <openssl/ripemd.h>
+#include "crypto/evp.h"
+#include "legacy_meth.h"
+
+IMPLEMENT_LEGACY_EVP_MD_METH(ripe, RIPEMD160)
+
+static const EVP_MD ripemd160_md = {
+ NID_ripemd160,
+ NID_ripemd160WithRSA,
+ RIPEMD160_DIGEST_LENGTH,
+ 0,
+ LEGACY_EVP_MD_METH_TABLE(ripe_init, ripe_update, ripe_final, NULL,
+ RIPEMD160_CBLOCK),
+};
+
+const EVP_MD *EVP_ripemd160(void)
+{
+ return &ripemd160_md;
+}
diff --git a/crypto/evp/legacy_sha.c b/crypto/evp/legacy_sha.c
index 859c129a26..db289bf2b9 100644
--- a/crypto/evp/legacy_sha.c
+++ b/crypto/evp/legacy_sha.c
@@ -7,24 +7,83 @@
* https://www.openssl.org/source/license.html
*/
-#include <openssl/opensslconf.h>
-
-#include <openssl/obj_mac.h>
#include <openssl/sha.h> /* diverse SHA macros */
#include "internal/sha3.h" /* KECCAK1600_WIDTH */
#include "crypto/evp.h"
+/* Used by legacy methods */
+#include "crypto/sha.h"
+#include "legacy_meth.h"
+#include "evp_local.h"
+
+/*-
+ * LEGACY methods for SHA.
+ * These only remain to support engines that can get these methods.
+ * Hardware support for SHA3 has been removed from these legacy cases.
+ */
+#define IMPLEMENT_LEGACY_EVP_MD_METH_SHA3(nm, fn, tag) \
+static int nm##_init(EVP_MD_CTX *ctx) \
+{ \
+ return fn##_init(EVP_MD_CTX_md_data(ctx), tag, ctx->digest->md_size * 8); \
+} \
+static int nm##_update(EVP_MD_CTX *ctx, const void *data, size_t count) \
+{ \
+ return fn##_update(EVP_MD_CTX_md_data(ctx), data, count); \
+} \
+static int nm##_final(EVP_MD_CTX *ctx, unsigned char *md) \
+{ \
+ return fn##_final(md, EVP_MD_CTX_md_data(ctx)); \
+}
+#define IMPLEMENT_LEGACY_EVP_MD_METH_SHAKE(nm, fn, tag) \
+static int nm##_init(EVP_MD_CTX *ctx) \
+{ \
+ return fn##_init(EVP_MD_CTX_md_data(ctx), tag, ctx->digest->md_size * 8); \
+} \
+
+#define sha512_224_Init sha512_224_init
+#define sha512_256_Init sha512_256_init
+
+#define sha512_224_Update SHA512_Update
+#define sha512_224_Final SHA512_Final
+#define sha512_256_Update SHA512_Update
+#define sha512_256_Final SHA512_Final
+
+IMPLEMENT_LEGACY_EVP_MD_METH(sha1, SHA1)
+IMPLEMENT_LEGACY_EVP_MD_METH(sha224, SHA224)
+IMPLEMENT_LEGACY_EVP_MD_METH(sha256, SHA256)
+IMPLEMENT_LEGACY_EVP_MD_METH(sha384, SHA384)
+IMPLEMENT_LEGACY_EVP_MD_METH(sha512, SHA512)
+IMPLEMENT_LEGACY_EVP_MD_METH(sha512_224_int, sha512_224)
+IMPLEMENT_LEGACY_EVP_MD_METH(sha512_256_int, sha512_256)
+IMPLEMENT_LEGACY_EVP_MD_METH_SHA3(sha3_int, sha3, '\x06')
+IMPLEMENT_LEGACY_EVP_MD_METH_SHAKE(shake, sha3, '\x1f')
+
+static int sha1_int_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2)
+{
+ return sha1_ctrl(ctx != NULL ? EVP_MD_CTX_md_data(ctx) : NULL, cmd, p1, p2);
+}
+
+static int shake_ctrl(EVP_MD_CTX *evp_ctx, int cmd, int p1, void *p2)
+{
+ KECCAK1600_CTX *ctx = evp_ctx->md_data;
+
+ switch (cmd) {
+ case EVP_MD_CTRL_XOF_LEN:
+ ctx->md_size = p1;
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+
static const EVP_MD sha1_md = {
NID_sha1,
NID_sha1WithRSAEncryption,
SHA_DIGEST_LENGTH,
EVP_MD_FLAG_DIGALGID_ABSENT,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- SHA_CBLOCK,
+ LEGACY_EVP_MD_METH_TABLE(sha1_init, sha1_update, sha1_final, sha1_int_ctrl,
+ SHA_CBLOCK),
};
const EVP_MD *EVP_sha1(void)
@@ -37,12 +96,8 @@ static const EVP_MD sha224_md = {
NID_sha224WithRSAEncryption,
SHA224_DIGEST_LENGTH,
EVP_MD_FLAG_DIGALGID_ABSENT,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- SHA256_CBLOCK,
+ LEGACY_EVP_MD_METH_TABLE(sha224_init, sha224_update, sha224_final, NULL,
+ SHA256_CBLOCK),
};
const EVP_MD *EVP_sha224(void)
@@ -55,12 +110,8 @@ static const EVP_MD sha256_md = {
NID_sha256WithRSAEncryption,
SHA256_DIGEST_LENGTH,
EVP_MD_FLAG_DIGALGID_ABSENT,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- SHA256_CBLOCK,
+ LEGACY_EVP_MD_METH_TABLE(sha256_init, sha256_update, sha256_final, NULL,
+ SHA256_CBLOCK),
};
const EVP_MD *EVP_sha256(void)
@@ -73,12 +124,8 @@ static const EVP_MD sha512_224_md = {
NID_sha512_224WithRSAEncryption,
SHA224_DIGEST_LENGTH,
EVP_MD_FLAG_DIGALGID_ABSENT,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- SHA512_CBLOCK,
+ LEGACY_EVP_MD_METH_TABLE(sha512_224_int_init, sha512_224_int_update,
+ sha512_224_int_final, NULL, SHA512_CBLOCK),
};
const EVP_MD *EVP_sha512_224(void)
@@ -91,12 +138,8 @@ static const EVP_MD sha512_256_md = {
NID_sha512_256WithRSAEncryption,
SHA256_DIGEST_LENGTH,
EVP_MD_FLAG_DIGALGID_ABSENT,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- SHA512_CBLOCK,
+ LEGACY_EVP_MD_METH_TABLE(sha512_256_int_init, sha512_256_int_update,
+ sha512_256_int_final, NULL, SHA512_CBLOCK),
};
const EVP_MD *EVP_sha512_256(void)
@@ -109,12 +152,8 @@ static const EVP_MD sha384_md = {
NID_sha384WithRSAEncryption,
SHA384_DIGEST_LENGTH,
EVP_MD_FLAG_DIGALGID_ABSENT,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- SHA512_CBLOCK,
+ LEGACY_EVP_MD_METH_TABLE(sha384_init, sha384_update, sha384_final, NULL,
+ SHA512_CBLOCK),
};
const EVP_MD *EVP_sha384(void)
@@ -127,12 +166,8 @@ static const EVP_MD sha512_md = {
NID_sha512WithRSAEncryption,
SHA512_DIGEST_LENGTH,
EVP_MD_FLAG_DIGALGID_ABSENT,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- SHA512_CBLOCK,
+ LEGACY_EVP_MD_METH_TABLE(sha512_init, sha512_update, sha512_final, NULL,
+ SHA512_CBLOCK),
};
const EVP_MD *EVP_sha512(void)
@@ -140,40 +175,33 @@ const EVP_MD *EVP_sha512(void)
return &sha512_md;
}
-# define EVP_MD_SHA3(bitlen) \
- const EVP_MD *EVP_sha3_##bitlen(void) \
- { \
- static const EVP_MD sha3_##bitlen##_md = { \
- NID_sha3_##bitlen, \
- NID_RSA_SHA3_##bitlen, \
- bitlen / 8, \
- EVP_MD_FLAG_DIGALGID_ABSENT, \
- NULL, \
- NULL, \
- NULL, \
- NULL, \
- NULL, \
- (KECCAK1600_WIDTH - bitlen * 2) / 8, \
- }; \
- return &sha3_##bitlen##_md; \
- }
-# define EVP_MD_SHAKE(bitlen) \
- const EVP_MD *EVP_shake##bitlen(void) \
- { \
- static const EVP_MD shake##bitlen##_md = { \
- NID_shake##bitlen, \
- 0, \
- bitlen / 8, \
- EVP_MD_FLAG_XOF, \
- NULL, \
- NULL, \
- NULL, \
- NULL, \
- NULL, \
- (KECCAK1600_WIDTH - bitlen * 2) / 8, \
- }; \
- return &shake##bitlen##_md; \
- }
+#define EVP_MD_SHA3(bitlen) \
+const EVP_MD *EVP_sha3_##bitlen(void) \
+{ \
+ static const EVP_MD sha3_##bitlen##_md = { \
+ NID_sha3_##bitlen, \
+ NID_RSA_SHA3_##bitlen, \
+ bitlen / 8, \
+ EVP_MD_FLAG_DIGALGID_ABSENT, \
+ LEGACY_EVP_MD_METH_TABLE(sha3_int_init, sha3_int_update, \
+ sha3_int_final, NULL, \
+ (KECCAK1600_WIDTH - bitlen * 2) / 8), \
+ }; \
+ return &sha3_##bitlen##_md; \
+}
+#define EVP_MD_SHAKE(bitlen) \
+const EVP_MD *EVP_shake##bitlen(void) \
+{ \
+ static const EVP_MD shake##bitlen##_md = { \
+ NID_shake##bitlen, \
+ 0, \
+ bitlen / 8, \
+ EVP_MD_FLAG_XOF, \
+ LEGACY_EVP_MD_METH_TABLE(shake_init, sha3_int_update, sha3_int_final, \
+ shake_ctrl, (KECCAK1600_WIDTH - bitlen * 2) / 8), \
+ }; \
+ return &shake##bitlen##_md; \
+}
EVP_MD_SHA3(224)
EVP_MD_SHA3(256)
diff --git a/crypto/evp/legacy_wp.c b/crypto/evp/legacy_wp.c
new file mode 100644
index 0000000000..a9af8c34de
--- /dev/null
+++ b/crypto/evp/legacy_wp.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the Apache License 2.0 (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include <openssl/whrlpool.h>
+#include "crypto/evp.h"
+#include "legacy_meth.h"
+
+IMPLEMENT_LEGACY_EVP_MD_METH(wp, WHIRLPOOL)
+
+static const EVP_MD whirlpool_md = {
+ NID_whirlpool,
+ 0,
+ WHIRLPOOL_DIGEST_LENGTH,
+ 0,
+ LEGACY_EVP_MD_METH_TABLE(wp_init, wp_update, wp_final, NULL,
+ WHIRLPOOL_BBLOCK / 8),
+};
+
+const EVP_MD *EVP_whirlpool(void)
+{
+ return &whirlpool_md;
+}
diff --git a/crypto/evp/m_ripemd.c b/crypto/evp/m_ripemd.c
deleted file mode 100644
index 4e05d18ba6..0000000000
--- a/crypto/evp/m_ripemd.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stdio.h>
-#include "internal/cryptlib.h"
-
-#ifndef OPENSSL_NO_RMD160
-
-# include <openssl/ripemd.h>
-# include <openssl/evp.h>
-# include <openssl/objects.h>
-# include <openssl/x509.h>
-# include <openssl/rsa.h>
-# include "crypto/evp.h"
-
-static int init(EVP_MD_CTX *ctx)
-{
- return RIPEMD160_Init(EVP_MD_CTX_md_data(ctx));
-}
-
-static int update(EVP_MD_CTX *ctx, const void *data, size_t count)
-{
- return RIPEMD160_Update(EVP_MD_CTX_md_data(ctx), data, count);
-}
-
-static int final(EVP_MD_CTX *ctx, unsigned char *md)
-{
- return RIPEMD160_Final(md, EVP_MD_CTX_md_data(ctx));
-}
-
-static const EVP_MD ripemd160_md = {
- NID_ripemd160,
- NID_ripemd160WithRSA,
- RIPEMD160_DIGEST_LENGTH,
- 0,
- init,
- update,
- final,
- NULL,
- NULL,
- RIPEMD160_CBLOCK,
- sizeof(EVP_MD *) + sizeof(RIPEMD160_CTX),
-};
-
-const EVP_MD *EVP_ripemd160(void)
-{
- return &ripemd160_md;
-}
-#endif
diff --git a/crypto/evp/m_wp.c b/crypto/evp/m_wp.c
deleted file mode 100644
index ee69df5658..0000000000
--- a/crypto/evp/m_wp.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved.
- *
- * Licensed under the Apache License 2.0 (the "License"). You may not use
- * this file except in compliance with the License. You can obtain a copy
- * in the file LICENSE in the source distribution or at
- * https://www.openssl.org/source/license.html
- */
-
-#include <stdio.h>
-#include "internal/cryptlib.h"
-
-#ifndef OPENSSL_NO_WHIRLPOOL
-
-# include <openssl/evp.h>
-# include <openssl/objects.h>
-# include <openssl/x509.h>
-# include <openssl/whrlpool.h>
-# include "crypto/evp.h"
-
-static int init(EVP_MD_CTX *ctx)
-{
- return WHIRLPOOL_Init(EVP_MD_CTX_md_data(ctx));
-}
-
-static int update(EVP_MD_CTX *ctx, const void *data, size_t count)
-{
- return WHIRLPOOL_Update(EVP_MD_CTX_md_data(ctx), data, count);
-}
-
-static int final(EVP_MD_CTX *ctx, unsigned char *md)
-{
- return WHIRLPOOL_Final(md, EVP_MD_CTX_md_data(ctx));
-}
-
-static const EVP_MD whirlpool_md = {
- NID_whirlpool,
- 0,
- WHIRLPOOL_DIGEST_LENGTH,
- 0,
- init,
- update,
- final,
- NULL,
- NULL,
- WHIRLPOOL_BBLOCK / 8,
- sizeof(EVP_MD *) + sizeof(WHIRLPOOL_CTX),
-};
-
-const EVP_MD *EVP_whirlpool(void)
-{
- return &whirlpool_md;
-}
-#endif