* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
+{-
+use OpenSSL::paramnames qw(produce_param_decoder);
+-}
+#include <string.h>
#include <openssl/crypto.h>
#include <openssl/core_names.h>
#include <openssl/proverr.h>
#include <openssl/err.h>
+#include "internal/cryptlib.h"
#include "prov/blake2.h"
#include "prov/digestcommon.h"
#include "prov/implementations.h"
+static OSSL_FUNC_digest_gettable_ctx_params_fn blake_gettable_ctx_params;
+static OSSL_FUNC_digest_settable_ctx_params_fn blake_settable_ctx_params;
+
+{- produce_param_decoder('blake_get_ctx_params',
+ (['DIGEST_PARAM_SIZE', 'size', 'uint'],
+ )); -}
+
+static const OSSL_PARAM *blake_gettable_ctx_params(ossl_unused void *ctx,
+ ossl_unused void *pctx)
+{
+ return blake_get_ctx_params_list;
+}
+
+{- produce_param_decoder('blake_set_ctx_params',
+ (['DIGEST_PARAM_SIZE', 'size', 'uint'],
+ )); -}
+
+static const OSSL_PARAM *blake_settable_ctx_params(ossl_unused void *ctx,
+ ossl_unused void *pctx)
+{
+ return blake_set_ctx_params_list;
+}
+
#define IMPLEMENT_BLAKE_functions(variant, VARIANT, variantsize) \
-static const OSSL_PARAM known_blake##variant##_ctx_params[] = { \
- {OSSL_DIGEST_PARAM_SIZE, OSSL_PARAM_UNSIGNED_INTEGER, NULL, 0, 0}, \
- OSSL_PARAM_END \
-}; \
- \
-const OSSL_PARAM *ossl_blake##variant##_gettable_ctx_params(ossl_unused void *ctx, \
- ossl_unused void *pctx) \
-{ \
- return known_blake##variant##_ctx_params; \
-} \
- \
-const OSSL_PARAM *ossl_blake##variant##_settable_ctx_params(ossl_unused void *ctx, \
- ossl_unused void *pctx) \
-{ \
- return known_blake##variant##_ctx_params; \
-} \
- \
int ossl_blake##variant##_get_ctx_params(void *vctx, OSSL_PARAM params[]) \
{ \
struct blake##variant##_md_data_st *mdctx = vctx; \
- OSSL_PARAM *p; \
+ struct blake_get_ctx_params_st p; \
\
BLAKE##VARIANT##_CTX *ctx = &mdctx->ctx; \
\
- if (ctx == NULL) \
+ if (ctx == NULL || !blake_get_ctx_params_decoder(params, &p)) \
return 0; \
- if (ossl_param_is_empty(params)) \
- return 1; \
\
- p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_SIZE); \
- if (p != NULL \
- && !OSSL_PARAM_set_uint(p, (unsigned int)mdctx->params.digest_length)) { \
+ if (p.size != NULL \
+ && !OSSL_PARAM_set_uint(p.size, (unsigned int)mdctx->params.digest_length)) { \
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER); \
return 0; \
} \
\
int ossl_blake##variant##_set_ctx_params(void *vctx, const OSSL_PARAM params[]) \
{ \
- size_t size; \
+ unsigned int size; \
struct blake##variant##_md_data_st *mdctx = vctx; \
- const OSSL_PARAM *p; \
+ struct blake_set_ctx_params_st p; \
\
BLAKE##VARIANT##_CTX *ctx = &mdctx->ctx; \
\
- if (ctx == NULL) \
+ if (ctx == NULL || !blake_set_ctx_params_decoder(params, &p)) \
return 0; \
- if (ossl_param_is_empty(params)) \
- return 1; \
\
- p = OSSL_PARAM_locate_const(params, OSSL_DIGEST_PARAM_SIZE); \
- if (p != NULL) { \
- if (!OSSL_PARAM_get_size_t(p, &size)) { \
+ if (p.size != NULL) { \
+ if (!OSSL_PARAM_get_uint(p.size, &size)) { \
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_GET_PARAMETER); \
return 0; \
} \
(void (*)(void))ossl_digest_default_gettable_params}, \
{OSSL_FUNC_DIGEST_INIT, (void (*)(void))blake##variantsize##_internal_init}, \
{OSSL_FUNC_DIGEST_GETTABLE_CTX_PARAMS, \
- (void (*)(void))ossl_blake##variant##_gettable_ctx_params}, \
+ (void (*)(void))blake_gettable_ctx_params}, \
{OSSL_FUNC_DIGEST_SETTABLE_CTX_PARAMS, \
- (void (*)(void))ossl_blake##variant##_settable_ctx_params}, \
+ (void (*)(void))blake_settable_ctx_params}, \
{OSSL_FUNC_DIGEST_GET_CTX_PARAMS, \
(void (*)(void))ossl_blake##variant##_get_ctx_params}, \
{OSSL_FUNC_DIGEST_SET_CTX_PARAMS, \