Coverage Report

Created: 2022-11-30 06:20

/src/openssl/crypto/evp/evp_locl.h
Line
Count
Source (jump to first uncovered line)
1
/* evp_locl.h */
2
/*
3
 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL project
4
 * 2000.
5
 */
6
/* ====================================================================
7
 * Copyright (c) 1999 The OpenSSL Project.  All rights reserved.
8
 *
9
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions
11
 * are met:
12
 *
13
 * 1. Redistributions of source code must retain the above copyright
14
 *    notice, this list of conditions and the following disclaimer.
15
 *
16
 * 2. Redistributions in binary form must reproduce the above copyright
17
 *    notice, this list of conditions and the following disclaimer in
18
 *    the documentation and/or other materials provided with the
19
 *    distribution.
20
 *
21
 * 3. All advertising materials mentioning features or use of this
22
 *    software must display the following acknowledgment:
23
 *    "This product includes software developed by the OpenSSL Project
24
 *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
25
 *
26
 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
27
 *    endorse or promote products derived from this software without
28
 *    prior written permission. For written permission, please contact
29
 *    licensing@OpenSSL.org.
30
 *
31
 * 5. Products derived from this software may not be called "OpenSSL"
32
 *    nor may "OpenSSL" appear in their names without prior written
33
 *    permission of the OpenSSL Project.
34
 *
35
 * 6. Redistributions of any form whatsoever must retain the following
36
 *    acknowledgment:
37
 *    "This product includes software developed by the OpenSSL Project
38
 *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
39
 *
40
 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
41
 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
44
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51
 * OF THE POSSIBILITY OF SUCH DAMAGE.
52
 * ====================================================================
53
 *
54
 * This product includes cryptographic software written by Eric Young
55
 * (eay@cryptsoft.com).  This product includes software written by Tim
56
 * Hudson (tjh@cryptsoft.com).
57
 *
58
 */
59
60
/* Macros to code block cipher wrappers */
61
62
/* Wrapper functions for each cipher mode */
63
64
#define BLOCK_CIPHER_ecb_loop() \
65
0
        size_t i, bl; \
66
0
        bl = ctx->cipher->block_size;\
67
0
        if(inl < bl) return 1;\
68
0
        inl -= bl; \
69
0
        for(i=0; i <= inl; i+=bl)
70
71
#define BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
72
0
static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
73
0
{\
74
0
        BLOCK_CIPHER_ecb_loop() \
75
0
                cprefix##_ecb_encrypt(in + i, out + i, &((kstruct *)ctx->cipher_data)->ksched, ctx->encrypt);\
76
0
        return 1;\
77
0
}
Unexecuted instantiation: e_seed.c:seed_ecb_cipher
Unexecuted instantiation: e_rc2.c:rc2_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
78
79
0
#define EVP_MAXCHUNK ((size_t)1<<(sizeof(long)*8-2))
80
81
#define BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched) \
82
0
static int cname##_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
83
0
{\
84
0
        while(inl>=EVP_MAXCHUNK)\
85
0
            {\
86
0
            cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\
87
0
            inl-=EVP_MAXCHUNK;\
88
0
            in +=EVP_MAXCHUNK;\
89
0
            out+=EVP_MAXCHUNK;\
90
0
            }\
91
0
        if (inl)\
92
0
            cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, &ctx->num);\
93
0
        return 1;\
94
0
}
Unexecuted instantiation: e_idea.c:idea_ofb_cipher
Unexecuted instantiation: e_seed.c:seed_ofb_cipher
Unexecuted instantiation: e_rc2.c:rc2_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
95
96
#define BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
97
0
static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
98
0
{\
99
0
        while(inl>=EVP_MAXCHUNK) \
100
0
            {\
101
0
            cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\
102
0
            inl-=EVP_MAXCHUNK;\
103
0
            in +=EVP_MAXCHUNK;\
104
0
            out+=EVP_MAXCHUNK;\
105
0
            }\
106
0
        if (inl)\
107
0
            cprefix##_cbc_encrypt(in, out, (long)inl, &((kstruct *)ctx->cipher_data)->ksched, ctx->iv, ctx->encrypt);\
108
0
        return 1;\
109
0
}
Unexecuted instantiation: e_idea.c:idea_cbc_cipher
Unexecuted instantiation: e_seed.c:seed_cbc_cipher
Unexecuted instantiation: e_rc2.c:rc2_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
110
111
#define BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
112
0
static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t inl) \
113
0
{\
114
0
        size_t chunk=EVP_MAXCHUNK;\
115
0
        if (cbits==1)  chunk>>=3;\
116
0
        if (inl<chunk) chunk=inl;\
117
0
        while(inl && inl>=chunk)\
118
0
            {\
119
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);\
120
0
            inl-=chunk;\
121
0
            in +=chunk;\
122
0
            out+=chunk;\
123
0
            if(inl<chunk) chunk=inl;\
124
0
            }\
