Latest update
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#ifndef OSSL_CORE_MKDIGEST_H
|
||||
# define OSSL_CORE_MKDIGEST_H
|
||||
|
||||
# include <openssl/core_numbers.h>
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
# define OSSL_FUNC_DIGEST_ALLOC_METHODS(name, CTX_NAME) \
|
||||
static OSSL_OP_digest_newctx_fn name##_newctx; \
|
||||
static OSSL_OP_digest_freectx_fn name##_freectx; \
|
||||
static OSSL_OP_digest_dupctx_fn name##_dupctx; \
|
||||
static void *name##_newctx(void *prov_ctx) \
|
||||
{ \
|
||||
CTX_NAME *ctx = OPENSSL_zalloc(sizeof(*ctx)); \
|
||||
return ctx; \
|
||||
} \
|
||||
static void name##_freectx(void *vctx) \
|
||||
{ \
|
||||
CTX_NAME *ctx = (CTX_NAME *)vctx; \
|
||||
OPENSSL_clear_free(ctx, sizeof(*ctx)); \
|
||||
} \
|
||||
static void *name##_dupctx(void *ctx) \
|
||||
{ \
|
||||
CTX_NAME *in = (CTX_NAME *)ctx; \
|
||||
CTX_NAME *ret = OPENSSL_malloc(sizeof(*ret)); \
|
||||
*ret = *in; \
|
||||
return ret; \
|
||||
}
|
||||
|
||||
# define OSSL_FUNC_DIGEST_SET_FINAL(name, dgstsize, fin) \
|
||||
static OSSL_OP_digest_final_fn name##_wrapfinal; \
|
||||
static int name##_wrapfinal(void *ctx, unsigned char *out, size_t *outl, size_t outsz) \
|
||||
{ \
|
||||
if (outsz >= dgstsize && fin(out, ctx)) { \
|
||||
*outl = dgstsize; \
|
||||
return 1; \
|
||||
} \
|
||||
return 0; \
|
||||
}
|
||||
|
||||
# define OSSL_FUNC_DIGEST_COMMON(name, blksize, dgstsize, init, upd) \
|
||||
static OSSL_OP_digest_block_size_fn name##_block_size; \
|
||||
static OSSL_OP_digest_size_fn name##_size; \
|
||||
static size_t name##_block_size(void) \
|
||||
{ \
|
||||
return blksize; \
|
||||
} \
|
||||
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))init }, \
|
||||
{ OSSL_FUNC_DIGEST_UPDATE, (void (*)(void))upd }, \
|
||||
{ OSSL_FUNC_DIGEST_FINAL, (void (*)(void))name##_wrapfinal }, \
|
||||
{ OSSL_FUNC_DIGEST_FREECTX, (void (*)(void))name##_freectx }, \
|
||||
{ OSSL_FUNC_DIGEST_DUPCTX, (void (*)(void))name##_dupctx }, \
|
||||
{ OSSL_FUNC_DIGEST_SIZE, (void (*)(void))name##_size }, \
|
||||
{ OSSL_FUNC_DIGEST_BLOCK_SIZE, (void (*)(void))name##_block_size },
|
||||
|
||||
# define OSSL_FUNC_DIGEST_CONSTRUCT_START(name, CTX, blksize, dgstsize, init, upd, fin) \
|
||||
OSSL_FUNC_DIGEST_ALLOC_METHODS(name, CTX) \
|
||||
OSSL_FUNC_DIGEST_SET_FINAL(name, dgstsize, fin) \
|
||||
OSSL_FUNC_DIGEST_COMMON(name, blksize, dgstsize, init, upd)
|
||||
|
||||
# define OSSL_FUNC_DIGEST_CONSTRUCT_END \
|
||||
{ 0, NULL } \
|
||||
};
|
||||
|
||||
# define OSSL_FUNC_DIGEST_CONSTRUCT(name, CTX, blksize, dgstsize, init, upd, fin) \
|
||||
OSSL_FUNC_DIGEST_CONSTRUCT_START(name, CTX, blksize, dgstsize, init, upd, fin) \
|
||||
OSSL_FUNC_DIGEST_CONSTRUCT_END
|
||||
|
||||
# define OSSL_FUNC_DIGEST_CONSTRUCT_PARAMS(name, CTX, blksize, dgstsize, init, upd, fin, setparams) \
|
||||
OSSL_FUNC_DIGEST_CONSTRUCT_START(name, CTX, blksize, dgstsize, init, upd, fin) \
|
||||
{ OSSL_FUNC_DIGEST_SET_PARAMS, (void (*)(void))setparams }, \
|
||||
OSSL_FUNC_DIGEST_CONSTRUCT_END
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif /* OSSL_CORE_MKDIGEST_H */
|
||||
@@ -8,7 +8,32 @@
|
||||
*/
|
||||
|
||||
/* Digests */
|
||||
extern const OSSL_DISPATCH sha1_functions[];
|
||||
extern const OSSL_DISPATCH sha224_functions[];
|
||||
extern const OSSL_DISPATCH sha256_functions[];
|
||||
extern const OSSL_DISPATCH sha384_functions[];
|
||||
extern const OSSL_DISPATCH sha512_functions[];
|
||||
extern const OSSL_DISPATCH sha512_224_functions[];
|
||||
extern const OSSL_DISPATCH sha512_256_functions[];
|
||||
extern const OSSL_DISPATCH sha3_224_functions[];
|
||||
extern const OSSL_DISPATCH sha3_256_functions[];
|
||||
extern const OSSL_DISPATCH sha3_384_functions[];
|
||||
extern const OSSL_DISPATCH sha3_512_functions[];
|
||||
extern const OSSL_DISPATCH keccak_kmac_128_functions[];
|
||||
extern const OSSL_DISPATCH keccak_kmac_256_functions[];
|
||||
extern const OSSL_DISPATCH shake_128_functions[];
|
||||
extern const OSSL_DISPATCH shake_256_functions[];
|
||||
extern const OSSL_DISPATCH blake2s256_functions[];
|
||||
extern const OSSL_DISPATCH blake2b512_functions[];
|
||||
extern const OSSL_DISPATCH md5_functions[];
|
||||
extern const OSSL_DISPATCH md5_sha1_functions[];
|
||||
extern const OSSL_DISPATCH sm3_functions[];
|
||||
extern const OSSL_DISPATCH nullmd_functions[];
|
||||
extern const OSSL_DISPATCH md2_functions[];
|
||||
extern const OSSL_DISPATCH md4_functions[];
|
||||
extern const OSSL_DISPATCH mdc2_functions[];
|
||||
extern const OSSL_DISPATCH wp_functions[];
|
||||
extern const OSSL_DISPATCH ripemd160_functions[];
|
||||
|
||||
/* Ciphers */
|
||||
extern const OSSL_DISPATCH aes256ecb_functions[];
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*
|
||||
* To be used anywhere the library context needs to be passed, such as to
|
||||
* fetching functions.
|
||||
*/
|
||||
#define PROV_LIBRARY_CONTEXT_OF(provctx) (provctx)
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#include <openssl/provider.h>
|
||||
|
||||
const OSSL_PROVIDER *FIPS_get_provider(OPENSSL_CTX *ctx);
|
||||
|
||||
const char *ossl_prov_util_nid_to_name(int nid);
|
||||
Reference in New Issue
Block a user