Coverage Report

Created: 2025-06-13 06:55

/src/openssl/providers/implementations/digests/digestcommon.c
Line
Count
Source (jump to first uncovered line)
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
10
#include <openssl/err.h>
11
#include <openssl/proverr.h>
12
#include "prov/digestcommon.h"
13
14
int ossl_digest_default_get_params(OSSL_PARAM params[], size_t blksz,
15
                                   size_t paramsz, unsigned long flags)
16
27
{
17
27
    OSSL_PARAM *p = NULL;
18
19
27
    p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_BLOCK_SIZE);
20
27
    if (p != NULL && !OSSL_PARAM_set_size_t(p, blksz)) {
21
0
        ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
22
0
        return 0;
23
0
    }
24
27
    p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_SIZE);
25
27
    if (p != NULL && !OSSL_PARAM_set_size_t(p, paramsz)) {
26
0
        ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
27
0
        return 0;
28
0
    }
29
27
    p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_XOF);
30
27
    if (p != NULL
31
27
        && !OSSL_PARAM_set_int(p, (flags & PROV_DIGEST_FLAG_XOF) != 0)) {
32
0
        ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
33
0
        return 0;
34
0
    }
35
27
    p = OSSL_PARAM_locate(params, OSSL_DIGEST_PARAM_ALGID_ABSENT);
36
27
    if (p != NULL
37
27
        && !OSSL_PARAM_set_int(p, (flags & PROV_DIGEST_FLAG_ALGID_ABSENT) != 0)) {
38
0
        ERR_raise(ERR_LIB_PROV, PROV_R_FAILED_TO_SET_PARAMETER);
39
0
        return 0;
40
0
    }
41
27
    return 1;
42
27
}
43
44
static const OSSL_PARAM digest_default_known_gettable_params[] = {
45
    OSSL_PARAM_size_t(OSSL_DIGEST_PARAM_BLOCK_SIZE, NULL),
46
    OSSL_PARAM_size_t(OSSL_DIGEST_PARAM_SIZE, NULL),
47
    OSSL_PARAM_int(OSSL_DIGEST_PARAM_XOF, NULL),
48
    OSSL_PARAM_int(OSSL_DIGEST_PARAM_ALGID_ABSENT, NULL),
49
    OSSL_PARAM_END
50
};
51
const OSSL_PARAM *ossl_digest_default_gettable_params(void *provctx)
52
0
{
53
0
    return digest_default_known_gettable_params;
54
0
}