summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/evp.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp/evp.h')
-rw-r--r--src/lib/libcrypto/evp/evp.h875
1 files changed, 463 insertions, 412 deletions
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index b39fad93a4..fb16de6852 100644
--- a/src/lib/libcrypto/evp/evp.h
+++ b/src/lib/libcrypto/evp/evp.h
@@ -59,75 +59,39 @@
59#ifndef HEADER_ENVELOPE_H 59#ifndef HEADER_ENVELOPE_H
60#define HEADER_ENVELOPE_H 60#define HEADER_ENVELOPE_H
61 61
62#ifdef __cplusplus 62#ifdef OPENSSL_ALGORITHM_DEFINES
63extern "C" { 63# include <openssl/opensslconf.h>
64#else
65# define OPENSSL_ALGORITHM_DEFINES
66# include <openssl/opensslconf.h>
67# undef OPENSSL_ALGORITHM_DEFINES
64#endif 68#endif
65 69
66#ifndef NO_MD2 70#include <openssl/ossl_typ.h>
67#include "md2.h" 71
68#endif 72#include <openssl/symhacks.h>
69#ifndef NO_MD5 73
70#include "md5.h" 74#ifndef OPENSSL_NO_BIO
71#endif 75#include <openssl/bio.h>
72#if !defined(NO_SHA) || !defined(NO_SHA1)
73#include "sha.h"
74#endif
75#ifndef NO_RIPEMD
76#include "ripemd.h"
77#endif
78#ifndef NO_DES
79#include "des.h"
80#endif
81#ifndef NO_RC4
82#include "rc4.h"
83#endif
84#ifndef NO_RC2
85#include "rc2.h"
86#endif
87#ifndef NO_RC5
88#include "rc5.h"
89#endif
90#ifndef NO_BLOWFISH
91#include "blowfish.h"
92#endif
93#ifndef NO_CAST
94#include "cast.h"
95#endif
96#ifndef NO_IDEA
97#include "idea.h"
98#endif
99#ifndef NO_MDC2
100#include "mdc2.h"
101#endif 76#endif
102 77
78/*
103#define EVP_RC2_KEY_SIZE 16 79#define EVP_RC2_KEY_SIZE 16
104#define EVP_RC4_KEY_SIZE 16 80#define EVP_RC4_KEY_SIZE 16
105#define EVP_BLOWFISH_KEY_SIZE 16 81#define EVP_BLOWFISH_KEY_SIZE 16
106#define EVP_CAST5_KEY_SIZE 16 82#define EVP_CAST5_KEY_SIZE 16
107#define EVP_RC5_32_12_16_KEY_SIZE 16 83#define EVP_RC5_32_12_16_KEY_SIZE 16
84*/
108#define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */ 85#define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */
109#define EVP_MAX_KEY_LENGTH 24 86#define EVP_MAX_KEY_LENGTH 32
110#define EVP_MAX_IV_LENGTH 8 87#define EVP_MAX_IV_LENGTH 16
111 88#define EVP_MAX_BLOCK_LENGTH 32
112#ifndef NO_RSA
113#include "rsa.h"
114#else
115#define RSA long
116#endif
117
118#ifndef NO_DSA
119#include "dsa.h"
120#else
121#define DSA long
122#endif
123 89
124#ifndef NO_DH 90#define PKCS5_SALT_LEN 8
125#include "dh.h" 91/* Default PKCS#5 iteration count */
126#else 92#define PKCS5_DEFAULT_ITER 2048
127#define DH long
128#endif
129 93
130#include "objects.h" 94#include <openssl/objects.h>
131 95
132#define EVP_PK_RSA 0x0001 96#define EVP_PK_RSA 0x0001
133#define EVP_PK_DSA 0x0002 97#define EVP_PK_DSA 0x0002
@@ -149,27 +113,33 @@ extern "C" {
149#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 113#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2
150#define EVP_PKEY_DH NID_dhKeyAgreement 114#define EVP_PKEY_DH NID_dhKeyAgreement
151 115
116#ifdef __cplusplus
117extern "C" {
118#endif
119
152/* Type needs to be a bit field 120/* Type needs to be a bit field
153 * Sub-type needs to be for variations on the method, as in, can it do 121 * Sub-type needs to be for variations on the method, as in, can it do
154 * arbitary encryption.... */ 122 * arbitrary encryption.... */
155typedef struct evp_pkey_st 123struct evp_pkey_st
156 { 124 {
157 int type; 125 int type;
158 int save_type; 126 int save_type;
159 int references; 127 int references;
160 union { 128 union {
161 char *ptr; 129 char *ptr;
130#ifndef OPENSSL_NO_RSA
162 struct rsa_st *rsa; /* RSA */ 131 struct rsa_st *rsa; /* RSA */
132#endif
133#ifndef OPENSSL_NO_DSA
163 struct dsa_st *dsa; /* DSA */ 134 struct dsa_st *dsa; /* DSA */
135#endif
136#ifndef OPENSSL_NO_DH
164 struct dh_st *dh; /* DH */ 137 struct dh_st *dh; /* DH */
138#endif
165 } pkey; 139 } pkey;
166 int save_parameters; 140 int save_parameters;
167#ifdef HEADER_STACK_H 141 STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
168 STACK /* X509_ATTRIBUTE */ *attributes; /* [ 0 ] */ 142 } /* EVP_PKEY */;
169#else
170 char /* X509_ATTRIBUTE */ *attributes; /* [ 0 ] */
171#endif
172 } EVP_PKEY;
173 143
174#define EVP_PKEY_MO_SIGN 0x0001 144#define EVP_PKEY_MO_SIGN 0x0001
175#define EVP_PKEY_MO_VERIFY 0x0002 145#define EVP_PKEY_MO_VERIFY 0x0002
@@ -183,7 +153,7 @@ typedef struct evp_pkey_st
183 * This is required because for various smart-card perform the digest and 153 * This is required because for various smart-card perform the digest and
184 * signing/verification on-board. To handle this case, the specific 154 * signing/verification on-board. To handle this case, the specific
185 * EVP_MD and EVP_PKEY_METHODs need to be closely associated. 155 * EVP_MD and EVP_PKEY_METHODs need to be closely associated.
186 * When a PKEY is created, it will have a EVP_PKEY_METHOD ossociated with it. 156 * When a PKEY is created, it will have a EVP_PKEY_METHOD associated with it.
187 * This can either be software or a token to provide the required low level 157 * This can either be software or a token to provide the required low level
188 * routines. 158 * routines.
189 */ 159 */
@@ -194,28 +164,28 @@ typedef struct evp_pkey_md_st
194 EVP_PKEY_METHOD *pkey; 164 EVP_PKEY_METHOD *pkey;
195 } EVP_PKEY_MD; 165 } EVP_PKEY_MD;
196 166
197#define EVP_rsa_md2() 167#define EVP_rsa_md2() \
198 EVP_PKEY_MD_add(NID_md2WithRSAEncryption,\ 168 EVP_PKEY_MD_add(NID_md2WithRSAEncryption,\
199 EVP_rsa_pkcs1(),EVP_md2()) 169 EVP_rsa_pkcs1(),EVP_md2())
200#define EVP_rsa_md5() 170#define EVP_rsa_md5() \
201 EVP_PKEY_MD_add(NID_md5WithRSAEncryption,\ 171 EVP_PKEY_MD_add(NID_md5WithRSAEncryption,\
202 EVP_rsa_pkcs1(),EVP_md5()) 172 EVP_rsa_pkcs1(),EVP_md5())
203#define EVP_rsa_sha0() 173#define EVP_rsa_sha0() \
204 EVP_PKEY_MD_add(NID_shaWithRSAEncryption,\ 174 EVP_PKEY_MD_add(NID_shaWithRSAEncryption,\
205 EVP_rsa_pkcs1(),EVP_sha()) 175 EVP_rsa_pkcs1(),EVP_sha())
206#define EVP_rsa_sha1() 176#define EVP_rsa_sha1() \
207 EVP_PKEY_MD_add(NID_sha1WithRSAEncryption,\ 177 EVP_PKEY_MD_add(NID_sha1WithRSAEncryption,\
208 EVP_rsa_pkcs1(),EVP_sha1()) 178 EVP_rsa_pkcs1(),EVP_sha1())
209#define EVP_rsa_ripemd160() 179#define EVP_rsa_ripemd160() \
210 EVP_PKEY_MD_add(NID_ripemd160WithRSA,\ 180 EVP_PKEY_MD_add(NID_ripemd160WithRSA,\
211 EVP_rsa_pkcs1(),EVP_ripemd160()) 181 EVP_rsa_pkcs1(),EVP_ripemd160())
212#define EVP_rsa_mdc2() 182#define EVP_rsa_mdc2() \
213 EVP_PKEY_MD_add(NID_mdc2WithRSA,\ 183 EVP_PKEY_MD_add(NID_mdc2WithRSA,\
214 EVP_rsa_octet_string(),EVP_mdc2()) 184 EVP_rsa_octet_string(),EVP_mdc2())
215#define EVP_dsa_sha() 185#define EVP_dsa_sha() \
216 EVP_PKEY_MD_add(NID_dsaWithSHA,\ 186 EVP_PKEY_MD_add(NID_dsaWithSHA,\
217 EVP_dsa(),EVP_mdc2()) 187 EVP_dsa(),EVP_sha())
218#define EVP_dsa_sha1() 188#define EVP_dsa_sha1() \
219 EVP_PKEY_MD_add(NID_dsaWithSHA1,\ 189 EVP_PKEY_MD_add(NID_dsaWithSHA1,\
220 EVP_dsa(),EVP_sha1()) 190 EVP_dsa(),EVP_sha1())
221 191
@@ -230,7 +200,6 @@ typedef struct evp_pkey_method_st
230 int (*sign)(); 200 int (*sign)();
231 int (*verify)(); 201 int (*verify)();
232 struct { 202 struct {
233 int
234 int (*set)(); /* get and/or set the underlying type */ 203 int (*set)(); /* get and/or set the underlying type */
235 int (*get)(); 204 int (*get)();
236 int (*encrypt)(); 205 int (*encrypt)();
@@ -245,25 +214,32 @@ typedef struct evp_pkey_method_st
245#endif 214#endif
246 215
247#ifndef EVP_MD 216#ifndef EVP_MD
248typedef struct env_md_st 217struct env_md_st
249 { 218 {
250 int type; 219 int type;
251 int pkey_type; 220 int pkey_type;
252 int md_size; 221 int md_size;
253 void (*init)(); 222 unsigned long flags;
254 void (*update)(); 223 int (*init)(EVP_MD_CTX *ctx);
255 void (*final)(); 224 int (*update)(EVP_MD_CTX *ctx,const void *data,unsigned long count);
256 225 int (*final)(EVP_MD_CTX *ctx,unsigned char *md);
226 int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from);
227 int (*cleanup)(EVP_MD_CTX *ctx);
228
229 /* FIXME: prototype these some day */
257 int (*sign)(); 230 int (*sign)();
258 int (*verify)(); 231 int (*verify)();
259 int required_pkey_type[5]; /*EVP_PKEY_xxx */ 232 int required_pkey_type[5]; /*EVP_PKEY_xxx */
260 int block_size; 233 int block_size;
261 int ctx_size; /* how big does the ctx need to be */ 234 int ctx_size; /* how big does the ctx->md_data need to be */
262 } EVP_MD; 235 } /* EVP_MD */;
236
237#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single
238 * block */
263 239
264#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0} 240#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0}
265 241
266#ifndef NO_DSA 242#ifndef OPENSSL_NO_DSA
267#define EVP_PKEY_DSA_method DSA_sign,DSA_verify, \ 243#define EVP_PKEY_DSA_method DSA_sign,DSA_verify, \
268 {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \ 244 {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \
269 EVP_PKEY_DSA4,0} 245 EVP_PKEY_DSA4,0}
@@ -271,7 +247,7 @@ typedef struct env_md_st
271#define EVP_PKEY_DSA_method EVP_PKEY_NULL_method 247#define EVP_PKEY_DSA_method EVP_PKEY_NULL_method
272#endif 248#endif
273 249
274#ifndef NO_RSA 250#ifndef OPENSSL_NO_RSA
275#define EVP_PKEY_RSA_method RSA_sign,RSA_verify, \ 251#define EVP_PKEY_RSA_method RSA_sign,RSA_verify, \
276 {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} 252 {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}
277#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \ 253#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \
@@ -285,103 +261,98 @@ typedef struct env_md_st
285 261
286#endif /* !EVP_MD */ 262#endif /* !EVP_MD */
287 263
288typedef struct env_md_ctx_st 264struct env_md_ctx_st
289 { 265 {
290 EVP_MD *digest; 266 const EVP_MD *digest;
291 union { 267 ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */
292 unsigned char base[4]; 268 unsigned long flags;
293#ifndef NO_MD2 269 void *md_data;
294 MD2_CTX md2; 270 } /* EVP_MD_CTX */;
295#endif 271
296#ifndef NO_MD5 272/* values for EVP_MD_CTX flags */
297 MD5_CTX md5;
298#endif
299#ifndef NO_MD5
300 RIPEMD160_CTX ripemd160;
301#endif
302#if !defined(NO_SHA) || !defined(NO_SHA1)
303 SHA_CTX sha;
304#endif
305#ifndef NO_MDC2
306 MDC2_CTX mdc2;
307#endif
308 } md;
309 } EVP_MD_CTX;
310 273
311typedef struct evp_cipher_st 274#define EVP_MD_CTX_FLAG_ONESHOT 0x0001 /* digest update will be called
275 * once only */
276#define EVP_MD_CTX_FLAG_CLEANED 0x0002 /* context has already been
277 * cleaned */
278
279struct evp_cipher_st
312 { 280 {
313 int nid; 281 int nid;
314 int block_size; 282 int block_size;
315 int key_len; 283 int key_len; /* Default value for variable length ciphers */
316 int iv_len; 284 int iv_len;
317 void (*init)(); /* init for encryption */ 285 unsigned long flags; /* Various flags */
318 void (*do_cipher)(); /* encrypt data */ 286 int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key,
319 void (*cleanup)(); /* used by cipher method */ 287 const unsigned char *iv, int enc); /* init key */
320 int ctx_size; /* how big the ctx needs to be */ 288 int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
321 /* int set_asn1_parameters(EVP_CIPHER_CTX,ASN1_TYPE *); */ 289 const unsigned char *in, unsigned int inl);/* encrypt/decrypt data */
322 int (*set_asn1_parameters)(); /* Populate a ASN1_TYPE with parameters */ 290 int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
323 /* int get_asn1_parameters(EVP_CIPHER_CTX,ASN1_TYPE *); */ 291 int ctx_size; /* how big ctx->cipher_data needs to be */
324 int (*get_asn1_parameters)(); /* Get parameters from a ASN1_TYPE */ 292 int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */
325 } EVP_CIPHER; 293 int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */
294 int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */
295 void *app_data; /* Application data */
296 } /* EVP_CIPHER */;
297
298/* Values for cipher flags */
299
300/* Modes for ciphers */
301
302#define EVP_CIPH_STREAM_CIPHER 0x0
303#define EVP_CIPH_ECB_MODE 0x1
304#define EVP_CIPH_CBC_MODE 0x2
305#define EVP_CIPH_CFB_MODE 0x3
306#define EVP_CIPH_OFB_MODE 0x4
307#define EVP_CIPH_MODE 0x7
308/* Set if variable length cipher */
309#define EVP_CIPH_VARIABLE_LENGTH 0x8
310/* Set if the iv handling should be done by the cipher itself */
311#define EVP_CIPH_CUSTOM_IV 0x10
312/* Set if the cipher's init() function should be called if key is NULL */
313#define EVP_CIPH_ALWAYS_CALL_INIT 0x20
314/* Call ctrl() to init cipher parameters */
315#define EVP_CIPH_CTRL_INIT 0x40
316/* Don't use standard key length function */
317#define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80
318/* Don't use standard block padding */
319#define EVP_CIPH_NO_PADDING 0x100
320
321/* ctrl() values */
322
323#define EVP_CTRL_INIT 0x0
324#define EVP_CTRL_SET_KEY_LENGTH 0x1
325#define EVP_CTRL_GET_RC2_KEY_BITS 0x2
326#define EVP_CTRL_SET_RC2_KEY_BITS 0x3
327#define EVP_CTRL_GET_RC5_ROUNDS 0x4
328#define EVP_CTRL_SET_RC5_ROUNDS 0x5
326 329
327typedef struct evp_cipher_info_st 330typedef struct evp_cipher_info_st
328 { 331 {
329 EVP_CIPHER *cipher; 332 const EVP_CIPHER *cipher;
330 unsigned char iv[EVP_MAX_IV_LENGTH]; 333 unsigned char iv[EVP_MAX_IV_LENGTH];
331 } EVP_CIPHER_INFO; 334 } EVP_CIPHER_INFO;
332 335
333typedef struct evp_cipher_ctx_st 336struct evp_cipher_ctx_st
334 { 337 {
335 EVP_CIPHER *cipher; 338 const EVP_CIPHER *cipher;
339 ENGINE *engine; /* functional reference if 'cipher' is ENGINE-provided */
336 int encrypt; /* encrypt or decrypt */ 340 int encrypt; /* encrypt or decrypt */
337 int buf_len; /* number we have left */ 341 int buf_len; /* number we have left */
338 342
339 unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */ 343 unsigned char oiv[EVP_MAX_IV_LENGTH]; /* original iv */
340 unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */ 344 unsigned char iv[EVP_MAX_IV_LENGTH]; /* working iv */
341 unsigned char buf[EVP_MAX_IV_LENGTH]; /* saved partial block */ 345 unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */
342 int num; /* used by cfb/ofb mode */ 346 int num; /* used by cfb/ofb mode */
343 347
344 char *app_data; /* aplication stuff */ 348 void *app_data; /* application stuff */
345 union { 349 int key_len; /* May change for variable length cipher */
346#ifndef NO_RC4 350 unsigned long flags; /* Various flags */
347 struct 351 void *cipher_data; /* per EVP data */
348 { 352 int final_used;
349 unsigned char key[EVP_RC4_KEY_SIZE]; 353 int block_mask;
350 RC4_KEY ks; /* working key */ 354 unsigned char final[EVP_MAX_BLOCK_LENGTH];/* possible final block */
351 } rc4; 355 } /* EVP_CIPHER_CTX */;
352#endif
353#ifndef NO_DES
354 des_key_schedule des_ks;/* key schedule */
355 struct
356 {
357 des_key_schedule ks;/* key schedule */
358 C_Block inw;
359 C_Block outw;
360 } desx_cbc;
361 struct
362 {
363 des_key_schedule ks1;/* key schedule */
364 des_key_schedule ks2;/* key schedule (for ede) */
365 des_key_schedule ks3;/* key schedule (for ede3) */
366 } des_ede;
367#endif
368#ifndef NO_IDEA
369 IDEA_KEY_SCHEDULE idea_ks;/* key schedule */
370#endif
371#ifndef NO_RC2
372 RC2_KEY rc2_ks;/* key schedule */
373#endif
374#ifndef NO_RC5
375 RC5_32_KEY rc5_ks;/* key schedule */
376#endif
377#ifndef NO_BLOWFISH
378 BF_KEY bf_ks;/* key schedule */
379#endif
380#ifndef NO_CAST
381 CAST_KEY cast_ks;/* key schedule */
382#endif
383 } c;
384 } EVP_CIPHER_CTX;
385 356
386typedef struct evp_Encode_Ctx_st 357typedef struct evp_Encode_Ctx_st
387 { 358 {
@@ -396,12 +367,25 @@ typedef struct evp_Encode_Ctx_st
396 int expect_nl; 367 int expect_nl;
397 } EVP_ENCODE_CTX; 368 } EVP_ENCODE_CTX;
398 369
370/* Password based encryption function */
371typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
372 ASN1_TYPE *param, const EVP_CIPHER *cipher,
373 const EVP_MD *md, int en_de);
374
375#ifndef OPENSSL_NO_RSA
399#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\ 376#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
400 (char *)(rsa)) 377 (char *)(rsa))
378#endif
379
380#ifndef OPENSSL_NO_DSA
401#define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\ 381#define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
402 (char *)(dsa)) 382 (char *)(dsa))
383#endif
384
385#ifndef OPENSSL_NO_DH
403#define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\ 386#define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\
404 (char *)(dh)) 387 (char *)(dh))
388#endif
405 389
406/* Add some extra combinations */ 390/* Add some extra combinations */
407#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) 391#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
@@ -410,77 +394,124 @@ typedef struct evp_Encode_Ctx_st
410#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) 394#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
411 395
412#define EVP_MD_type(e) ((e)->type) 396#define EVP_MD_type(e) ((e)->type)
397#define EVP_MD_nid(e) EVP_MD_type(e)
398#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e))
413#define EVP_MD_pkey_type(e) ((e)->pkey_type) 399#define EVP_MD_pkey_type(e) ((e)->pkey_type)
414#define EVP_MD_size(e) ((e)->md_size) 400#define EVP_MD_size(e) ((e)->md_size)
415#define EVP_MD_block_size(e) ((e)->block_size) 401#define EVP_MD_block_size(e) ((e)->block_size)
416 402
403#define EVP_MD_CTX_md(e) ((e)->digest)
417#define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest) 404#define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest)
418#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest) 405#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest)
419#define EVP_MD_CTX_type(e) ((e)->digest) 406#define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
420 407
421#define EVP_CIPHER_nid(e) ((e)->nid) 408#define EVP_CIPHER_nid(e) ((e)->nid)
409#define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e))
422#define EVP_CIPHER_block_size(e) ((e)->block_size) 410#define EVP_CIPHER_block_size(e) ((e)->block_size)
423#define EVP_CIPHER_key_length(e) ((e)->key_len) 411#define EVP_CIPHER_key_length(e) ((e)->key_len)
424#define EVP_CIPHER_iv_length(e) ((e)->iv_len) 412#define EVP_CIPHER_iv_length(e) ((e)->iv_len)
413#define EVP_CIPHER_flags(e) ((e)->flags)
414#define EVP_CIPHER_mode(e) (((e)->flags) & EVP_CIPH_MODE)
425 415
426#define EVP_CIPHER_CTX_cipher(e) ((e)->cipher) 416#define EVP_CIPHER_CTX_cipher(e) ((e)->cipher)
427#define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid) 417#define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid)
428#define EVP_CIPHER_CTX_block_size(e) ((e)->cipher->block_size) 418#define EVP_CIPHER_CTX_block_size(e) ((e)->cipher->block_size)
429#define EVP_CIPHER_CTX_key_length(e) ((e)->cipher->key_len) 419#define EVP_CIPHER_CTX_key_length(e) ((e)->key_len)
430#define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len) 420#define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len)
431#define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data) 421#define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data)
432#define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d)) 422#define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d))
423#define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
424#define EVP_CIPHER_CTX_flags(e) ((e)->cipher->flags)
425#define EVP_CIPHER_CTX_mode(e) ((e)->cipher->flags & EVP_CIPH_MODE)
433 426
434#define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80) 427#define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80)
435#define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80) 428#define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80)
436 429
430#define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
437#define EVP_SignInit(a,b) EVP_DigestInit(a,b) 431#define EVP_SignInit(a,b) EVP_DigestInit(a,b)
438#define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) 432#define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
433#define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c)
439#define EVP_VerifyInit(a,b) EVP_DigestInit(a,b) 434#define EVP_VerifyInit(a,b) EVP_DigestInit(a,b)
440#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) 435#define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c)
441#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e) 436#define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e)
442#define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e) 437#define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e)
443 438
444#define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md) 439#ifdef CONST_STRICT
440void BIO_set_md(BIO *,const EVP_MD *md);
441#else
442# define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md)
443#endif
445#define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp) 444#define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp)
446#define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp) 445#define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp)
447#define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL) 446#define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)
447#define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp)
448 448
449#define EVP_Cipher(c,o,i,l) (c)->cipher->do_cipher((c),(o),(i),(l)) 449#define EVP_Cipher(c,o,i,l) (c)->cipher->do_cipher((c),(o),(i),(l))
450 450
451#ifndef NOPROTO 451#define EVP_add_cipher_alias(n,alias) \
452 452 OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))
453void EVP_DigestInit(EVP_MD_CTX *ctx, EVP_MD *type); 453#define EVP_add_digest_alias(n,alias) \
454void EVP_DigestUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt); 454 OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n))
455void EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); 455#define EVP_delete_cipher_alias(alias) \
456 456 OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS);
457int EVP_read_pw_string(char *buf,int length,char *prompt,int verify); 457#define EVP_delete_digest_alias(alias) \
458 OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS);
459
460void EVP_MD_CTX_init(EVP_MD_CTX *ctx);
461int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
462EVP_MD_CTX *EVP_MD_CTX_create(void);
463void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
464int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in);
465#define EVP_MD_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs))
466#define EVP_MD_CTX_clear_flags(ctx,flgs) ((ctx)->flags&=~(flgs))
467#define EVP_MD_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs))
468int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
469int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d,
470 unsigned int cnt);
471int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
472int EVP_Digest(void *data, unsigned int count,
473 unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl);
474
475int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in);
476int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
477int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
478
479int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify);
458void EVP_set_pw_prompt(char *prompt); 480void EVP_set_pw_prompt(char *prompt);
459char * EVP_get_pw_prompt(void); 481char * EVP_get_pw_prompt(void);
460 482
461int EVP_BytesToKey(EVP_CIPHER *type,EVP_MD *md,unsigned char *salt, 483int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md,
462 unsigned char *data, int datal, int count, 484 const unsigned char *salt, const unsigned char *data,
463 unsigned char *key,unsigned char *iv); 485 int datal, int count, unsigned char *key,unsigned char *iv);
464 486
465EVP_CIPHER *EVP_get_cipherbyname(char *name); 487int EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
466 488 const unsigned char *key, const unsigned char *iv);
467void EVP_EncryptInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type, 489int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
468 unsigned char *key, unsigned char *iv); 490 const unsigned char *key, const unsigned char *iv);
469void EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, 491int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
470 int *outl, unsigned char *in, int inl); 492 int *outl, const unsigned char *in, int inl);
471void EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); 493int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
472 494int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
473void EVP_DecryptInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type, 495
474 unsigned char *key, unsigned char *iv); 496int EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
475void EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, 497 const unsigned char *key, const unsigned char *iv);
476 int *outl, unsigned char *in, int inl); 498int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
499 const unsigned char *key, const unsigned char *iv);
500int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
501 int *outl, const unsigned char *in, int inl);
477int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); 502int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
478 503int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
479void EVP_CipherInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type, unsigned char *key, 504
480 unsigned char *iv,int enc); 505int EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
481void EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, 506 const unsigned char *key,const unsigned char *iv,
482 int *outl, unsigned char *in, int inl); 507 int enc);
508int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
509 const unsigned char *key,const unsigned char *iv,
510 int enc);
511int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
512 int *outl, const unsigned char *in, int inl);
483int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl); 513int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
514int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
484 515
485int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s, 516int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s,
486 EVP_PKEY *pkey); 517 EVP_PKEY *pkey);
@@ -488,100 +519,171 @@ int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s,
488int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf, 519int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf,
489 unsigned int siglen,EVP_PKEY *pkey); 520 unsigned int siglen,EVP_PKEY *pkey);
490 521
491int EVP_OpenInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type,unsigned char *ek, 522int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type,unsigned char *ek,
492 int ekl,unsigned char *iv,EVP_PKEY *priv); 523 int ekl,unsigned char *iv,EVP_PKEY *priv);
493int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); 524int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
494 525
495int EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek, 526int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek,
496 int *ekl, unsigned char *iv,EVP_PKEY **pubk, int npubk); 527 int *ekl, unsigned char *iv,EVP_PKEY **pubk, int npubk);
497void EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl); 528int EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl);
498 529
499void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); 530void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
500void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out, 531void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,
501 int *outl,unsigned char *in,int inl); 532 int *outl,unsigned char *in,int inl);
502void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl); 533void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl);
503int EVP_EncodeBlock(unsigned char *t, unsigned char *f, int n); 534int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);
504 535
505void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); 536void EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
506int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, 537int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
507 unsigned char *in, int inl); 538 unsigned char *in, int inl);
508int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned 539int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
509 char *out, int *outl); 540 char *out, int *outl);
510int EVP_DecodeBlock(unsigned char *t, unsigned 541int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
511 char *f, int n);
512
513void ERR_load_EVP_strings(void );
514 542
515void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a); 543void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
516void EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); 544int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
545int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
546int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);
547int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
517 548
518#ifdef HEADER_BIO_H 549#ifndef OPENSSL_NO_BIO
519BIO_METHOD *BIO_f_md(void); 550BIO_METHOD *BIO_f_md(void);
520BIO_METHOD *BIO_f_base64(void); 551BIO_METHOD *BIO_f_base64(void);
521BIO_METHOD *BIO_f_cipher(void); 552BIO_METHOD *BIO_f_cipher(void);
522void BIO_set_cipher(BIO *b,EVP_CIPHER *c,unsigned char *k, 553BIO_METHOD *BIO_f_reliable(void);
554void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,unsigned char *k,
523 unsigned char *i, int enc); 555 unsigned char *i, int enc);
524#endif 556#endif
525 557
526EVP_MD *EVP_md_null(void); 558const EVP_MD *EVP_md_null(void);
527EVP_MD *EVP_md2(void); 559#ifndef OPENSSL_NO_MD2
528EVP_MD *EVP_md5(void); 560const EVP_MD *EVP_md2(void);
529EVP_MD *EVP_sha(void); 561#endif
530EVP_MD *EVP_sha1(void); 562#ifndef OPENSSL_NO_MD4
531EVP_MD *EVP_dss(void); 563const EVP_MD *EVP_md4(void);
532EVP_MD *EVP_dss1(void); 564#endif
533EVP_MD *EVP_mdc2(void); 565#ifndef OPENSSL_NO_MD5
534EVP_MD *EVP_ripemd160(void); 566const EVP_MD *EVP_md5(void);
535 567#endif
536EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */ 568#ifndef OPENSSL_NO_SHA
537EVP_CIPHER *EVP_des_ecb(void); 569const EVP_MD *EVP_sha(void);
538EVP_CIPHER *EVP_des_ede(void); 570const EVP_MD *EVP_sha1(void);
539EVP_CIPHER *EVP_des_ede3(void); 571const EVP_MD *EVP_dss(void);
540EVP_CIPHER *EVP_des_cfb(void); 572const EVP_MD *EVP_dss1(void);
541EVP_CIPHER *EVP_des_ede_cfb(void); 573#endif
542EVP_CIPHER *EVP_des_ede3_cfb(void); 574#ifndef OPENSSL_NO_MDC2
543EVP_CIPHER *EVP_des_ofb(void); 575const EVP_MD *EVP_mdc2(void);
544EVP_CIPHER *EVP_des_ede_ofb(void); 576#endif
545EVP_CIPHER *EVP_des_ede3_ofb(void); 577#ifndef OPENSSL_NO_RIPEMD
546EVP_CIPHER *EVP_des_cbc(void); 578const EVP_MD *EVP_ripemd160(void);
547EVP_CIPHER *EVP_des_ede_cbc(void); 579#endif
548EVP_CIPHER *EVP_des_ede3_cbc(void); 580const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */
549EVP_CIPHER *EVP_desx_cbc(void); 581#ifndef OPENSSL_NO_DES
550EVP_CIPHER *EVP_rc4(void); 582const EVP_CIPHER *EVP_des_ecb(void);
551EVP_CIPHER *EVP_rc4_40(void); 583const EVP_CIPHER *EVP_des_ede(void);
552EVP_CIPHER *EVP_idea_ecb(void); 584const EVP_CIPHER *EVP_des_ede3(void);
553EVP_CIPHER *EVP_idea_cfb(void); 585const EVP_CIPHER *EVP_des_cfb(void);
554EVP_CIPHER *EVP_idea_ofb(void); 586const EVP_CIPHER *EVP_des_ede_cfb(void);
555EVP_CIPHER *EVP_idea_cbc(void); 587const EVP_CIPHER *EVP_des_ede3_cfb(void);
556EVP_CIPHER *EVP_rc2_ecb(void); 588const EVP_CIPHER *EVP_des_ofb(void);
557EVP_CIPHER *EVP_rc2_cbc(void); 589const EVP_CIPHER *EVP_des_ede_ofb(void);
558EVP_CIPHER *EVP_rc2_40_cbc(void); 590const EVP_CIPHER *EVP_des_ede3_ofb(void);
559EVP_CIPHER *EVP_rc2_cfb(void); 591const EVP_CIPHER *EVP_des_cbc(void);
560EVP_CIPHER *EVP_rc2_ofb(void); 592const EVP_CIPHER *EVP_des_ede_cbc(void);
561EVP_CIPHER *EVP_bf_ecb(void); 593const EVP_CIPHER *EVP_des_ede3_cbc(void);
562EVP_CIPHER *EVP_bf_cbc(void); 594const EVP_CIPHER *EVP_desx_cbc(void);
563EVP_CIPHER *EVP_bf_cfb(void); 595/* This should now be supported through the dev_crypto ENGINE. But also, why are
564EVP_CIPHER *EVP_bf_ofb(void); 596 * rc4 and md5 declarations made here inside a "NO_DES" precompiler branch? */
565EVP_CIPHER *EVP_cast5_ecb(void); 597#if 0
566EVP_CIPHER *EVP_cast5_cbc(void); 598# ifdef OPENSSL_OPENBSD_DEV_CRYPTO
567EVP_CIPHER *EVP_cast5_cfb(void); 599const EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void);
568EVP_CIPHER *EVP_cast5_ofb(void); 600const EVP_CIPHER *EVP_dev_crypto_rc4(void);
569EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); 601const EVP_MD *EVP_dev_crypto_md5(void);
570EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); 602# endif
571EVP_CIPHER *EVP_rc5_32_12_16_cfb(void); 603#endif
572EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); 604#endif
573 605#ifndef OPENSSL_NO_RC4
574void SSLeay_add_all_algorithms(void); 606const EVP_CIPHER *EVP_rc4(void);
575void SSLeay_add_all_ciphers(void); 607const EVP_CIPHER *EVP_rc4_40(void);
576void SSLeay_add_all_digests(void); 608#endif
577 609#ifndef OPENSSL_NO_IDEA
578int EVP_add_cipher(EVP_CIPHER *cipher); 610const EVP_CIPHER *EVP_idea_ecb(void);
579int EVP_add_digest(EVP_MD *digest); 611const EVP_CIPHER *EVP_idea_cfb(void);
580int EVP_add_alias(char *name,char *alias); 612const EVP_CIPHER *EVP_idea_ofb(void);
581int EVP_delete_alias(char *name); 613const EVP_CIPHER *EVP_idea_cbc(void);
582 614#endif
583EVP_CIPHER *EVP_get_cipherbyname(char *name); 615#ifndef OPENSSL_NO_RC2
584EVP_MD *EVP_get_digestbyname(char *name); 616const EVP_CIPHER *EVP_rc2_ecb(void);
617const EVP_CIPHER *EVP_rc2_cbc(void);
618const EVP_CIPHER *EVP_rc2_40_cbc(void);
619const EVP_CIPHER *EVP_rc2_64_cbc(void);
620const EVP_CIPHER *EVP_rc2_cfb(void);
621const EVP_CIPHER *EVP_rc2_ofb(void);
622#endif
623#ifndef OPENSSL_NO_BF
624const EVP_CIPHER *EVP_bf_ecb(void);
625const EVP_CIPHER *EVP_bf_cbc(void);
626const EVP_CIPHER *EVP_bf_cfb(void);
627const EVP_CIPHER *EVP_bf_ofb(void);
628#endif
629#ifndef OPENSSL_NO_CAST
630const EVP_CIPHER *EVP_cast5_ecb(void);
631const EVP_CIPHER *EVP_cast5_cbc(void);
632const EVP_CIPHER *EVP_cast5_cfb(void);
633const EVP_CIPHER *EVP_cast5_ofb(void);
634#endif
635#ifndef OPENSSL_NO_RC5
636const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);
637const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
638const EVP_CIPHER *EVP_rc5_32_12_16_cfb(void);
639const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
640#endif
641#ifndef OPENSSL_NO_AES
642const EVP_CIPHER *EVP_aes_128_ecb(void);
643const EVP_CIPHER *EVP_aes_128_cbc(void);
644const EVP_CIPHER *EVP_aes_128_cfb(void);
645const EVP_CIPHER *EVP_aes_128_ofb(void);
646#if 0
647const EVP_CIPHER *EVP_aes_128_ctr(void);
648#endif
649const EVP_CIPHER *EVP_aes_192_ecb(void);
650const EVP_CIPHER *EVP_aes_192_cbc(void);
651const EVP_CIPHER *EVP_aes_192_cfb(void);
652const EVP_CIPHER *EVP_aes_192_ofb(void);
653#if 0
654const EVP_CIPHER *EVP_aes_192_ctr(void);
655#endif
656const EVP_CIPHER *EVP_aes_256_ecb(void);
657const EVP_CIPHER *EVP_aes_256_cbc(void);
658const EVP_CIPHER *EVP_aes_256_cfb(void);
659const EVP_CIPHER *EVP_aes_256_ofb(void);
660#if 0
661const EVP_CIPHER *EVP_aes_256_ctr(void);
662#endif
663#endif
664
665void OPENSSL_add_all_algorithms_noconf(void);
666void OPENSSL_add_all_algorithms_conf(void);
667
668#ifdef OPENSSL_LOAD_CONF
669#define OpenSSL_add_all_algorithms() \
670 OPENSSL_add_all_algorithms_conf()
671#else
672#define OpenSSL_add_all_algorithms() \
673 OPENSSL_add_all_algorithms_noconf()
674#endif
675
676void OpenSSL_add_all_ciphers(void);
677void OpenSSL_add_all_digests(void);
678#define SSLeay_add_all_algorithms() OpenSSL_add_all_algorithms()
679#define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers()
680#define SSLeay_add_all_digests() OpenSSL_add_all_digests()
681
682int EVP_add_cipher(const EVP_CIPHER *cipher);
683int EVP_add_digest(const EVP_MD *digest);
684
685const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
686const EVP_MD *EVP_get_digestbyname(const char *name);
585void EVP_cleanup(void); 687void EVP_cleanup(void);
586 688
587int EVP_PKEY_decrypt(unsigned char *dec_key,unsigned char *enc_key, 689int EVP_PKEY_decrypt(unsigned char *dec_key,unsigned char *enc_key,
@@ -592,6 +694,24 @@ int EVP_PKEY_type(int type);
592int EVP_PKEY_bits(EVP_PKEY *pkey); 694int EVP_PKEY_bits(EVP_PKEY *pkey);
593int EVP_PKEY_size(EVP_PKEY *pkey); 695int EVP_PKEY_size(EVP_PKEY *pkey);
594int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key); 696int EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key);
697
698#ifndef OPENSSL_NO_RSA
699struct rsa_st;
700int EVP_PKEY_set1_RSA(EVP_PKEY *pkey,struct rsa_st *key);
701struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey);
702#endif
703#ifndef OPENSSL_NO_DSA
704struct dsa_st;
705int EVP_PKEY_set1_DSA(EVP_PKEY *pkey,struct dsa_st *key);
706struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey);
707#endif
708#ifndef OPENSSL_NO_DH
709struct dh_st;
710int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key);
711struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
712#endif
713
714
595EVP_PKEY * EVP_PKEY_new(void); 715EVP_PKEY * EVP_PKEY_new(void);
596void EVP_PKEY_free(EVP_PKEY *pkey); 716void EVP_PKEY_free(EVP_PKEY *pkey);
597EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, unsigned char **pp, 717EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, unsigned char **pp,
@@ -600,6 +720,8 @@ int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);
600 720
601EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, unsigned char **pp, 721EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, unsigned char **pp,
602 long length); 722 long length);
723EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, unsigned char **pp,
724 long length);
603int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp); 725int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);
604 726
605int EVP_PKEY_copy_parameters(EVP_PKEY *to,EVP_PKEY *from); 727int EVP_PKEY_copy_parameters(EVP_PKEY *to,EVP_PKEY *from);
@@ -607,6 +729,8 @@ int EVP_PKEY_missing_parameters(EVP_PKEY *pkey);
607int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode); 729int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode);
608int EVP_PKEY_cmp_parameters(EVP_PKEY *a,EVP_PKEY *b); 730int EVP_PKEY_cmp_parameters(EVP_PKEY *a,EVP_PKEY *b);
609 731
732int EVP_CIPHER_type(const EVP_CIPHER *ctx);
733
610/* calls methods */ 734/* calls methods */
611int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); 735int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
612int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); 736int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
@@ -615,179 +739,106 @@ int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
615int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); 739int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
616int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type); 740int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c,ASN1_TYPE *type);
617 741
618#else 742/* PKCS5 password based encryption */
619 743int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
620void EVP_DigestInit(); 744 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
621void EVP_DigestUpdate(); 745 int en_de);
622void EVP_DigestFinal(); 746int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
623 747 unsigned char *salt, int saltlen, int iter,
624int EVP_read_pw_string(); 748 int keylen, unsigned char *out);
625void EVP_set_pw_prompt(); 749int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
626char * EVP_get_pw_prompt(); 750 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
627 751 int en_de);
628int EVP_BytesToKey(); 752
629 753void PKCS5_PBE_add(void);
630EVP_CIPHER *EVP_get_cipherbyname(); 754
631 755int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
632void EVP_EncryptInit(); 756 ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
633void EVP_EncryptUpdate(); 757int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
634void EVP_EncryptFinal(); 758 EVP_PBE_KEYGEN *keygen);
635 759void EVP_PBE_cleanup(void);
636void EVP_DecryptInit();
637void EVP_DecryptUpdate();
638int EVP_DecryptFinal();
639
640void EVP_CipherInit();
641void EVP_CipherUpdate();
642int EVP_CipherFinal();
643
644int EVP_SignFinal();
645
646int EVP_VerifyFinal();
647
648int EVP_OpenInit();
649int EVP_OpenFinal();
650
651int EVP_SealInit();
652void EVP_SealFinal();
653
654void EVP_EncodeInit();
655void EVP_EncodeUpdate();
656void EVP_EncodeFinal();
657int EVP_EncodeBlock();
658
659void EVP_DecodeInit();
660int EVP_DecodeUpdate();
661int EVP_DecodeFinal();
662int EVP_DecodeBlock();
663
664void ERR_load_EVP_strings();
665
666void EVP_CIPHER_CTX_init();
667void EVP_CIPHER_CTX_cleanup();
668
669#ifdef HEADER_BIO_H
670BIO_METHOD *BIO_f_md();
671BIO_METHOD *BIO_f_base64();
672BIO_METHOD *BIO_f_cipher();
673void BIO_set_cipher();
674#endif
675
676EVP_MD *EVP_md_null();
677EVP_MD *EVP_md2();
678EVP_MD *EVP_md5();
679EVP_MD *EVP_sha();
680EVP_MD *EVP_sha1();
681EVP_MD *EVP_dss();
682EVP_MD *EVP_dss1();
683EVP_MD *EVP_mdc2();
684
685EVP_CIPHER *EVP_enc_null();
686EVP_CIPHER *EVP_des_ecb();
687EVP_CIPHER *EVP_des_ede();
688EVP_CIPHER *EVP_des_ede3();
689EVP_CIPHER *EVP_des_cfb();
690EVP_CIPHER *EVP_des_ede_cfb();
691EVP_CIPHER *EVP_des_ede3_cfb();
692EVP_CIPHER *EVP_des_ofb();
693EVP_CIPHER *EVP_des_ede_ofb();
694EVP_CIPHER *EVP_des_ede3_ofb();
695EVP_CIPHER *EVP_des_cbc();
696EVP_CIPHER *EVP_des_ede_cbc();
697EVP_CIPHER *EVP_des_ede3_cbc();
698EVP_CIPHER *EVP_desx_cbc();
699EVP_CIPHER *EVP_rc4();
700EVP_CIPHER *EVP_rc4_40();
701EVP_CIPHER *EVP_idea_ecb();
702EVP_CIPHER *EVP_idea_cfb();
703EVP_CIPHER *EVP_idea_ofb();
704EVP_CIPHER *EVP_idea_cbc();
705EVP_CIPHER *EVP_rc2_ecb();
706EVP_CIPHER *EVP_rc2_cbc();
707EVP_CIPHER *EVP_rc2_40_cbc();
708EVP_CIPHER *EVP_rc2_cfb();
709EVP_CIPHER *EVP_rc2_ofb();
710EVP_CIPHER *EVP_bf_ecb();
711EVP_CIPHER *EVP_bf_cbc();
712EVP_CIPHER *EVP_bf_cfb();
713EVP_CIPHER *EVP_bf_ofb();
714EVP_CIPHER *EVP_cast5_ecb();
715EVP_CIPHER *EVP_cast5_cbc();
716EVP_CIPHER *EVP_cast5_cfb();
717EVP_CIPHER *EVP_cast5_ofb();
718EVP_CIPHER *EVP_rc5_32_12_16_cbc();
719EVP_CIPHER *EVP_rc5_32_12_16_ecb();
720EVP_CIPHER *EVP_rc5_32_12_16_cfb();
721EVP_CIPHER *EVP_rc5_32_12_16_ofb();
722
723void SSLeay_add_all_algorithms();
724void SSLeay_add_all_ciphers();
725void SSLeay_add_all_digests();
726
727int EVP_add_cipher();
728int EVP_add_digest();
729int EVP_add_alias();
730int EVP_delete_alias();
731
732EVP_CIPHER *EVP_get_cipherbyname();
733EVP_MD *EVP_get_digestbyname();
734void EVP_cleanup();
735
736int EVP_PKEY_decrypt();
737int EVP_PKEY_encrypt();
738int EVP_PKEY_type();
739int EVP_PKEY_bits();
740int EVP_PKEY_size();
741int EVP_PKEY_assign();
742EVP_PKEY * EVP_PKEY_new();
743void EVP_PKEY_free();
744EVP_PKEY * d2i_PublicKey();
745int i2d_PublicKey();
746
747EVP_PKEY * d2i_PrivateKey();
748int i2d_PrivateKey();
749
750int EVP_PKEY_copy_parameters();
751int EVP_PKEY_missing_parameters();
752int EVP_PKEY_save_parameters();
753int EVP_PKEY_cmp_parameters();
754
755int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
756int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type);
757
758int EVP_CIPHER_set_asn1_iv();
759int EVP_CIPHER_get_asn1_iv();
760
761#endif
762 760
763/* BEGIN ERROR CODES */ 761/* BEGIN ERROR CODES */
762/* The following lines are auto generated by the script mkerr.pl. Any changes
763 * made after this point may be overwritten when the script is next run.
764 */
765void ERR_load_EVP_strings(void);
766
764/* Error codes for the EVP functions. */ 767/* Error codes for the EVP functions. */
765 768
766/* Function codes. */ 769/* Function codes. */
767#define EVP_F_D2I_PKEY 100 770#define EVP_F_D2I_PKEY 100
771#define EVP_F_EVP_CIPHERINIT 123
772#define EVP_F_EVP_CIPHER_CTX_CTRL 124
773#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122
768#define EVP_F_EVP_DECRYPTFINAL 101 774#define EVP_F_EVP_DECRYPTFINAL 101
775#define EVP_F_EVP_DIGESTINIT 128
776#define EVP_F_EVP_ENCRYPTFINAL 127
777#define EVP_F_EVP_MD_CTX_COPY 110
769#define EVP_F_EVP_OPENINIT 102 778#define EVP_F_EVP_OPENINIT 102
779#define EVP_F_EVP_PBE_ALG_ADD 115
780#define EVP_F_EVP_PBE_CIPHERINIT 116
781#define EVP_F_EVP_PKCS82PKEY 111
782#define EVP_F_EVP_PKCS8_SET_BROKEN 112
783#define EVP_F_EVP_PKEY2PKCS8 113
770#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 784#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
771#define EVP_F_EVP_PKEY_DECRYPT 104 785#define EVP_F_EVP_PKEY_DECRYPT 104
772#define EVP_F_EVP_PKEY_ENCRYPT 105 786#define EVP_F_EVP_PKEY_ENCRYPT 105
787#define EVP_F_EVP_PKEY_GET1_DH 119
788#define EVP_F_EVP_PKEY_GET1_DSA 120
789#define EVP_F_EVP_PKEY_GET1_RSA 121
773#define EVP_F_EVP_PKEY_NEW 106 790#define EVP_F_EVP_PKEY_NEW 106
791#define EVP_F_EVP_RIJNDAEL 126
774#define EVP_F_EVP_SIGNFINAL 107 792#define EVP_F_EVP_SIGNFINAL 107
775#define EVP_F_EVP_VERIFYFINAL 108 793#define EVP_F_EVP_VERIFYFINAL 108
794#define EVP_F_PKCS5_PBE_KEYIVGEN 117
795#define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118
796#define EVP_F_RC2_MAGIC_TO_METH 109
797#define EVP_F_RC5_CTRL 125
776 798
777/* Reason codes. */ 799/* Reason codes. */
800#define EVP_R_BAD_BLOCK_LENGTH 136
778#define EVP_R_BAD_DECRYPT 100 801#define EVP_R_BAD_DECRYPT 100
802#define EVP_R_BAD_KEY_LENGTH 137
803#define EVP_R_BN_DECODE_ERROR 112
804#define EVP_R_BN_PUBKEY_ERROR 113
805#define EVP_R_CIPHER_PARAMETER_ERROR 122
806#define EVP_R_CTRL_NOT_IMPLEMENTED 132
807#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133
808#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138
809#define EVP_R_DECODE_ERROR 114
779#define EVP_R_DIFFERENT_KEY_TYPES 101 810#define EVP_R_DIFFERENT_KEY_TYPES 101
811#define EVP_R_ENCODE_ERROR 115
812#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119
813#define EVP_R_EXPECTING_AN_RSA_KEY 127
814#define EVP_R_EXPECTING_A_DH_KEY 128
815#define EVP_R_EXPECTING_A_DSA_KEY 129
816#define EVP_R_INITIALIZATION_ERROR 134
817#define EVP_R_INPUT_NOT_INITIALIZED 111
818#define EVP_R_INVALID_KEY_LENGTH 130
780#define EVP_R_IV_TOO_LARGE 102 819#define EVP_R_IV_TOO_LARGE 102
781#define EVP_R_MISSING_PARMATERS 103 820#define EVP_R_KEYGEN_FAILURE 120
821#define EVP_R_MISSING_PARAMETERS 103
822#define EVP_R_NO_CIPHER_SET 131
823#define EVP_R_NO_DIGEST_SET 139
824#define EVP_R_NO_DSA_PARAMETERS 116
782#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104 825#define EVP_R_NO_SIGN_FUNCTION_CONFIGURED 104
783#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105 826#define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED 105
827#define EVP_R_PKCS8_UNKNOWN_BROKEN_TYPE 117
784#define EVP_R_PUBLIC_KEY_NOT_RSA 106 828#define EVP_R_PUBLIC_KEY_NOT_RSA 106
829#define EVP_R_UNKNOWN_PBE_ALGORITHM 121
830#define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS 135
785#define EVP_R_UNSUPPORTED_CIPHER 107 831#define EVP_R_UNSUPPORTED_CIPHER 107
786#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 108 832#define EVP_R_UNSUPPORTED_KEYLENGTH 123
787#define EVP_R_WRONG_PUBLIC_KEY_TYPE 109 833#define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124
788 834#define EVP_R_UNSUPPORTED_KEY_SIZE 108
835#define EVP_R_UNSUPPORTED_PRF 125
836#define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118
837#define EVP_R_UNSUPPORTED_SALT_TYPE 126
838#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109
839#define EVP_R_WRONG_PUBLIC_KEY_TYPE 110
840
789#ifdef __cplusplus 841#ifdef __cplusplus
790} 842}
791#endif 843#endif
792#endif 844#endif
793