125
0
        return 1;\
126
0
}
Unexecuted instantiation: e_idea.c:idea_cfb64_cipher
Unexecuted instantiation: e_seed.c:seed_cfb128_cipher
Unexecuted instantiation: e_rc2.c:rc2_cfb64_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
127
128
#define BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
129
        BLOCK_CIPHER_func_cbc(cname, cprefix, kstruct, ksched) \
130
        BLOCK_CIPHER_func_cfb(cname, cprefix, cbits, kstruct, ksched) \
131
        BLOCK_CIPHER_func_ecb(cname, cprefix, kstruct, ksched) \
132
        BLOCK_CIPHER_func_ofb(cname, cprefix, cbits, kstruct, ksched)
133
134
#define BLOCK_CIPHER_def1(cname, nmode, mode, MODE, kstruct, nid, block_size, \
135
                          key_len, iv_len, flags, init_key, cleanup, \
136
                          set_asn1, get_asn1, ctrl) \
137
static const EVP_CIPHER cname##_##mode = { \
138
        nid##_##nmode, block_size, key_len, iv_len, \
139
        flags | EVP_CIPH_##MODE##_MODE, \
140
        init_key, \
141
        cname##_##mode##_cipher, \
142
        cleanup, \
143
        sizeof(kstruct), \
144
        set_asn1, get_asn1,\
145
        ctrl, \
146
        NULL \
147
}; \
148
817
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_des_cbc
Line
Count
Source
148
38
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_des_cfb64
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_des_ofb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_des_ecb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_des_cfb1
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_des_cfb8
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_idea_cbc
Line
Count
Source
148
38
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_idea_cfb64
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_idea_ofb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_idea_ecb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_des_ede_cbc
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_des_ede_cfb64
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_des_ede_ofb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
Unexecuted instantiation: EVP_des_ede_ecb
EVP_des_ede3_cbc
Line
Count
Source
148
38
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_des_ede3_cfb64
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_des_ede3_ofb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
Unexecuted instantiation: EVP_des_ede3_ecb
EVP_des_ede3_cfb1
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_des_ede3_cfb8
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_seed_cbc
Line
Count
Source
148
38
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_seed_cfb128
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_seed_ofb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_seed_ecb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_rc2_cbc
Line
Count
Source
148
38
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_rc2_cfb64
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_rc2_ofb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_rc2_ecb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_bf_cbc
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_bf_cfb64
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_bf_ofb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_bf_ecb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_cast5_cbc
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_cast5_cfb64
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_cast5_ofb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_cast5_ecb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_rc5_32_12_16_cbc
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_rc5_32_12_16_cfb64
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_rc5_32_12_16_ofb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
EVP_rc5_32_12_16_ecb
Line
Count
Source
148
19
const EVP_CIPHER *EVP_##cname##_##mode(void) { return &cname##_##mode; }
149
150
#define BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, \
151
                             iv_len, flags, init_key, cleanup, set_asn1, \
152
                             get_asn1, ctrl) \
153
BLOCK_CIPHER_def1(cname, cbc, cbc, CBC, kstruct, nid, block_size, key_len, \
154
                  iv_len, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
155
156
#define BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, \
157
                             iv_len, cbits, flags, init_key, cleanup, \
158
                             set_asn1, get_asn1, ctrl) \
159
BLOCK_CIPHER_def1(cname, cfb##cbits, cfb##cbits, CFB, kstruct, nid, 1, \
160
                  key_len, iv_len, flags, init_key, cleanup, set_asn1, \
161
                  get_asn1, ctrl)
162
163
#define BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, \
164
                             iv_len, cbits, flags, init_key, cleanup, \
165
                             set_asn1, get_asn1, ctrl) \
166
BLOCK_CIPHER_def1(cname, ofb##cbits, ofb, OFB, kstruct, nid, 1, \
167
                  key_len, iv_len, flags, init_key, cleanup, set_asn1, \
168
                  get_asn1, ctrl)
169
170
#define BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, \
171
                             flags, init_key, cleanup, set_asn1, \
172
                             get_asn1, ctrl) \
173
BLOCK_CIPHER_def1(cname, ecb, ecb, ECB, kstruct, nid, block_size, key_len, \
174
                  0, flags, init_key, cleanup, set_asn1, get_asn1, ctrl)
175
176
#define BLOCK_CIPHER_defs(cname, kstruct, \
177
                          nid, block_size, key_len, iv_len, cbits, flags, \
178
                          init_key, cleanup, set_asn1, get_asn1, ctrl) \
