1/* 2 * Copyright 2019-2021 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{- 10use OpenSSL::paramnames qw(produce_param_decoder); 11-} 12 13#include <string.h> 14#include <openssl/err.h> 15#include <openssl/proverr.h> 16#include "prov/digestcommon.h" 17#include "internal/common.h" 18 19{- produce_param_decoder('digest_default_get_params', 20 (['DIGEST_PARAM_BLOCK_SIZE', 'bsize', 'size_t'], 21 ['DIGEST_PARAM_SIZE', 'size', 'size_t'], 22 ['DIGEST_PARAM_XOF', 'xof', 'int'], 23 ['DIGEST_PARAM_ALGID_ABSENT', 'aldid', 'int'], 24 )); -} 25 26int ossl_digest_default_get_params(OSSL_PARAM params[], size_t blksz, 27 size_t paramsz, unsigned long flags) 28{ 29 struct digest_default_get_params_st p; 30 31 if (!digest_default_get_params_decoder(params, &p)) 32 return 0; 33 34 if (p.bsize != NULL && !OSSL_PARAM_set_size_t(p.bsize, blksz)) { 35 ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER); 36 return 0; 37 } 38 if (p.size != NULL && !OSSL_PARAM_set_size_t(p.size, paramsz)) { 39 ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER); 40 return 0; 41 } 42 if (p.xof != NULL 43 && !OSSL_PARAM_set_int(p.xof, (flags & PROV_DIGEST_FLAG_XOF) != 0)) { 44 ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER); 45 return 0; 46 } 47 if (p.aldid != NULL 48 && !OSSL_PARAM_set_int(p.aldid, (flags & PROV_DIGEST_FLAG_ALGID_ABSENT) != 0)) { 49 ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER); 50 return 0; 51 } 52 return 1; 53} 54 55const OSSL_PARAM *ossl_digest_default_gettable_params(void *provctx) 56{ 57 return digest_default_get_params_list; 58} 59