/src/openssl/providers/implementations/digests/digestcommon.c
Line  | Count  | Source  | 
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  |  |  | 
10  |  | #include <string.h>  | 
11  |  | #include <openssl/err.h>  | 
12  |  | #include <openssl/proverr.h>  | 
13  |  | #include "prov/digestcommon.h"  | 
14  |  | #include "internal/common.h"  | 
15  |  |  | 
16  |  | #include "providers/implementations/digests/digestcommon.inc"  | 
17  |  |  | 
18  |  | int ossl_digest_default_get_params(OSSL_PARAM params[], size_t blksz,  | 
19  |  |                                    size_t paramsz, unsigned long flags)  | 
20  | 432  | { | 
21  | 432  |     struct digest_default_get_params_st p;  | 
22  |  |  | 
23  | 432  |     if (!digest_default_get_params_decoder(params, &p))  | 
24  | 0  |         return 0;  | 
25  |  |  | 
26  | 432  |     if (p.bsize != NULL && !OSSL_PARAM_set_size_t(p.bsize, blksz)) { | 
27  | 0  |         ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);  | 
28  | 0  |         return 0;  | 
29  | 0  |     }  | 
30  | 432  |     if (p.size != NULL && !OSSL_PARAM_set_size_t(p.size, paramsz)) { | 
31  | 0  |         ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);  | 
32  | 0  |         return 0;  | 
33  | 0  |     }  | 
34  | 432  |     if (p.xof != NULL  | 
35  | 432  |         && !OSSL_PARAM_set_int(p.xof, (flags & PROV_DIGEST_FLAG_XOF) != 0)) { | 
36  | 0  |         ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);  | 
37  | 0  |         return 0;  | 
38  | 0  |     }  | 
39  | 432  |     if (p.aldid != NULL  | 
40  | 432  |         && !OSSL_PARAM_set_int(p.aldid, (flags & PROV_DIGEST_FLAG_ALGID_ABSENT) != 0)) { | 
41  | 0  |         ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);  | 
42  | 0  |         return 0;  | 
43  | 0  |     }  | 
44  | 432  |     return 1;  | 
45  | 432  | }  | 
46  |  |  | 
47  |  | const OSSL_PARAM *ossl_digest_default_gettable_params(void *provctx)  | 
48  | 0  | { | 
49  | 0  |     return digest_default_get_params_list;  | 
50  | 0  | }  |