179
BLOCK_CIPHER_def_cbc(cname, kstruct, nid, block_size, key_len, iv_len, flags, \
180
                     init_key, cleanup, set_asn1, get_asn1, ctrl) \
181
BLOCK_CIPHER_def_cfb(cname, kstruct, nid, key_len, iv_len, cbits, \
182
                     flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
183
BLOCK_CIPHER_def_ofb(cname, kstruct, nid, key_len, iv_len, cbits, \
184
                     flags, init_key, cleanup, set_asn1, get_asn1, ctrl) \
185
BLOCK_CIPHER_def_ecb(cname, kstruct, nid, block_size, key_len, flags, \
186
                     init_key, cleanup, set_asn1, get_asn1, ctrl)
187
188
/*-
189
#define BLOCK_CIPHER_defs(cname, kstruct, \
190
                                nid, block_size, key_len, iv_len, flags,\
191
                                 init_key, cleanup, set_asn1, get_asn1, ctrl)\
192
static const EVP_CIPHER cname##_cbc = {\
193
        nid##_cbc, block_size, key_len, iv_len, \
194
        flags | EVP_CIPH_CBC_MODE,\
195
        init_key,\
196
        cname##_cbc_cipher,\
197
        cleanup,\
198
        sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
199
                sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
200
        set_asn1, get_asn1,\
201
        ctrl, \
202
        NULL \
203
};\
204
const EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\
205
static const EVP_CIPHER cname##_cfb = {\
206
        nid##_cfb64, 1, key_len, iv_len, \
207
        flags | EVP_CIPH_CFB_MODE,\
208
        init_key,\
209
        cname##_cfb_cipher,\
210
        cleanup,\
211
        sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
212
                sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
213
        set_asn1, get_asn1,\
214
        ctrl,\
215
        NULL \
216
};\
217
const EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\
218
static const EVP_CIPHER cname##_ofb = {\
219
        nid##_ofb64, 1, key_len, iv_len, \
220
        flags | EVP_CIPH_OFB_MODE,\
221
        init_key,\
222
        cname##_ofb_cipher,\
223
        cleanup,\
224
        sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
225
                sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
226
        set_asn1, get_asn1,\
227
        ctrl,\
228
        NULL \
229
};\
230
const EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\
231
static const EVP_CIPHER cname##_ecb = {\
232
        nid##_ecb, block_size, key_len, iv_len, \
233
        flags | EVP_CIPH_ECB_MODE,\
234
        init_key,\
235
        cname##_ecb_cipher,\
236
        cleanup,\
237
        sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+\
238
                sizeof((((EVP_CIPHER_CTX *)NULL)->c.kstruct)),\
239
        set_asn1, get_asn1,\
240
        ctrl,\
241
        NULL \
242
};\
243
const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
244
*/
245
246
#define IMPLEMENT_BLOCK_CIPHER(cname, ksched, cprefix, kstruct, nid, \
247
                               block_size, key_len, iv_len, cbits, \
248
                               flags, init_key, \
249
                               cleanup, set_asn1, get_asn1, ctrl) \
250
        BLOCK_CIPHER_all_funcs(cname, cprefix, cbits, kstruct, ksched) \
251
        BLOCK_CIPHER_defs(cname, kstruct, nid, block_size, key_len, iv_len, \
252
                          cbits, flags, init_key, cleanup, set_asn1, \
253
                          get_asn1, ctrl)
