| 1 |
/* |
| 2 |
* Copyright 2019-2025 The OpenSSL Project Authors. All Rights Reserved. |
| 3 |
* |
| 4 |
* Licensed under the Apache License 2.0 (the "License"). You may not use |
| 5 |
* this file except in compliance with the License. You can obtain a copy |
| 6 |
* in the file LICENSE in the source distribution or at |
| 7 |
* https://www.openssl.org/source/license.html |
| 8 |
*/ |
| 9 |
/* clang-format off */ |
| 10 |
{- |
| 11 |
use OpenSSL::paramnames qw(produce_param_decoder); |
| 12 |
-} |
| 13 |
/* clang-format on */ |
| 14 |
|
| 15 |
#include <string.h> |
| 16 |
#include <openssl/err.h> |
| 17 |
#include <openssl/proverr.h> |
| 18 |
#include "prov/digestcommon.h" |
| 19 |
#include "internal/common.h" |
| 20 |
|
| 21 |
/* clang-format off */ |
| 22 |
{- produce_param_decoder('digest_default_get_params', |
| 23 |
(['OSSL_DIGEST_PARAM_BLOCK_SIZE', 'bsize', 'size_t'], |
| 24 |
['OSSL_DIGEST_PARAM_SIZE', 'size', 'size_t'], |
| 25 |
['OSSL_DIGEST_PARAM_XOF', 'xof', 'int'], |
| 26 |
['OSSL_DIGEST_PARAM_ALGID_ABSENT', 'aldid', 'int'], |
| 27 |
)); -} |
| 28 |
/* clang-format on */ |
| 29 |
|
| 30 |
int ossl_digest_default_get_params(OSSL_PARAM params[], size_t blksz, |
| 31 |
size_t paramsz, unsigned long flags) |
| 32 |
{ |
| 33 |
struct digest_default_get_params_st p; |
| 34 |
|
| 35 |
if (!digest_default_get_params_decoder(params, &p)) |
| 36 |
return 0; |
| 37 |
|
| 38 |
if (p.bsize != NULL && !OSSL_PARAM_set_size_t(p.bsize, blksz)) { |
| 39 |
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER); |
| 40 |
return 0; |
| 41 |
} |
| 42 |
if (p.size != NULL && !OSSL_PARAM_set_size_t(p.size, paramsz)) { |
| 43 |
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER); |
| 44 |
return 0; |
| 45 |
} |
| 46 |
if (p.xof != NULL |
| 47 |
&& !OSSL_PARAM_set_int(p.xof, (flags & PROV_DIGEST_FLAG_XOF) != 0)) { |
| 48 |
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER); |
| 49 |
return 0; |
| 50 |
} |
| 51 |
if (p.aldid != NULL |
| 52 |
&& !OSSL_PARAM_set_int(p.aldid, (flags & PROV_DIGEST_FLAG_ALGID_ABSENT) != 0)) { |
| 53 |
ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER); |
| 54 |
return 0; |
| 55 |
} |
| 56 |
return 1; |
| 57 |
} |
| 58 |
|
| 59 |
const OSSL_PARAM *ossl_digest_default_gettable_params(void *provctx) |
| 60 |
{ |
| 61 |
return digest_default_get_params_list; |
| 62 |
} |