Coverage Report

Created: 2026-09-12 06:55

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/openssl41/providers/implementations/ciphers/cipher_chacha20.inc
Line
Count
Source
1
/*
2
 * Copyright 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
11
12
/* Machine generated by util/perl/OpenSSL/paramnames.pm */
13
#include <string.h>
14
#include <openssl/params.h>
15
#include <openssl/e_os2.h>
16
#include "internal/common.h"
17
#include "prov/proverr.h"
18
19
/* Machine generated */
20
#ifndef chacha20_get_ctx_params_list
21
static ossl_unused const OSSL_PARAM chacha20_get_ctx_params_list[] = {
22
    OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL),
23
    OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_IVLEN, NULL),
24
    OSSL_PARAM_octet_string(OSSL_CIPHER_PARAM_UPDATED_IV, NULL, 0),
25
    OSSL_PARAM_END
26
};
27
#endif
28
29
#ifndef chacha20_get_ctx_params_st
30
struct chacha20_get_ctx_params_st {
31
    OSSL_PARAM *ivlen;
32
    OSSL_PARAM *keylen;
33
    OSSL_PARAM *upd_iv;
34
};
35
#endif
36
37
#ifndef chacha20_get_ctx_params_decoder
38
static ossl_unused int chacha20_get_ctx_params_decoder
39
    (const OSSL_PARAM *p, struct chacha20_get_ctx_params_st *r)
40
2.29k
{
41
2.29k
    const char *s;
42
43
2.29k
    memset(r, 0, sizeof(*r));
44
2.29k
    if (p != NULL)
45
4.59k
        for (; (s = p->key) != NULL; p++)
46
2.29k
            switch(s[0]) {
47
0
            default:
48
0
                break;
49
881
            case 'i':
50
881
                if (ossl_likely(strcmp("vlen", s + 1) == 0)) {
51
                    /* OSSL_CIPHER_PARAM_IVLEN */
52
881
                    if (ossl_unlikely(r->ivlen != NULL)) {
53
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
54
0
                                       "param %s is repeated", s);
55
0
                        return 0;
56
0
                    }
57
881
                    r->ivlen = (OSSL_PARAM *)p;
58
881
                }
59
881
                break;
60
1.41k
            case 'k':
61
1.41k
                if (ossl_likely(strcmp("eylen", s + 1) == 0)) {
62
                    /* OSSL_CIPHER_PARAM_KEYLEN */
63
1.41k
                    if (ossl_unlikely(r->keylen != NULL)) {
64
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
65
0
                                       "param %s is repeated", s);
66
0
                        return 0;
67
0
                    }
68
1.41k
                    r->keylen = (OSSL_PARAM *)p;
69
1.41k
                }
70
1.41k
                break;
71
1.41k
            case 'u':
72
0
                if (ossl_likely(strcmp("pdated-iv", s + 1) == 0)) {
73
                    /* OSSL_CIPHER_PARAM_UPDATED_IV */
74
0
                    if (ossl_unlikely(r->upd_iv != NULL)) {
75
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
76
0
                                       "param %s is repeated", s);
77
0
                        return 0;
78
0
                    }
79
0
                    r->upd_iv = (OSSL_PARAM *)p;
80
0
                }
81
2.29k
            }
82
2.29k
    return 1;
83
2.29k
}
84
#endif
85
/* End of machine generated */
86
87
/* Machine generated */
88
#ifndef chacha20_set_ctx_params_list
89
static ossl_unused const OSSL_PARAM chacha20_set_ctx_params_list[] = {
90
    OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_KEYLEN, NULL),
91
    OSSL_PARAM_size_t(OSSL_CIPHER_PARAM_IVLEN, NULL),
92
    OSSL_PARAM_END
93
};
94
#endif
95
96
#ifndef chacha20_set_ctx_params_st
97
struct chacha20_set_ctx_params_st {
98
    OSSL_PARAM *ivlen;
99
    OSSL_PARAM *keylen;
100
};
101
#endif
102
103
#ifndef chacha20_set_ctx_params_decoder
104
static ossl_unused int chacha20_set_ctx_params_decoder
105
    (const OSSL_PARAM *p, struct chacha20_set_ctx_params_st *r)
106
108k
{
107
108k
    const char *s;
108
109
108k
    memset(r, 0, sizeof(*r));
110
108k
    if (p != NULL)
111
24
        for (; (s = p->key) != NULL; p++)
112
16
            switch(s[0]) {
113
0
            default:
114
0
                break;
115
8
            case 'i':
116
8
                if (ossl_likely(strcmp("vlen", s + 1) == 0)) {
117
                    /* OSSL_CIPHER_PARAM_IVLEN */
118
8
                    if (ossl_unlikely(r->ivlen != NULL)) {
119
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
120
0
                                       "param %s is repeated", s);
121
0
                        return 0;
122
0
                    }
123
8
                    r->ivlen = (OSSL_PARAM *)p;
124
8
                }
125
8
                break;
126
8
            case 'k':
127
8
                if (ossl_likely(strcmp("eylen", s + 1) == 0)) {
128
                    /* OSSL_CIPHER_PARAM_KEYLEN */
129
8
                    if (ossl_unlikely(r->keylen != NULL)) {
130
0
                        ERR_raise_data(ERR_LIB_PROV, PROV_R_REPEATED_PARAMETER,
131
0
                                       "param %s is repeated", s);
132
0
                        return 0;
133
0
                    }
134
8
                    r->keylen = (OSSL_PARAM *)p;
135
8
                }
136
16
            }
137
108k
    return 1;
138
108k
}
139
#endif
140
/* End of machine generated */