#include <openssl/crypto.h>
#include <openssl/core_numbers.h>
+#include <openssl/evp.h>
#include <openssl/sha.h>
#include <openssl/evp.h>
#include <openssl/params.h>
#include "internal/provider_algs.h"
#include "internal/sha.h"
-static OSSL_OP_digest_set_params_fn sha1_set_params;
+static OSSL_OP_digest_ctx_set_params_fn sha1_set_params;
/* Special set_params method for SSL3 */
static int sha1_set_params(void *vctx, const OSSL_PARAM params[])
OSSL_FUNC_DIGEST_CONSTRUCT_PARAMS(sha1, SHA_CTX,
SHA_CBLOCK, SHA_DIGEST_LENGTH,
+ EVP_MD_FLAG_DIGALGID_ABSENT,
SHA1_Init, SHA1_Update, SHA1_Final,
sha1_set_params)
OSSL_FUNC_DIGEST_CONSTRUCT(sha224, SHA256_CTX,
SHA256_CBLOCK, SHA224_DIGEST_LENGTH,
+ EVP_MD_FLAG_DIGALGID_ABSENT,
SHA224_Init, SHA224_Update, SHA224_Final)
OSSL_FUNC_DIGEST_CONSTRUCT(sha256, SHA256_CTX,
SHA256_CBLOCK, SHA256_DIGEST_LENGTH,
+ EVP_MD_FLAG_DIGALGID_ABSENT,
SHA256_Init, SHA256_Update, SHA256_Final)
OSSL_FUNC_DIGEST_CONSTRUCT(sha384, SHA512_CTX,
SHA512_CBLOCK, SHA384_DIGEST_LENGTH,
+ EVP_MD_FLAG_DIGALGID_ABSENT,
SHA384_Init, SHA384_Update, SHA384_Final)
OSSL_FUNC_DIGEST_CONSTRUCT(sha512, SHA512_CTX,
SHA512_CBLOCK, SHA512_DIGEST_LENGTH,
+ EVP_MD_FLAG_DIGALGID_ABSENT,
SHA512_Init, SHA512_Update, SHA512_Final)
OSSL_FUNC_DIGEST_CONSTRUCT(sha512_224, SHA512_CTX,
SHA512_CBLOCK, SHA224_DIGEST_LENGTH,
+ EVP_MD_FLAG_DIGALGID_ABSENT,
sha512_224_init, SHA512_Update, SHA512_Final)
OSSL_FUNC_DIGEST_CONSTRUCT(sha512_256, SHA512_CTX,
SHA512_CBLOCK, SHA256_DIGEST_LENGTH,
+ EVP_MD_FLAG_DIGALGID_ABSENT,
sha512_256_init, SHA512_Update, SHA512_Final)
static OSSL_OP_digest_final_fn keccak_final;
static OSSL_OP_digest_freectx_fn keccak_freectx;
static OSSL_OP_digest_dupctx_fn keccak_dupctx;
-static OSSL_OP_digest_set_params_fn shake_set_params;
+static OSSL_OP_digest_ctx_set_params_fn shake_set_params;
static sha3_absorb_fn generic_sha3_absorb;
static sha3_final_fn generic_sha3_final;
return ctx; \
}
-#define OSSL_FUNC_SHA3_DIGEST(name, bitlen, dgstsize, stparams) \
-static OSSL_OP_digest_size_fn name##_size; \
-static OSSL_OP_digest_block_size_fn name##_block_size; \
-static size_t name##_block_size(void) \
-{ \
- return SHA3_BLOCKSIZE(bitlen); \
-} \
-static size_t name##_size(void) \
-{ \
- return dgstsize; \
-} \
-const OSSL_DISPATCH name##_functions[] = { \
- { OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))name##_newctx }, \
- { OSSL_FUNC_DIGEST_INIT, (void (*)(void))keccak_init }, \
- { OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))keccak_update }, \
- { OSSL_FUNC_DIGEST_FINAL, (void (*)(void))keccak_final }, \
- { OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))keccak_freectx }, \
- { OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))keccak_dupctx }, \
- { OSSL_FUNC_DIGEST_SIZE, (void (*)(void))name##_size }, \
- { OSSL_FUNC_DIGEST_BLOCK_SIZE, (void (*)(void))name##_block_size }, \
- { OSSL_FUNC_DIGEST_SET_PARAMS, (void (*)(void))stparams },\
+#define OSSL_FUNC_SHA3_DIGEST(name, bitlen, blksize, dgstsize, flags, \
+ stparams) \
+static OSSL_OP_digest_get_params_fn name##_get_params; \
+static int name##_get_params(OSSL_PARAM params[]) \
+{ \
+ OSSL_PARAM *p = NULL; \
+ \
+ p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_BLOCK_SIZE); \
+ if (p != NULL && !OSSL_PARAM_set_int(p, (blksize))) \
+ return 0; \
+ p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_SIZE); \
+ if (p != NULL && !OSSL_PARAM_set_int(p, (dgstsize))) \
+ return 0; \
+ p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_FLAGS); \
+ if (p != NULL && !OSSL_PARAM_set_ulong(p, (flags))) \
+ return 0; \
+ return 1; \
+} \
+const OSSL_DISPATCH name##_functions[] = { \
+ { OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))name##_newctx }, \
+ { OSSL_FUNC_DIGEST_INIT, (void (*)(void))keccak_init }, \
+ { OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))keccak_update }, \
+ { OSSL_FUNC_DIGEST_FINAL, (void (*)(void))keccak_final }, \
+ { OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))keccak_freectx }, \
+ { OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))keccak_dupctx }, \
+ { OSSL_FUNC_DIGEST_GET_PARAMS, (void (*)(void))name##_get_params }, \
+ { OSSL_FUNC_DIGEST_CTX_SET_PARAMS, (void (*)(void))stparams }, \
OSSL_FUNC_DIGEST_CONSTRUCT_END
static void keccak_freectx(void *vctx)
#define SHA3(bitlen) \
SHA3_newctx(sha3, SHA3_##bitlen, sha3_##bitlen, bitlen, '\x06') \
- OSSL_FUNC_SHA3_DIGEST(sha3_##bitlen, bitlen, SHA3_MDSIZE(bitlen), NULL)
+ OSSL_FUNC_SHA3_DIGEST(sha3_##bitlen, bitlen, \
+ SHA3_BLOCKSIZE(bitlen), SHA3_MDSIZE(bitlen), \
+ EVP_MD_FLAG_DIGALGID_ABSENT, NULL)
#define SHAKE(bitlen) \
SHA3_newctx(shake, SHAKE_##bitlen, shake_##bitlen, bitlen, '\x1f') \
- OSSL_FUNC_SHA3_DIGEST(shake_##bitlen, bitlen, SHA3_MDSIZE(bitlen), \
- shake_set_params)
+ OSSL_FUNC_SHA3_DIGEST(shake_##bitlen, bitlen, \
+ SHA3_BLOCKSIZE(bitlen), SHA3_MDSIZE(bitlen), \
+ EVP_MD_FLAG_XOF, shake_set_params)
#define KMAC(bitlen) \
KMAC_newctx(keccak_kmac_##bitlen, bitlen, '\x04') \
- OSSL_FUNC_SHA3_DIGEST(keccak_kmac_##bitlen, bitlen, KMAC_MDSIZE(bitlen), \
- shake_set_params)
+ OSSL_FUNC_SHA3_DIGEST(keccak_kmac_##bitlen, bitlen, \
+ SHA3_BLOCKSIZE(bitlen), KMAC_MDSIZE(bitlen), \
+ EVP_MD_FLAG_XOF, shake_set_params)
SHA3(224)
SHA3(256)
}
OSSL_FUNC_DIGEST_CONSTRUCT(blake2s256, BLAKE2S_CTX,
- BLAKE2S_BLOCKBYTES, BLAKE2S_DIGEST_LENGTH,
+ BLAKE2S_BLOCKBYTES, BLAKE2S_DIGEST_LENGTH, 0,
blake2s256_init, blake2s_update, blake2s_final)
OSSL_FUNC_DIGEST_CONSTRUCT(blake2b512, BLAKE2B_CTX,
- BLAKE2B_BLOCKBYTES, BLAKE2B_DIGEST_LENGTH,
+ BLAKE2B_BLOCKBYTES, BLAKE2B_DIGEST_LENGTH, 0,
blake2b512_init, blake2b_update, blake2b_final)
#include "internal/provider_algs.h"
OSSL_FUNC_DIGEST_CONSTRUCT(md5, MD5_CTX,
- MD5_CBLOCK, MD5_DIGEST_LENGTH,
+ MD5_CBLOCK, MD5_DIGEST_LENGTH, 0,
MD5_Init, MD5_Update, MD5_Final)
#include "internal/md5_sha1.h"
#include "internal/provider_algs.h"
-static OSSL_OP_digest_set_params_fn md5_sha1_set_params;
+static OSSL_OP_digest_ctx_set_params_fn md5_sha1_set_params;
/* Special set_params method for SSL3 */
static int md5_sha1_set_params(void *vctx, const OSSL_PARAM params[])
}
OSSL_FUNC_DIGEST_CONSTRUCT_PARAMS(md5_sha1, MD5_SHA1_CTX,
- MD5_SHA1_CBLOCK, MD5_SHA1_DIGEST_LENGTH,
+ MD5_SHA1_CBLOCK, MD5_SHA1_DIGEST_LENGTH, 0,
md5_sha1_init, md5_sha1_update, md5_sha1_final,
md5_sha1_set_params)
*/
#include <openssl/core_numbers.h>
+#include <openssl/core_names.h>
+#include <openssl/params.h>
#include <openssl/whrlpool.h>
#include "internal/provider_algs.h"
static OSSL_OP_digest_newctx_fn nullmd_newctx;
static OSSL_OP_digest_freectx_fn nullmd_freectx;
static OSSL_OP_digest_dupctx_fn nullmd_dupctx;
-static OSSL_OP_digest_size_fn nullmd_size;
-static OSSL_OP_digest_block_size_fn nullmd_block_size;
-
-static size_t nullmd_block_size(void)
-{
- return 0;
-}
-
-static size_t nullmd_size(void)
-{
- return 0;
-}
+static OSSL_OP_digest_get_params_fn nullmd_get_params;
static int nullmd_init(void *vctx)
{
return &nullmd_dummy;
}
+static int nullmd_get_params(OSSL_PARAM params[])
+{
+ OSSL_PARAM *p = NULL;
+
+ p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_BLOCK_SIZE);
+ if (p != NULL && !OSSL_PARAM_set_int(p, 0))
+ return 0;
+ p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_SIZE);
+ if (p != NULL && !OSSL_PARAM_set_int(p, 0))
+ return 0;
+ p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_FLAGS);
+ if (p != NULL && !OSSL_PARAM_set_ulong(p, 0))
+ return 0;
+ return 1;
+}
+
const OSSL_DISPATCH nullmd_functions[] = {
{ OSSL_FUNC_DIGEST_NEWCTX, (void (*)(void))nullmd_newctx },
{ OSSL_FUNC_DIGEST_INIT, (void (*)(void))nullmd_init },
{ OSSL_FUNC_DIGEST_FINAL, (void (*)(void))nullmd_final },
{ OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))nullmd_freectx },
{ OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))nullmd_dupctx },
- { OSSL_FUNC_DIGEST_SIZE, (void (*)(void))nullmd_size },
- { OSSL_FUNC_DIGEST_BLOCK_SIZE, (void (*)(void))nullmd_block_size },
+ { OSSL_FUNC_DIGEST_GET_PARAMS, (void (*)(void))nullmd_get_params },
{ 0, NULL }
};
#include "internal/provider_algs.h"
OSSL_FUNC_DIGEST_CONSTRUCT(sm3, SM3_CTX,
- SM3_CBLOCK, SM3_DIGEST_LENGTH,
+ SM3_CBLOCK, SM3_DIGEST_LENGTH, 0,
sm3_init, sm3_update, sm3_final)
#include "internal/provider_algs.h"
OSSL_FUNC_DIGEST_CONSTRUCT(md2, MD2_CTX,
- MD2_BLOCK, MD2_DIGEST_LENGTH,
+ MD2_BLOCK, MD2_DIGEST_LENGTH, 0,
MD2_Init, MD2_Update, MD2_Final)
#include "internal/provider_algs.h"
OSSL_FUNC_DIGEST_CONSTRUCT(md4, MD4_CTX,
- MD4_CBLOCK, MD4_DIGEST_LENGTH,
+ MD4_CBLOCK, MD4_DIGEST_LENGTH, 0,
MD4_Init, MD4_Update, MD4_Final)
#include "internal/core_mkdigest.h"
#include "internal/provider_algs.h"
-static OSSL_OP_digest_set_params_fn mdc2_set_params;
+static OSSL_OP_digest_ctx_set_params_fn mdc2_set_params;
static int mdc2_set_params(void *vctx, const OSSL_PARAM params[])
{
}
OSSL_FUNC_DIGEST_CONSTRUCT_PARAMS(mdc2, MDC2_CTX,
- MDC2_BLOCK, MDC2_DIGEST_LENGTH,
+ MDC2_BLOCK, MDC2_DIGEST_LENGTH, 0,
MDC2_Init, MDC2_Update, MDC2_Final,
mdc2_set_params)
#include "internal/provider_algs.h"
OSSL_FUNC_DIGEST_CONSTRUCT(ripemd160, RIPEMD160_CTX,
- RIPEMD160_CBLOCK, RIPEMD160_DIGEST_LENGTH,
+ RIPEMD160_CBLOCK, RIPEMD160_DIGEST_LENGTH, 0,
RIPEMD160_Init, RIPEMD160_Update, RIPEMD160_Final)
#include "internal/provider_algs.h"
OSSL_FUNC_DIGEST_CONSTRUCT(wp, WHIRLPOOL_CTX,
- WHIRLPOOL_BBLOCK / 8, WHIRLPOOL_DIGEST_LENGTH,
+ WHIRLPOOL_BBLOCK / 8, WHIRLPOOL_DIGEST_LENGTH, 0,
WHIRLPOOL_Init, WHIRLPOOL_Update, WHIRLPOOL_Final)