/src/openssl/crypto/include/internal/evp_int.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2015-2018 The OpenSSL Project Authors. All Rights Reserved. |
3 | | * |
4 | | * Licensed under the OpenSSL license (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/evp.h> |
11 | | #include "internal/refcount.h" |
12 | | |
13 | | struct evp_pkey_ctx_st { |
14 | | /* Method associated with this operation */ |
15 | | const EVP_PKEY_METHOD *pmeth; |
16 | | /* Engine that implements this method or NULL if builtin */ |
17 | | ENGINE *engine; |
18 | | /* Key: may be NULL */ |
19 | | EVP_PKEY *pkey; |
20 | | /* Peer key for key agreement, may be NULL */ |
21 | | EVP_PKEY *peerkey; |
22 | | /* Actual operation */ |
23 | | int operation; |
24 | | /* Algorithm specific data */ |
25 | | void *data; |
26 | | /* Application specific data */ |
27 | | void *app_data; |
28 | | /* Keygen callback */ |
29 | | EVP_PKEY_gen_cb *pkey_gencb; |
30 | | /* implementation specific keygen data */ |
31 | | int *keygen_info; |
32 | | int keygen_info_count; |
33 | | } /* EVP_PKEY_CTX */ ; |
34 | | |
35 | 0 | #define EVP_PKEY_FLAG_DYNAMIC 1 |
36 | | |
37 | | struct evp_pkey_method_st { |
38 | | int pkey_id; |
39 | | int flags; |
40 | | int (*init) (EVP_PKEY_CTX *ctx); |
41 | | int (*copy) (EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src); |
42 | | void (*cleanup) (EVP_PKEY_CTX *ctx); |
43 | | int (*paramgen_init) (EVP_PKEY_CTX *ctx); |
44 | | int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); |
45 | | int (*keygen_init) (EVP_PKEY_CTX *ctx); |
46 | | int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey); |
47 | | int (*sign_init) (EVP_PKEY_CTX *ctx); |
48 | | int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, |
49 | | const unsigned char *tbs, size_t tbslen); |
50 | | int (*verify_init) (EVP_PKEY_CTX *ctx); |
51 | | int (*verify) (EVP_PKEY_CTX *ctx, |
52 | | const unsigned char *sig, size_t siglen, |
53 | | const unsigned char *tbs, size_t tbslen); |
54 | | int (*verify_recover_init) (EVP_PKEY_CTX *ctx); |
55 | | int (*verify_recover) (EVP_PKEY_CTX *ctx, |
56 | | unsigned char *rout, size_t *routlen, |
57 | | const unsigned char *sig, size_t siglen); |
58 | | int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); |
59 | | int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen, |
60 | | EVP_MD_CTX *mctx); |
61 | | int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx); |
62 | | int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen, |
63 | | EVP_MD_CTX *mctx); |
64 | | int (*encrypt_init) (EVP_PKEY_CTX *ctx); |
65 | | int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, |
66 | | const unsigned char *in, size_t inlen); |
67 | | int (*decrypt_init) (EVP_PKEY_CTX *ctx); |
68 | | int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen, |
69 | | const unsigned char *in, size_t inlen); |
70 | | int (*derive_init) (EVP_PKEY_CTX *ctx); |
71 | | int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); |
72 | | int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2); |
73 | | int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value); |
74 | | int (*digestsign) (EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen, |
75 | | const unsigned char *tbs, size_t tbslen); |
76 | | int (*digestverify) (EVP_MD_CTX *ctx, const unsigned char *sig, |
77 | | size_t siglen, const unsigned char *tbs, |
78 | | size_t tbslen); |
79 | | int (*check) (EVP_PKEY *pkey); |
80 | | int (*public_check) (EVP_PKEY *pkey); |
81 | | int (*param_check) (EVP_PKEY *pkey); |
82 | | } /* EVP_PKEY_METHOD */ ; |
83 | | |
84 | | DEFINE_STACK_OF_CONST(EVP_PKEY_METHOD) |
85 | | |
86 | | void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx); |
87 | | |
88 | | extern const EVP_PKEY_METHOD cmac_pkey_meth; |
89 | | extern const EVP_PKEY_METHOD dh_pkey_meth; |
90 | | extern const EVP_PKEY_METHOD dhx_pkey_meth; |
91 | | extern const EVP_PKEY_METHOD dsa_pkey_meth; |
92 | | extern const EVP_PKEY_METHOD ec_pkey_meth; |
93 | | extern const EVP_PKEY_METHOD sm2_pkey_meth; |
94 | | extern const EVP_PKEY_METHOD ecx25519_pkey_meth; |
95 | | extern const EVP_PKEY_METHOD ecx448_pkey_meth; |
96 | | extern const EVP_PKEY_METHOD ed25519_pkey_meth; |
97 | | extern const EVP_PKEY_METHOD ed448_pkey_meth; |
98 | | extern const EVP_PKEY_METHOD hmac_pkey_meth; |
99 | | extern const EVP_PKEY_METHOD rsa_pkey_meth; |
100 | | extern const EVP_PKEY_METHOD rsa_pss_pkey_meth; |
101 | | extern const EVP_PKEY_METHOD scrypt_pkey_meth; |
102 | | extern const EVP_PKEY_METHOD tls1_prf_pkey_meth; |
103 | | extern const EVP_PKEY_METHOD hkdf_pkey_meth; |
104 | | extern const EVP_PKEY_METHOD poly1305_pkey_meth; |
105 | | extern const EVP_PKEY_METHOD siphash_pkey_meth; |
106 | | |
107 | | struct evp_md_st { |
108 | | int type; |
109 | | int pkey_type; |
110 | | int md_size; |
111 | | unsigned long flags; |
112 | | int (*init) (EVP_MD_CTX *ctx); |
113 | | int (*update) (EVP_MD_CTX *ctx, const void *data, size_t count); |
114 | | int (*final) (EVP_MD_CTX *ctx, unsigned char *md); |
115 | | int (*copy) (EVP_MD_CTX *to, const EVP_MD_CTX *from); |
116 | | int (*cleanup) (EVP_MD_CTX *ctx); |
117 | | int block_size; |
118 | | int ctx_size; /* how big does the ctx->md_data need to be */ |
119 | | /* control function */ |
120 | | int (*md_ctrl) (EVP_MD_CTX *ctx, int cmd, int p1, void *p2); |
121 | | } /* EVP_MD */ ; |
122 | | |
123 | | struct evp_cipher_st { |
124 | | int nid; |
125 | | int block_size; |
126 | | /* Default value for variable length ciphers */ |
127 | | int key_len; |
128 | | int iv_len; |
129 | | /* Various flags */ |
130 | | unsigned long flags; |
131 | | /* init key */ |
132 | | int (*init) (EVP_CIPHER_CTX *ctx, const unsigned char *key, |
133 | | const unsigned char *iv, int enc); |
134 | | /* encrypt/decrypt data */ |
135 | | int (*do_cipher) (EVP_CIPHER_CTX *ctx, unsigned char *out, |
136 | | const unsigned char *in, size_t inl); |
137 | | /* cleanup ctx */ |
138 | | int (*cleanup) (EVP_CIPHER_CTX *); |
139 | | /* how big ctx->cipher_data needs to be */ |
140 | | int ctx_size; |
141 | | /* Populate a ASN1_TYPE with parameters */ |
142 | | int (*set_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *); |
143 | | /* Get parameters from a ASN1_TYPE */ |
144 | | int (*get_asn1_parameters) (EVP_CIPHER_CTX *, ASN1_TYPE *); |
145 | | /* Miscellaneous operations */ |
146 | | int (*ctrl) (EVP_CIPHER_CTX *, int type, int arg, void *ptr); |
147 | | /* Application data */ |
148 | | void *app_data; |
149 | | } /* EVP_CIPHER */ ; |
150 | | |
151 | | /* Macros to code block cipher wrappers */ |
152 | | |
153 | | /* Wrapper functions for each cipher mode */ |
154 | | |
155 | | #define EVP_C_DATA(kstruct, ctx) \ |
156 | 0 | ((kstruct *)EVP_CIPHER_CTX_get_cipher_data(ctx)) |
157 | | |
158 | | #define BLOCK_CIPHER_ecb_loop() \ |
159 | 0 | size_t i, bl; \ |
160 | 0 | bl = EVP_CIPHER_CTX_cipher(ctx)->block_size; \ |
161 | 0 | if (inl < bl) return 1;\ |
162 | 0 | inl -= bl; \ |
163 | 0 | for (i=0; i <= inl; i+=bl) |
164 | | |
165 | | #define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ |
166 | 0 | static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ |
167 | 0 | {\ |
168 | 0 | BLOCK_CIPHER_ecb_loop() \ |
169 | 0 | cprefix##_ecb_encrypt(in + i, out + i, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_encrypting(ctx)); \ |
170 | 0 | return 1;\ |
171 | 0 | } Unexecuted instantiation: e_aria.c:aria_128_ecb_cipher Unexecuted instantiation: e_aria.c:aria_192_ecb_cipher Unexecuted instantiation: e_aria.c:aria_256_ecb_cipher Unexecuted instantiation: e_rc2.c:rc2_ecb_cipher Unexecuted instantiation: e_seed.c:seed_ecb_cipher Unexecuted instantiation: e_bf.c:bf_ecb_cipher Unexecuted instantiation: e_cast.c:cast5_ecb_cipher Unexecuted instantiation: e_rc5.c:rc5_32_12_16_ecb_cipher Unexecuted instantiation: e_sm4.c:sm4_ecb_cipher |
172 | | |
173 | 0 | #define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2)) |
174 | | |
175 | | #define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \ |
176 | 0 | static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ |
177 | 0 | {\ |
178 | 0 | while(inl>=EVP_MAXCHUNK) {\ |
179 | 0 | int num = EVP_CIPHER_CTX_num(ctx);\ |
180 | 0 | cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \ |
181 | 0 | EVP_CIPHER_CTX_set_num(ctx, num);\ |
182 | 0 | inl-=EVP_MAXCHUNK;\ |
183 | 0 | in +=EVP_MAXCHUNK;\ |
184 | 0 | out+=EVP_MAXCHUNK;\ |
185 | 0 | }\ |
186 | 0 | if (inl) {\ |
187 | 0 | int num = EVP_CIPHER_CTX_num(ctx);\ |
188 | 0 | cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \ |
189 | 0 | EVP_CIPHER_CTX_set_num(ctx, num);\ |
190 | 0 | }\ |
191 | 0 | return 1;\ |
192 | 0 | } Unexecuted instantiation: e_aria.c:aria_128_ofb_cipher Unexecuted instantiation: e_aria.c:aria_192_ofb_cipher Unexecuted instantiation: e_aria.c:aria_256_ofb_cipher Unexecuted instantiation: e_idea.c:idea_ofb_cipher Unexecuted instantiation: e_rc2.c:rc2_ofb_cipher Unexecuted instantiation: e_seed.c:seed_ofb_cipher Unexecuted instantiation: e_bf.c:bf_ofb_cipher Unexecuted instantiation: e_cast.c:cast5_ofb_cipher Unexecuted instantiation: e_rc5.c:rc5_32_12_16_ofb_cipher Unexecuted instantiation: e_sm4.c:sm4_ofb_cipher |
193 | | |
194 | | #define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ |
195 | 0 | static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ |
196 | 0 | {\ |
197 | 0 | while(inl>=EVP_MAXCHUNK) \ |
198 | 0 | {\ |
199 | 0 | cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\ |
200 | 0 | inl-=EVP_MAXCHUNK;\ |
201 | 0 | in +=EVP_MAXCHUNK;\ |
202 | 0 | out+=EVP_MAXCHUNK;\ |
203 | 0 | }\ |
204 | 0 | if (inl)\ |
205 | 0 | cprefix##_cbc_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\ |
206 | 0 | return 1;\ |
207 | 0 | } Unexecuted instantiation: e_aria.c:aria_128_cbc_cipher Unexecuted instantiation: e_aria.c:aria_192_cbc_cipher Unexecuted instantiation: e_aria.c:aria_256_cbc_cipher Unexecuted instantiation: e_idea.c:idea_cbc_cipher Unexecuted instantiation: e_rc2.c:rc2_cbc_cipher Unexecuted instantiation: e_seed.c:seed_cbc_cipher Unexecuted instantiation: e_bf.c:bf_cbc_cipher Unexecuted instantiation: e_cast.c:cast5_cbc_cipher Unexecuted instantiation: e_rc5.c:rc5_32_12_16_cbc_cipher Unexecuted instantiation: e_sm4.c:sm4_cbc_cipher |
208 | | |
209 | | #define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ |
210 | 0 | static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \ |
211 | 0 | {\ |
212 | 0 | size_t chunk = EVP_MAXCHUNK;\ |
213 | 0 | if (cbits == 1) chunk >>= 3;\ |
214 | 0 | if (inl < chunk) chunk = inl;\ |
215 | 0 | while (inl && inl >= chunk)\ |
216 | 0 | {\ |
217 | 0 | int num = EVP_CIPHER_CTX_num(ctx);\ |
218 | 0 | cprefix##_cfb##cbits##_encrypt(in, out, (long) \ |
219 | 0 | ((cbits == 1) \ |
220 | 0 | && !EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS) \ |
221 | 0 | ? chunk*8 : chunk), \ |
222 | 0 | &EVP_C_DATA(kstruct, ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx),\ |
223 | 0 | &num, EVP_CIPHER_CTX_encrypting(ctx));\ |
224 | 0 | EVP_CIPHER_CTX_set_num(ctx, num);\ |
225 | 0 | inl -= chunk;\ |
226 | 0 | in += chunk;\ |
227 | 0 | out += chunk;\ |
228 | 0 | if (inl < chunk) chunk = inl;\ |
229 | 0 | }\ |
230 | 0 | return 1;\ |
231 | 0 | } Unexecuted instantiation: e_aria.c:aria_128_cfb128_cipher Unexecuted instantiation: e_aria.c:aria_192_cfb128_cipher Unexecuted instantiation: e_aria.c:aria_256_cfb128_cipher Unexecuted instantiation: e_aria.c:aria_128_cfb1_cipher Unexecuted instantiation: e_aria.c:aria_192_cfb1_cipher Unexecuted instantiation: e_aria.c:aria_256_cfb1_cipher Unexecuted instantiation: e_aria.c:aria_128_cfb8_cipher Unexecuted instantiation: e_aria.c:aria_192_cfb8_cipher Unexecuted instantiation: e_aria.c:aria_256_cfb8_cipher Unexecuted instantiation: e_idea.c:idea_cfb64_cipher Unexecuted instantiation: e_rc2.c:rc2_cfb64_cipher Unexecuted instantiation: e_seed.c:seed_cfb128_cipher Unexecuted instantiation: e_bf.c:bf_cfb64_cipher Unexecuted instantiation: e_cast.c:cast5_cfb64_cipher Unexecuted instantiation: e_rc5.c:rc5_32_12_16_cfb64_cipher Unexecuted instantiation: e_sm4.c:sm4_cfb128_cipher |
232 | | |
233 | | #define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ |
234 | | BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \ |
235 | | BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \ |
236 | | BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \ |
237 | | BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) |
238 | | |
239 | | #define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \ |
240 | | key_len, iv_len, flags, init_key, cleanup, \ |
241 | | set_asn1, get_asn1, ctrl) \ |
242 | | static const EVP_CIPHER cname##_##mode = { \ |
243 | | nid##_##nmode, block_size, key_len, iv_len, \ |
244 | | flags | EVP_CIPH_##MODE##_MODE, \ |
245 | | init_key, \ |
246 | | cname##_##mode##_cipher, \ |
247 | | cleanup, \ |
248 | | sizeof(kstruct), \ |
249 | | set_asn1, get_asn1,\ |
250 | | ctrl, \ |
251 | | NULL \ |
252 | | }; \ |
253 | 480 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Unexecuted instantiation: EVP_des_ede_ecb Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Unexecuted instantiation: EVP_des_ede3_ecb Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
Line | Count | Source | 253 | 8 | const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; } |
|
254 | | |
255 | | #define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \ |
256 | | iv_len, flags, init_key, cleanup, set_asn1, \ |
257 | | get_asn1, ctrl) \ |
258 | | BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \ |
259 | | iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl) |
260 | | |
261 | | #define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \ |
262 | | iv_len, cbits, flags, init_key, cleanup, \ |
263 | | set_asn1, get_asn1, ctrl) \ |
264 | | BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \ |
265 | | key_len, iv_len, flags, init_key, cleanup, set_asn1, \ |
266 | | get_asn1, ctrl) |
267 | | |
268 | | #define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \ |
269 | | iv_len, cbits, flags, init_key, cleanup, \ |
270 | | set_asn1, get_asn1, ctrl) \ |
271 | | BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \ |
272 | | key_len, iv_len, flags, init_key, cleanup, set_asn1, \ |
273 | | get_asn1, ctrl) |
274 | | |
275 | | #define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \ |
276 | | flags, init_key, cleanup, set_asn1, \ |
277 | | get_asn1, ctrl) \ |
278 | | BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \ |
279 | | 0, flags, init_key, cleanup, set_asn1, get_asn1, ctrl) |
280 | | |
281 | | #define BLOCK_CIPHER_defs(cname, kstruct, \ |
282 | | nid, block_size, key_len, iv_len, cbits, flags, \ |
283 | | init_key, cleanup, set_asn1, get_asn1, ctrl) \ |
284 | | BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \ |
285 | | init_key, cleanup, set_asn1, get_asn1, ctrl) \ |
286 | | BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \ |
287 | | flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ |
288 | | BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \ |
289 | | flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \ |
290 | | BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, \ |
291 | | init_key, cleanup, set_asn1, get_asn1, ctrl) |
292 | | |
293 | | /*- |
294 | | #define BLOCK_CIPHER_defs(cname, kstruct, \ |
295 | | nid, block_size, key_len, iv_len, flags,\ |
296 | | init_key, cleanup, set_asn1, get_asn1, ctrl)\ |
297 | | static const EVP_CIPHER cname##_cbc = {\ |
298 | | nid##_cbc, block_size, key_len, iv_len, \ |
299 | | flags | EVP_CIPH_CBC_MODE,\ |
300 | | init_key,\ |
301 | | cname##_cbc_cipher,\ |
302 | | cleanup,\ |
303 | | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ |
304 | | sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ |
305 | | set_asn1, get_asn1,\ |
306 | | ctrl, \ |
307 | | NULL \ |
308 | | };\ |
309 | | const EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\ |
310 | | static const EVP_CIPHER cname##_cfb = {\ |
311 | | nid##_cfb64, 1, key_len, iv_len, \ |
312 | | flags | EVP_CIPH_CFB_MODE,\ |
313 | | init_key,\ |
314 | | cname##_cfb_cipher,\ |
315 | | cleanup,\ |
316 | | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ |
317 | | sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ |
318 | | set_asn1, get_asn1,\ |
319 | | ctrl,\ |
320 | | NULL \ |
321 | | };\ |
322 | | const EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\ |
323 | | static const EVP_CIPHER cname##_ofb = {\ |
324 | | nid##_ofb64, 1, key_len, iv_len, \ |
325 | | flags | EVP_CIPH_OFB_MODE,\ |
326 | | init_key,\ |
327 | | cname##_ofb_cipher,\ |
328 | | cleanup,\ |
329 | | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ |
330 | | sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ |
331 | | set_asn1, get_asn1,\ |
332 | | ctrl,\ |
333 | | NULL \ |
334 | | };\ |
335 | | const EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\ |
336 | | static const EVP_CIPHER cname##_ecb = {\ |
337 | | nid##_ecb, block_size, key_len, iv_len, \ |
338 | | flags | EVP_CIPH_ECB_MODE,\ |
339 | | init_key,\ |
340 | | cname##_ecb_cipher,\ |
341 | | cleanup,\ |
342 | | sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\ |
343 | | sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\ |
344 | | set_asn1, get_asn1,\ |
345 | | ctrl,\ |
346 | | NULL \ |
347 | | };\ |
348 | | const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; } |
349 | | */ |
350 | | |
351 | | #define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \ |
352 | | block_size, key_len, iv_len, cbits, \ |
353 | | flags, init_key, \ |
354 | | cleanup, set_asn1, get_asn1, ctrl) \ |
355 | | BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \ |
356 | | BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \ |
357 | | cbits, flags, init_key, cleanup, set_asn1, \ |
358 | | get_asn1, ctrl) |
359 | | |
360 | | #define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len,fl) \ |
361 | | BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \ |
362 | | BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \ |
363 | | NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \ |
364 | | (fl)|EVP_CIPH_FLAG_DEFAULT_ASN1, \ |
365 | | cipher##_init_key, NULL, NULL, NULL, NULL) |
366 | | |
367 | | |
368 | | # ifndef OPENSSL_NO_EC |
369 | | |
370 | 0 | #define X25519_KEYLEN 32 |
371 | 0 | #define X448_KEYLEN 56 |
372 | 0 | #define ED448_KEYLEN 57 |
373 | | |
374 | | #define MAX_KEYLEN ED448_KEYLEN |
375 | | |
376 | | typedef struct { |
377 | | unsigned char pubkey[MAX_KEYLEN]; |
378 | | unsigned char *privkey; |
379 | | } ECX_KEY; |
380 | | |
381 | | #endif |
382 | | |
383 | | /* |
384 | | * Type needs to be a bit field Sub-type needs to be for variations on the |
385 | | * method, as in, can it do arbitrary encryption.... |
386 | | */ |
387 | | struct evp_pkey_st { |
388 | | int type; |
389 | | int save_type; |
390 | | CRYPTO_REF_COUNT references; |
391 | | const EVP_PKEY_ASN1_METHOD *ameth; |
392 | | ENGINE *engine; |
393 | | ENGINE *pmeth_engine; /* If not NULL public key ENGINE to use */ |
394 | | union { |
395 | | void *ptr; |
396 | | # ifndef OPENSSL_NO_RSA |
397 | | struct rsa_st *rsa; /* RSA */ |
398 | | # endif |
399 | | # ifndef OPENSSL_NO_DSA |
400 | | struct dsa_st *dsa; /* DSA */ |
401 | | # endif |
402 | | # ifndef OPENSSL_NO_DH |
403 | | struct dh_st *dh; /* DH */ |
404 | | # endif |
405 | | # ifndef OPENSSL_NO_EC |
406 | | struct ec_key_st *ec; /* ECC */ |
407 | | ECX_KEY *ecx; /* X25519, X448, Ed25519, Ed448 */ |
408 | | # endif |
409 | | } pkey; |
410 | | int save_parameters; |
411 | | STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ |
412 | | CRYPTO_RWLOCK *lock; |
413 | | } /* EVP_PKEY */ ; |
414 | | |
415 | | |
416 | | void openssl_add_all_ciphers_int(void); |
417 | | void openssl_add_all_digests_int(void); |
418 | | void evp_cleanup_int(void); |
419 | | void evp_app_cleanup_int(void); |
420 | | |
421 | | /* Pulling defines out of C source files */ |
422 | | |
423 | | #define EVP_RC4_KEY_SIZE 16 |
424 | | #ifndef TLS1_1_VERSION |
425 | 0 | # define TLS1_1_VERSION 0x0302 |
426 | | #endif |
427 | | |
428 | | void evp_encode_ctx_set_flags(EVP_ENCODE_CTX *ctx, unsigned int flags); |
429 | | |
430 | | /* EVP_ENCODE_CTX flags */ |
431 | | /* Don't generate new lines when encoding */ |
432 | 0 | #define EVP_ENCODE_CTX_NO_NEWLINES 1 |
433 | | /* Use the SRP base64 alphabet instead of the standard one */ |
434 | 1.79M | #define EVP_ENCODE_CTX_USE_SRP_ALPHABET 2 |