254
255
0
#define EVP_C_DATA(kstruct, ctx)        ((kstruct *)(ctx)->cipher_data)
256
257
#define IMPLEMENT_CFBR(cipher,cprefix,kstruct,ksched,keysize,cbits,iv_len) \
258
        BLOCK_CIPHER_func_cfb(cipher##_##keysize,cprefix,cbits,kstruct,ksched) \
259
        BLOCK_CIPHER_def_cfb(cipher##_##keysize,kstruct, \
260
                             NID_##cipher##_##keysize, keysize/8, iv_len, cbits, \
261
                             0, cipher##_init_key, NULL, \
262
                             EVP_CIPHER_set_asn1_iv, \
263
                             EVP_CIPHER_get_asn1_iv, \
264
                             NULL)
265
266
struct evp_pkey_ctx_st {
267
    /* Method associated with this operation */
268
    const EVP_PKEY_METHOD *pmeth;
269
    /* Engine that implements this method or NULL if builtin */
270
    ENGINE *engine;
271
    /* Key: may be NULL */
272
    EVP_PKEY *pkey;
273
    /* Peer key for key agreement, may be NULL */
274
    EVP_PKEY *peerkey;
275
    /* Actual operation */
276
    int operation;
277
    /* Algorithm specific data */
278
    void *data;
279
    /* Application specific data */
280
    void *app_data;
281
    /* Keygen callback */
282
    EVP_PKEY_gen_cb *pkey_gencb;
283
    /* implementation specific keygen data */
284
    int *keygen_info;
285
    int keygen_info_count;
286
} /* EVP_PKEY_CTX */ ;
287
288
57
#define EVP_PKEY_FLAG_DYNAMIC   1
289
290
struct evp_pkey_method_st {
291
    int pkey_id;
292
    int flags;
293
    int (*init) (EVP_PKEY_CTX *ctx);
294
    int (*copy) (EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src);
295
    void (*cleanup) (EVP_PKEY_CTX *ctx);
296
    int (*paramgen_init) (EVP_PKEY_CTX *ctx);
297
    int (*paramgen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
298
    int (*keygen_init) (EVP_PKEY_CTX *ctx);
299
    int (*keygen) (EVP_PKEY_CTX *ctx, EVP_PKEY *pkey);
300
    int (*sign_init) (EVP_PKEY_CTX *ctx);
301
    int (*sign) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
302
                 const unsigned char *tbs, size_t tbslen);
303
    int (*verify_init) (EVP_PKEY_CTX *ctx);
304
    int (*verify) (EVP_PKEY_CTX *ctx,
305
                   const unsigned char *sig, size_t siglen,
306
                   const unsigned char *tbs, size_t tbslen);
307
    int (*verify_recover_init) (EVP_PKEY_CTX *ctx);
308
    int (*verify_recover) (EVP_PKEY_CTX *ctx,
309
                           unsigned char *rout, size_t *routlen,
310
                           const unsigned char *sig, size_t siglen);
311
    int (*signctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
312
    int (*signctx) (EVP_PKEY_CTX *ctx, unsigned char *sig, size_t *siglen,
313
                    EVP_MD_CTX *mctx);
314
    int (*verifyctx_init) (EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx);
315
    int (*verifyctx) (EVP_PKEY_CTX *ctx, const unsigned char *sig, int siglen,
316
                      EVP_MD_CTX *mctx);
317
    int (*encrypt_init) (EVP_PKEY_CTX *ctx);
318
    int (*encrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
319
                    const unsigned char *in, size_t inlen);
320
    int (*decrypt_init) (EVP_PKEY_CTX *ctx);
321
    int (*decrypt) (EVP_PKEY_CTX *ctx, unsigned char *out, size_t *outlen,
322
                    const unsigned char *in, size_t inlen);
323
    int (*derive_init) (EVP_PKEY_CTX *ctx);
324
    int (*derive) (EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen);
325
    int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, void *p2);
326
    int (*ctrl_str) (EVP_PKEY_CTX *ctx, const char *type, const char *value);
327
} /* EVP_PKEY_METHOD */ ;
328
329
void evp_pkey_set_cb_translate(BN_GENCB *cb, EVP_PKEY_CTX *ctx);
330
331
int PKCS5_v2_PBKDF2_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass,
332
                             int passlen, ASN1_TYPE *param,
333
                             const EVP_CIPHER *c, const EVP_MD *md,
334
                             int en_de);
335
336
const EVP_MD *evp_get_fips_md(const EVP_MD *md);
337
const EVP_CIPHER *evp_get_fips_cipher(const EVP_CIPHER *cipher);
338
339
#ifdef OPENSSL_FIPS
340
341
# ifdef OPENSSL_DOING_MAKEDEPEND
342
#  undef SHA1_Init
343
#  undef SHA1_Update
344
#  undef SHA224_Init
345
#  undef SHA256_Init
346
#  undef SHA384_Init
347
#  undef SHA512_Init
348
#  undef DES_set_key_unchecked
349
# endif
350
351
# define RIPEMD160_Init  private_RIPEMD160_Init
352
# define WHIRLPOOL_Init  private_WHIRLPOOL_Init
353
# define MD5_Init        private_MD5_Init
354
# define MD4_Init        private_MD4_Init
355
# define MD2_Init        private_MD2_Init
356
# define MDC2_Init       private_MDC2_Init
357
# define SHA_Init        private_SHA_Init
358
# define SHA1_Init       private_SHA1_Init
359
# define SHA224_Init     private_SHA224_Init
360
# define SHA256_Init     private_SHA256_Init
361
# define SHA384_Init     private_SHA384_Init
362
# define SHA512_Init     private_SHA512_Init
363
364
# define BF_set_key      private_BF_set_key
365
# define CAST_set_key    private_CAST_set_key
366
# define idea_set_encrypt_key    private_idea_set_encrypt_key
367
# define SEED_set_key    private_SEED_set_key
368
# define RC2_set_key     private_RC2_set_key
369
# define RC4_set_key     private_RC4_set_key
370
# define DES_set_key_unchecked   private_DES_set_key_unchecked
371
# define Camellia_set_key        private_Camellia_set_key
372
373
#endif