/src/libressl/crypto/evp/evp_locl.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* $OpenBSD: evp_locl.h,v 1.23 2022/05/05 08:42:27 tb Exp $ */ |
2 | | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | | * project 2000. |
4 | | */ |
5 | | /* ==================================================================== |
6 | | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. |
7 | | * |
8 | | * Redistribution and use in source and binary forms, with or without |
9 | | * modification, are permitted provided that the following conditions |
10 | | * are met: |
11 | | * |
12 | | * 1. Redistributions of source code must retain the above copyright |
13 | | * notice, this list of conditions and the following disclaimer. |
14 | | * |
15 | | * 2. Redistributions in binary form must reproduce the above copyright |
16 | | * notice, this list of conditions and the following disclaimer in |
17 | | * the documentation and/or other materials provided with the |
18 | | * distribution. |
19 | | * |
20 | | * 3. All advertising materials mentioning features or use of this |
21 | | * software must display the following acknowledgment: |
22 | | * "This product includes software developed by the OpenSSL Project |
23 | | * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" |
24 | | * |
25 | | * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to |
26 | | * endorse or promote products derived from this software without |
27 | | * prior written permission. For written permission, please contact |
28 | | * licensing@OpenSSL.org. |
29 | | * |
30 | | * 5. Products derived from this software may not be called "OpenSSL" |
31 | | * nor may "OpenSSL" appear in their names without prior written |
32 | | * permission of the OpenSSL Project. |
33 | | * |
34 | | * 6. Redistributions of any form whatsoever must retain the following |
35 | | * acknowledgment: |
36 | | * "This product includes software developed by the OpenSSL Project |
37 | | * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" |
38 | | * |
39 | | * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY |
40 | | * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
41 | | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
42 | | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR |
43 | | * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
44 | | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
45 | | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
46 | | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
47 | | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
48 | | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
49 | | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
50 | | * OF THE POSSIBILITY OF SUCH DAMAGE. |
51 | | * ==================================================================== |
52 | | * |
53 | | * This product includes cryptographic software written by Eric Young |
54 | | * (eay@cryptsoft.com). This product includes software written by Tim |
55 | | * Hudson (tjh@cryptsoft.com). |
56 | | * |
57 | | */ |
58 | | |
59 | | #ifndef HEADER_EVP_LOCL_H |
60 | | #define HEADER_EVP_LOCL_H |
61 | | |
62 | | __BEGIN_HIDDEN_DECLS |
63 | | |
64 | | /* |
65 | | * Don't free md_ctx->pctx in EVP_MD_CTX_cleanup(). Needed for ownership |
66 | | * handling in EVP_MD_CTX_set_pkey_ctx(). |
67 | | */ |
68 | 34 | #define EVP_MD_CTX_FLAG_KEEP_PKEY_CTX 0x0400 |
69 | | |
70 | | typedef int evp_sign_method(int type, const unsigned char *m, |
71 | | unsigned int m_length, unsigned char *sigret, unsigned int *siglen, |
72 | | void *key); |
73 | | typedef int evp_verify_method(int type, const unsigned char *m, |
74 | | unsigned int m_length, const unsigned char *sigbuf, unsigned int siglen, |
75 | | void *key); |
76 | | |
77 | | /* Type needs to be a bit field |
78 | | * Sub-type needs to be for variations on the method, as in, can it do |
79 | | * arbitrary encryption.... */ |
80 | | struct evp_pkey_st { |
81 | | int type; |
82 | | int save_type; |
83 | | int references; |
84 | | const EVP_PKEY_ASN1_METHOD *ameth; |
85 | | ENGINE *engine; |
86 | | union { |
87 | | char *ptr; |
88 | | #ifndef OPENSSL_NO_RSA |
89 | | struct rsa_st *rsa; /* RSA */ |
90 | | #endif |
91 | | #ifndef OPENSSL_NO_DSA |
92 | | struct dsa_st *dsa; /* DSA */ |
93 | | #endif |
94 | | #ifndef OPENSSL_NO_DH |
95 | | struct dh_st *dh; /* DH */ |
96 | | #endif |
97 | | #ifndef OPENSSL_NO_EC |
98 | | struct ec_key_st *ec; /* ECC */ |
99 | | #endif |
100 | | #ifndef OPENSSL_NO_GOST |
101 | | struct gost_key_st *gost; /* GOST */ |
102 | | #endif |
103 | | } pkey; |
104 | | int save_parameters; |
105 | | STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ |
106 | | } /* EVP_PKEY */; |
107 | | |
108 | | struct env_md_st { |
109 | | int type; |
110 | | int pkey_type; |
111 | | int md_size; |
112 | | unsigned long flags; |
113 | | int (*init)(EVP_MD_CTX *ctx); |
114 | | int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count); |
115 | | int (*final)(EVP_MD_CTX *ctx, unsigned char *md); |
116 | | int (*copy)(EVP_MD_CTX *to, const EVP_MD_CTX *from); |
117 | | int (*cleanup)(EVP_MD_CTX *ctx); |
118 | | |
119 | | int block_size; |
120 | | int ctx_size; /* how big does the ctx->md_data need to be */ |
121 | | /* control function */ |
122 | | int (*md_ctrl)(EVP_MD_CTX *ctx, int cmd, int p1, void *p2); |
123 | | } /* EVP_MD */; |
124 | | |
125 | | struct env_md_ctx_st { |
126 | | const EVP_MD *digest; |
127 | | ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */ |
128 | | unsigned long flags; |
129 | | void *md_data; |
130 | | /* Public key context for sign/verify */ |
131 | | EVP_PKEY_CTX *pctx; |
132 | | /* Update function: usually copied from EVP_MD */ |
133 | | int (*update)(EVP_MD_CTX *ctx, const void *data, size_t count); |
134 | | } /* EVP_MD_CTX */; |
135 | | |
136 | | struct evp_cipher_st { |
137 | | int nid; |
138 | | int block_size; |
139 | | int key_len; /* Default value for variable length ciphers */ |
140 | | int iv_len; |
141 | | unsigned long flags; /* Various flags */ |
142 | | int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key, |
143 | | const unsigned char *iv, int enc); /* init key */ |
144 | | int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out, |
145 | | const unsigned char *in, size_t inl);/* encrypt/decrypt data */ |
146 | | int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */ |
147 | | int ctx_size; /* how big ctx->cipher_data needs to be */ |
148 | | int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */ |
149 | | int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */ |
150 | | int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */ |
151 | | void *app_data; /* Application data */ |
152 | | } /* EVP_CIPHER */; |
153 | | |
154 | | struct evp_cipher_ctx_st { |
155 | | const EVP_CIPHER *cipher; |
156 | | ENGINE *engine; /* functional reference if 'cipher' is ENGINE-provided */ |
157 | | int encrypt; /* encrypt or decrypt */ |
158 | | int buf_len; /* number we have left */ |
159 | | |
160 | | unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ |
161 | | unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ |
162 | | unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */ |
163 | | int num; /* used by cfb/ofb/ctr mode */ |
164 | | |
165 | | void *app_data; /* application stuff */ |
166 | | int key_len; /* May change for variable length cipher */ |
167 | | unsigned long flags; /* Various flags */ |
168 | | void *cipher_data; /* per EVP data */ |
169 | | int final_used; |
170 | | int block_mask; |
171 | | unsigned char final[EVP_MAX_BLOCK_LENGTH];/* possible final block */ |
172 | | } /* EVP_CIPHER_CTX */; |
173 | | |
174 | | struct evp_Encode_Ctx_st { |
175 | | |
176 | | int num; /* number saved in a partial encode/decode */ |
177 | | int length; /* The length is either the output line length |
178 | | * (in input bytes) or the shortest input line |
179 | | * length that is ok. Once decoding begins, |
180 | | * the length is adjusted up each time a longer |
181 | | * line is decoded */ |
182 | | unsigned char enc_data[80]; /* data to encode */ |
183 | | int line_num; /* number read on current line */ |
184 | | int expect_nl; |
185 | | } /* EVP_ENCODE_CTX */; |
186 | | |
187 | | /* Macros to code block cipher wrappers */ |
188 | | |
189 | | /* Wrapper functions for each cipher mode */ |
190 | | |
191 | | #define BLOCK_CIPHER_ecb_loop() \ |
192 | 0 | size_t i, bl; \ |
193 | 0 | bl = ctx->cipher->block_size;\ |
194 | 0 | if(inl < bl) return 1;\ |
195 | 0 | inl -= bl; \ |
196 | 0 | for(i=0; i <= inl; i+=bl) |
197 | | |
198 | | #define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ |
199 | 0 | static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ |
200 | 0 | {\ |
201 | 0 | BLOCK_CIPHER_ecb_loop() \ |
202 | 0 | cprefix##_ecb_encrypt(in + i, out + i, &((kstruct *)ctx->cipher_data)->ksched, ctx->encrypt);\ |
203 | 0 | return 1;\ |
204 | 0 | } Unexecuted instantiation: e_bf.c:bf_ecb_cipher Unexecuted instantiation: e_camellia.c:camellia_128_ecb_cipher Unexecuted instantiation: e_camellia.c:camellia_192_ecb_cipher Unexecuted instantiation: e_camellia.c:camellia_256_ecb_cipher Unexecuted instantiation: e_cast.c:cast5_ecb_cipher Unexecuted instantiation: e_gost2814789.c:gost2814789_ecb_cipher Unexecuted instantiation: e_rc2.c:rc2_ecb_cipher Unexecuted instantiation: e_sm4.c:sm4_ecb_cipher |
205 | | |
206 | 0 | #define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2)) |
207 | | |
208 | | #define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \ |
209 | 0 | static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ |
210 | 0 | {\ |
211 | 0 | while(inl>=EVP_MAXCHUNK)\ |
212 | 0 | {\ |
213 | 0 | cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\ |
214 | 0 | inl-=EVP_MAXCHUNK;\ |
215 | 0 | in +=EVP_MAXCHUNK;\ |
216 | 0 | out+=EVP_MAXCHUNK;\ |
217 | 0 | }\ |
218 | 0 | if (inl)\ |
219 | 0 | cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\ |
220 | 0 | return 1;\ |
221 | 0 | } Unexecuted instantiation: e_bf.c:bf_ofb_cipher Unexecuted instantiation: e_camellia.c:camellia_128_ofb_cipher Unexecuted instantiation: e_camellia.c:camellia_192_ofb_cipher Unexecuted instantiation: e_camellia.c:camellia_256_ofb_cipher Unexecuted instantiation: e_cast.c:cast5_ofb_cipher Unexecuted instantiation: e_idea.c:idea_ofb_cipher Unexecuted instantiation: e_rc2.c:rc2_ofb_cipher Unexecuted instantiation: e_sm4.c:sm4_ofb_cipher |
222 | | |
223 | | #define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ |
224 | 0 | static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ |
225 | 0 | {\ |
226 | 0 | while(inl>=EVP_MAXCHUNK) \ |
227 | 0 | {\ |
228 | 0 | cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\ |
229 | 0 | inl-=EVP_MAXCHUNK;\ |
230 | 0 | in +=EVP_MAXCHUNK;\ |
231 | 0 | out+=EVP_MAXCHUNK;\ |
232 | 0 | }\ |
233 | 0 | if (inl)\ |
234 | 0 | cprefix##_cbc_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\ |
235 | 0 | return 1;\ |
236 | 0 | } Unexecuted instantiation: e_bf.c:bf_cbc_cipher Unexecuted instantiation: e_camellia.c:camellia_128_cbc_cipher Unexecuted instantiation: e_camellia.c:camellia_192_cbc_cipher Unexecuted instantiation: e_camellia.c:camellia_256_cbc_cipher Unexecuted instantiation: e_cast.c:cast5_cbc_cipher Unexecuted instantiation: e_idea.c:idea_cbc_cipher Unexecuted instantiation: e_rc2.c:rc2_cbc_cipher Unexecuted instantiation: e_sm4.c:sm4_cbc_cipher |
237 | | |
238 | | #define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ |
239 | 0 | static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ |
240 | 0 | {\ |
241 | 0 | size_t chunk=EVP_MAXCHUNK;\ |
242 | 0 | if (cbits==1) chunk>>=3;\ |
243 | 0 | if (inl<chunk) chunk=inl;\ |
244 | 0 | while(inl && inl>=chunk)\ |
245 | 0 | {\ |
246 | 0 | cprefix##_cfb##cbits##_encrypt(in, out, (long)((cbits==1) && !(ctx->flags & EVP_CIPH_FLAG_LENGTH_BITS) ?inl*8:inl), &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num, ctx->encrypt);\ |
247 | 0 | inl-=chunk;\ |
248 | 0 | in +=chunk;\ |
249 | 0 | out+=chunk;\ |
250 | 0 | if(inl<chunk) chunk=inl;\ |
251 | 0 | }\ |
252 | 0 | return 1;\ |
253 | 0 | } Unexecuted instantiation: e_bf.c:bf_cfb64_cipher Unexecuted instantiation: e_camellia.c:camellia_128_cfb128_cipher Unexecuted instantiation: e_camellia.c:camellia_192_cfb128_cipher Unexecuted instantiation: e_camellia.c:camellia_256_cfb128_cipher Unexecuted instantiation: e_camellia.c:camellia_128_cfb1_cipher Unexecuted instantiation: e_camellia.c:camellia_192_cfb1_cipher Unexecuted instantiation: e_camellia.c:camellia_256_cfb1_cipher Unexecuted instantiation: e_camellia.c:camellia_128_cfb8_cipher Unexecuted instantiation: e_camellia.c:camellia_192_cfb8_cipher Unexecuted instantiation: e_camellia.c:camellia_256_cfb8_cipher Unexecuted instantiation: e_cast.c:cast5_cfb64_cipher Unexecuted instantiation: e_gost2814789.c:gost2814789_cfb64_cipher Unexecuted instantiation: e_idea.c:idea_cfb64_cipher Unexecuted instantiation: e_rc2.c:rc2_cfb64_cipher Unexecuted instantiation: e_sm4.c:sm4_cfb128_cipher |
254 | | |
255 | | #define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ |
256 | | BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ |
257 | | BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ |
258 | | BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ |
259 | | BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) |
260 | | |
261 | | #define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \ |
262 | | key_len, iv_len, flags, init_key, cleanup, \ |
263 | | set_asn1, get_asn1, ctrl) \ |
264 | | static const EVP_CIPHER cname##_##mode = { \ |
265 | | nid##_##nmode, block_size, key_len, iv_len, \ |
266 | | flags | EVP_CIPH_##MODE##_MODE, \ |
267 | | init_key, \ |
268 | | cname##_##mode##_cipher, \ |
269 | | cleanup, \ |
270 | | sizeof(kstruct), \ |
271 | | set_asn1, get_asn1,\ |
272 | | ctrl, \ |
273 | | NULL \ |
274 | | }; \ |
275 | 124 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 4 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 4 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 4 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Unexecuted instantiation: EVP_des_ede_ecb Line | Count | Source | 275 | 4 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Unexecuted instantiation: EVP_des_ede3_ecb Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 4 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 4 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 4 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 275 | 2 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
|
276 | | |
277 | | #define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \ |
278 | | iv_len, flags, init_key, cleanup, set_asn1, \ |
279 | | get_asn1, ctrl) \ |
280 | | BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \ |
281 | | iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl) |
282 | | |
283 | | #define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \ |
284 | | iv_len, cbits, flags, init_key, cleanup, \ |
285 | | set_asn1, get_asn1, ctrl) \ |
286 | | BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \ |
287 | | key_len, iv_len, flags, init_key, cleanup, set_asn1, \ |
288 | | get_asn1, ctrl) |
289 | | |
290 | | #define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \ |
291 | | iv_len, cbits, flags, init_key, cleanup, \ |
292 | | set_asn1, get_asn1, ctrl) \ |
293 | | BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \ |
294 | | key_len, iv_len, flags, init_key, cleanup, set_asn1, \ |
295 | | get_asn1, ctrl) |
296 | | |
297 | | #define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \ |
298 | | flags, init_key, cleanup, set_asn1, \ |
299 | | get_asn1, ctrl) \ |
300 | | BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \ |
301 | | 0, flags, init_key, cleanup, set_asn1, get_asn1, ctrl) |
302 | | |
303 | | #define BLOCK_CIPHER_defs(cname, kstruct, \ |
304 | | nid, block_size, key_len, iv_len, cbits, flags, \ |
305 | | init_key, cleanup, set_asn1, get_asn1, ctrl) \ |
306 | | BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \ |
307 | | init_key, cleanup, set_asn1, get_asn1, ctrl) \ |
308 | | BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \ |
309 | | flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ |
310 | | BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \ |
311 | | flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ |
312 | | BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, \ |
313 | | init_key, cleanup, set_asn1, get_asn1, ctrl) |
314 | | |
315 | | |
316 | | /* |
317 | | #define BLOCK_CIPHER_defs(cname, kstruct, \ |
318 | | nid, block_size, key_len, iv_len, flags,\ |
319 | | init_key, cleanup, set_asn1, get_asn1, ctrl)\ |
320 | | static const EVP_CIPHER cname##_cbc = {\ |
321 | | nid##_cbc, block_size, key_len, iv_len, \ |
322 | | flags | EVP_CIPH_CBC_MODE,\ |
323 | | init_key,\ |
324 | | cname##_cbc_cipher,\ |
325 | | cleanup,\ |
326 | | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ |
327 | | sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ |
328 | | set_asn1, get_asn1,\ |
329 | | ctrl, \ |
330 | | NULL \ |
331 | | };\ |
332 | | const EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\ |
333 | | static const EVP_CIPHER cname##_cfb = {\ |
334 | | nid##_cfb64, 1, key_len, iv_len, \ |
335 | | flags | EVP_CIPH_CFB_MODE,\ |
336 | | init_key,\ |
337 | | cname##_cfb_cipher,\ |
338 | | cleanup,\ |
339 | | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ |
340 | | sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ |
341 | | set_asn1, get_asn1,\ |
342 | | ctrl,\ |
343 | | NULL \ |
344 | | };\ |
345 | | const EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\ |
346 | | static const EVP_CIPHER cname##_ofb = {\ |
347 | | nid##_ofb64, 1, key_len, iv_len, \ |
348 | | flags | EVP_CIPH_OFB_MODE,\ |
349 | | init_key,\ |
350 | | cname##_ofb_cipher,\ |
351 | | cleanup,\ |
352 | | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ |
353 | | sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ |
354 | | set_asn1, get_asn1,\ |
355 | | ctrl,\ |
356 | | NULL \ |
357 | | };\ |
358 | | const EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\ |
359 | | static const EVP_CIPHER cname##_ecb = {\ |
360 | | nid##_ecb, block_size, key_len, iv_len, \ |
361 | | flags | EVP_CIPH_ECB_MODE,\ |
362 | | init_key,\ |
363 | | cname##_ecb_cipher,\ |
364 | | cleanup,\ |
365 | | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ |
366 | | sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ |
367 | | set_asn1, get_asn1,\ |
368 | | ctrl,\ |
369 | | NULL \ |
370 | | };\ |
371 | | const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; } |
372 | | */ |
373 | | |
374 | | #define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \ |
375 | | block_size, key_len, iv_len, cbits, \ |
376 | | flags, init_key, \ |
377 | | cleanup, set_asn1, get_asn1, ctrl) \ |
378 | | BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ |
379 | | BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \ |
380 | | cbits, flags, init_key, cleanup, set_asn1, \ |
381 | | get_asn1, ctrl) |
382 | | |
383 | 0 | #define EVP_C_DATA(kstruct, ctx) ((kstruct *)(ctx)->cipher_data) |
384 | | |
385 | | #define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len) \ |
386 | | BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \ |
387 | | BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \ |
388 | | NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \ |
389 | | 0, cipher##_init_key, NULL, \ |
390 | | EVP_CIPHER_set_asn1_iv, \ |
391 | | EVP_CIPHER_get_asn1_iv, \ |
392 | | NULL) |
393 | | |
394 | | struct evp_pkey_ctx_st { |
395 | | /* Method associated with this operation */ |
396 | | const EVP_PKEY_METHOD *pmeth; |
397 | | /* Engine that implements this method or NULL if builtin */ |
398 | | ENGINE *engine; |
399 | | /* Key: may be NULL */ |
400 | | EVP_PKEY *pkey; |
401 | | /* Peer key for key agreement, may be NULL */ |
402 | | EVP_PKEY *peerkey; |
403 | | /* Actual operation */ |
404 | | int operation; |
405 | | /* Algorithm specific data */ |
406 | | void *data; |
407 | | /* Application specific data */ |
408 | | void *app_data; |
409 | | /* Keygen callback */ |
410 | | EVP_PKEY_gen_cb *pkey_gencb; |
411 | | /* implementation specific keygen data */ |
412 | | int *keygen_info; |
413 | | int keygen_info_count; |
414 | | } /* EVP_PKEY_CTX */; |
415 | | |
416 | 0 | #define EVP_PKEY_FLAG_DYNAMIC 1 |
417 | | |
418 | | struct evp_pkey_method_st { |
419 | | int pkey_id; |
420 | | int flags; |
421 | | |
422 | | int (*init)(EVP_PKEY_CTX *ctx); |
423 | | int (*copy)(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src); |
424 | | void (*cleanup)(EVP_PKEY_CTX *ctx); |
425 | | |
426 | | int (*paramgen_init)(EVP_PKEY_CTX *ctx); |
427 | | int (*paramgen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); |
428 | | |
429 | | int (*keygen_init)(EVP_PKEY_CTX *ctx); |
430 | | int (*keygen)(EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); |
431 | | |
432 | | int (*sign_init)(EVP_PKEY_CTX *ctx); |
433 | | int (*sign)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, |
434 | | const unsigned char *tbs, size_t tbslen); |
435 | | |
436 | | int (*verify_init)(EVP_PKEY_CTX *ctx); |
437 | | int (*verify)(EVP_PKEY_CTX *ctx, |
438 | | const unsigned char *sig, size_t siglen, |
439 | | const unsigned char *tbs, size_t tbslen); |
440 | | |
441 | | int (*verify_recover_init)(EVP_PKEY_CTX *ctx); |
442 | | int (*verify_recover)(EVP_PKEY_CTX *ctx, |
443 | | unsigned char *rout, size_t *routlen, |
444 | | const unsigned char *sig, size_t siglen); |
445 | | |
446 | | int (*signctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); |
447 | | int (*signctx)(EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, |
448 | | EVP_MD_CTX *mctx); |
449 | | |
450 | | int (*verifyctx_init)(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); |
451 | | int (*verifyctx)(EVP_PKEY_CTX *ctx, const unsigned char *sig, |
452 | | int siglen, EVP_MD_CTX *mctx); |
453 | | |
454 | | int (*encrypt_init)(EVP_PKEY_CTX *ctx); |
455 | | int (*encrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, |
456 | | const unsigned char *in, size_t inlen); |
457 | | |
458 | | int (*decrypt_init)(EVP_PKEY_CTX *ctx); |
459 | | int (*decrypt)(EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, |
460 | | const unsigned char *in, size_t inlen); |
461 | | |
462 | | int (*derive_init)(EVP_PKEY_CTX *ctx); |
463 | | int (*derive)(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); |
464 | | |
465 | | int (*ctrl)(EVP_PKEY_CTX *ctx, int type, int p1, void *p2); |
466 | | int (*ctrl_str)(EVP_PKEY_CTX *ctx, const char *type, const char *value); |
467 | | |
468 | | int (*check)(EVP_PKEY *pkey); |
469 | | int (*public_check)(EVP_PKEY *pkey); |
470 | | int (*param_check)(EVP_PKEY *pkey); |
471 | | } /* EVP_PKEY_METHOD */; |
472 | | |
473 | | void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx); |
474 | | |
475 | | int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, |
476 | | ASN1_TYPE *param, const EVP_CIPHER *c, const EVP_MD *md, int en_de); |
477 | | |
478 | | /* EVP_AEAD represents a specific AEAD algorithm. */ |
479 | | struct evp_aead_st { |
480 | | unsigned char key_len; |
481 | | unsigned char nonce_len; |
482 | | unsigned char overhead; |
483 | | unsigned char max_tag_len; |
484 | | |
485 | | int (*init)(struct evp_aead_ctx_st*, const unsigned char *key, |
486 | | size_t key_len, size_t tag_len); |
487 | | void (*cleanup)(struct evp_aead_ctx_st*); |
488 | | |
489 | | int (*seal)(const struct evp_aead_ctx_st *ctx, unsigned char *out, |
490 | | size_t *out_len, size_t max_out_len, const unsigned char *nonce, |
491 | | size_t nonce_len, const unsigned char *in, size_t in_len, |
492 | | const unsigned char *ad, size_t ad_len); |
493 | | |
494 | | int (*open)(const struct evp_aead_ctx_st *ctx, unsigned char *out, |
495 | | size_t *out_len, size_t max_out_len, const unsigned char *nonce, |
496 | | size_t nonce_len, const unsigned char *in, size_t in_len, |
497 | | const unsigned char *ad, size_t ad_len); |
498 | | }; |
499 | | |
500 | | /* An EVP_AEAD_CTX represents an AEAD algorithm configured with a specific key |
501 | | * and message-independent IV. */ |
502 | | struct evp_aead_ctx_st { |
503 | | const EVP_AEAD *aead; |
504 | | /* aead_state is an opaque pointer to the AEAD specific state. */ |
505 | | void *aead_state; |
506 | | }; |
507 | | |
508 | | int EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str); |
509 | | int EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *hex); |
510 | | int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md_name); |
511 | | |
512 | | __END_HIDDEN_DECLS |
513 | | |
514 | | #endif /* !HEADER_EVP_LOCL_H */ |