Coverage Report

Created: 2026-05-20 07:05

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