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.h319
1 files changed, 165 insertions, 154 deletions
diff --git a/src/lib/libcrypto/evp/evp.h b/src/lib/libcrypto/evp/evp.h
index 56eec23fef..bdd3b7ecaa 100644
--- a/src/lib/libcrypto/evp/evp.h
+++ b/src/lib/libcrypto/evp/evp.h
@@ -74,56 +74,6 @@
74#ifndef OPENSSL_NO_BIO 74#ifndef OPENSSL_NO_BIO
75#include <openssl/bio.h> 75#include <openssl/bio.h>
76#endif 76#endif
77#ifndef OPENSSL_NO_MD2
78#include <openssl/md2.h>
79#endif
80#ifndef OPENSSL_NO_MD4
81#include <openssl/md4.h>
82#endif
83#ifndef OPENSSL_NO_MD5
84#include <openssl/md5.h>
85#endif
86#ifndef OPENSSL_NO_SHA
87#ifndef OPENSSL_FIPS
88#include <openssl/sha.h>
89#else
90#include <openssl/fips_sha.h>
91#endif
92#endif
93#ifndef OPENSSL_NO_RIPEMD
94#include <openssl/ripemd.h>
95#endif
96#ifndef OPENSSL_NO_DES
97#include <openssl/des.h>
98#endif
99#ifndef OPENSSL_NO_RC4
100#include <openssl/rc4.h>
101#endif
102#ifndef OPENSSL_NO_RC2
103#include <openssl/rc2.h>
104#endif
105#ifndef OPENSSL_NO_RC5
106#include <openssl/rc5.h>
107#endif
108#ifndef OPENSSL_NO_BF
109#include <openssl/blowfish.h>
110#endif
111#ifndef OPENSSL_NO_CAST
112#include <openssl/cast.h>
113#endif
114#ifndef OPENSSL_NO_IDEA
115#include <openssl/idea.h>
116#endif
117#ifndef OPENSSL_NO_MDC2
118#include <openssl/mdc2.h>
119#endif
120#ifndef OPENSSL_NO_AES
121#include <openssl/aes.h>
122#endif
123
124#ifdef OPENSSL_FIPS
125#include <openssl/fips.h>
126#endif
127 77
128/* 78/*
129#define EVP_RC2_KEY_SIZE 16 79#define EVP_RC2_KEY_SIZE 16
@@ -132,11 +82,7 @@
132#define EVP_CAST5_KEY_SIZE 16 82#define EVP_CAST5_KEY_SIZE 16
133#define EVP_RC5_32_12_16_KEY_SIZE 16 83#define EVP_RC5_32_12_16_KEY_SIZE 16
134*/ 84*/
135#ifdef OPENSSL_FIPS 85#define EVP_MAX_MD_SIZE 64 /* longest known is SHA512 */
136#define EVP_MAX_MD_SIZE 64 /* longest known SHA512 */
137#else
138#define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */
139#endif
140#define EVP_MAX_KEY_LENGTH 32 86#define EVP_MAX_KEY_LENGTH 32
141#define EVP_MAX_IV_LENGTH 16 87#define EVP_MAX_IV_LENGTH 16
142#define EVP_MAX_BLOCK_LENGTH 32 88#define EVP_MAX_BLOCK_LENGTH 32
@@ -145,28 +91,18 @@
145/* Default PKCS#5 iteration count */ 91/* Default PKCS#5 iteration count */
146#define PKCS5_DEFAULT_ITER 2048 92#define PKCS5_DEFAULT_ITER 2048
147 93
148#ifndef OPENSSL_NO_RSA
149#include <openssl/rsa.h>
150#endif
151
152#ifndef OPENSSL_NO_DSA
153#include <openssl/dsa.h>
154#endif
155
156#ifndef OPENSSL_NO_DH
157#include <openssl/dh.h>
158#endif
159
160#include <openssl/objects.h> 94#include <openssl/objects.h>
161 95
162#define EVP_PK_RSA 0x0001 96#define EVP_PK_RSA 0x0001
163#define EVP_PK_DSA 0x0002 97#define EVP_PK_DSA 0x0002
164#define EVP_PK_DH 0x0004 98#define EVP_PK_DH 0x0004
99#define EVP_PK_EC 0x0008
165#define EVP_PKT_SIGN 0x0010 100#define EVP_PKT_SIGN 0x0010
166#define EVP_PKT_ENC 0x0020 101#define EVP_PKT_ENC 0x0020
167#define EVP_PKT_EXCH 0x0040 102#define EVP_PKT_EXCH 0x0040
168#define EVP_PKS_RSA 0x0100 103#define EVP_PKS_RSA 0x0100
169#define EVP_PKS_DSA 0x0200 104#define EVP_PKS_DSA 0x0200
105#define EVP_PKS_EC 0x0400
170#define EVP_PKT_EXP 0x1000 /* <= 512 bit key */ 106#define EVP_PKT_EXP 0x1000 /* <= 512 bit key */
171 107
172#define EVP_PKEY_NONE NID_undef 108#define EVP_PKEY_NONE NID_undef
@@ -178,6 +114,7 @@
178#define EVP_PKEY_DSA3 NID_dsaWithSHA1 114#define EVP_PKEY_DSA3 NID_dsaWithSHA1
179#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 115#define EVP_PKEY_DSA4 NID_dsaWithSHA1_2
180#define EVP_PKEY_DH NID_dhKeyAgreement 116#define EVP_PKEY_DH NID_dhKeyAgreement
117#define EVP_PKEY_EC NID_X9_62_id_ecPublicKey
181 118
182#ifdef __cplusplus 119#ifdef __cplusplus
183extern "C" { 120extern "C" {
@@ -202,6 +139,9 @@ struct evp_pkey_st
202#ifndef OPENSSL_NO_DH 139#ifndef OPENSSL_NO_DH
203 struct dh_st *dh; /* DH */ 140 struct dh_st *dh; /* DH */
204#endif 141#endif
142#ifndef OPENSSL_NO_EC
143 struct ec_key_st *ec; /* ECC */
144#endif
205 } pkey; 145 } pkey;
206 int save_parameters; 146 int save_parameters;
207 STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */ 147 STACK_OF(X509_ATTRIBUTE) *attributes; /* [ 0 ] */
@@ -287,39 +227,58 @@ struct env_md_st
287 int md_size; 227 int md_size;
288 unsigned long flags; 228 unsigned long flags;
289 int (*init)(EVP_MD_CTX *ctx); 229 int (*init)(EVP_MD_CTX *ctx);
290 int (*update)(EVP_MD_CTX *ctx,const void *data,unsigned long count); 230 int (*update)(EVP_MD_CTX *ctx,const void *data,size_t count);
291 int (*final)(EVP_MD_CTX *ctx,unsigned char *md); 231 int (*final)(EVP_MD_CTX *ctx,unsigned char *md);
292 int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from); 232 int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from);
293 int (*cleanup)(EVP_MD_CTX *ctx); 233 int (*cleanup)(EVP_MD_CTX *ctx);
294 234
295 /* FIXME: prototype these some day */ 235 /* FIXME: prototype these some day */
296 int (*sign)(); 236 int (*sign)(int type, const unsigned char *m, unsigned int m_length,
297 int (*verify)(); 237 unsigned char *sigret, unsigned int *siglen, void *key);
238 int (*verify)(int type, const unsigned char *m, unsigned int m_length,
239 const unsigned char *sigbuf, unsigned int siglen,
240 void *key);
298 int required_pkey_type[5]; /*EVP_PKEY_xxx */ 241 int required_pkey_type[5]; /*EVP_PKEY_xxx */
299 int block_size; 242 int block_size;
300 int ctx_size; /* how big does the ctx->md_data need to be */ 243 int ctx_size; /* how big does the ctx->md_data need to be */
301 } /* EVP_MD */; 244 } /* EVP_MD */;
302 245
246typedef int evp_sign_method(int type,const unsigned char *m,
247 unsigned int m_length,unsigned char *sigret,
248 unsigned int *siglen, void *key);
249typedef int evp_verify_method(int type,const unsigned char *m,
250 unsigned int m_length,const unsigned char *sigbuf,
251 unsigned int siglen, void *key);
252
303#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single 253#define EVP_MD_FLAG_ONESHOT 0x0001 /* digest can only handle a single
304 * block */ 254 * block */
305#define EVP_MD_FLAG_FIPS 0x0400 /* Note if suitable for use in FIPS mode */
306 255
307#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0} 256#define EVP_PKEY_NULL_method NULL,NULL,{0,0,0,0}
308 257
309#ifndef OPENSSL_NO_DSA 258#ifndef OPENSSL_NO_DSA
310#define EVP_PKEY_DSA_method DSA_sign,DSA_verify, \ 259#define EVP_PKEY_DSA_method (evp_sign_method *)DSA_sign, \
260 (evp_verify_method *)DSA_verify, \
311 {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \ 261 {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3, \
312 EVP_PKEY_DSA4,0} 262 EVP_PKEY_DSA4,0}
313#else 263#else
314#define EVP_PKEY_DSA_method EVP_PKEY_NULL_method 264#define EVP_PKEY_DSA_method EVP_PKEY_NULL_method
315#endif 265#endif
316 266
267#ifndef OPENSSL_NO_ECDSA
268#define EVP_PKEY_ECDSA_method (evp_sign_method *)ECDSA_sign, \
269 (evp_verify_method *)ECDSA_verify, \
270 {EVP_PKEY_EC,0,0,0}
271#else
272#define EVP_PKEY_ECDSA_method EVP_PKEY_NULL_method
273#endif
274
317#ifndef OPENSSL_NO_RSA 275#ifndef OPENSSL_NO_RSA
318#define EVP_PKEY_RSA_method RSA_sign,RSA_verify, \ 276#define EVP_PKEY_RSA_method (evp_sign_method *)RSA_sign, \
277 (evp_verify_method *)RSA_verify, \
319 {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} 278 {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}
320#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \ 279#define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \
321 RSA_sign_ASN1_OCTET_STRING, \ 280 (evp_sign_method *)RSA_sign_ASN1_OCTET_STRING, \
322 RSA_verify_ASN1_OCTET_STRING, \ 281 (evp_verify_method *)RSA_verify_ASN1_OCTET_STRING, \
323 {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0} 282 {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}
324#else 283#else
325#define EVP_PKEY_RSA_method EVP_PKEY_NULL_method 284#define EVP_PKEY_RSA_method EVP_PKEY_NULL_method
@@ -345,9 +304,6 @@ struct env_md_ctx_st
345#define EVP_MD_CTX_FLAG_REUSE 0x0004 /* Don't free up ctx->md_data 304#define EVP_MD_CTX_FLAG_REUSE 0x0004 /* Don't free up ctx->md_data
346 * in EVP_MD_CTX_cleanup */ 305 * in EVP_MD_CTX_cleanup */
347 306
348#define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0x0008 /* Allow use of non FIPS digest
349 * in FIPS mode */
350
351struct evp_cipher_st 307struct evp_cipher_st
352 { 308 {
353 int nid; 309 int nid;
@@ -389,10 +345,8 @@ struct evp_cipher_st
389#define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80 345#define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80
390/* Don't use standard block padding */ 346/* Don't use standard block padding */
391#define EVP_CIPH_NO_PADDING 0x100 347#define EVP_CIPH_NO_PADDING 0x100
392/* Note if suitable for use in FIPS mode */ 348/* cipher handles random key generation */
393#define EVP_CIPH_FLAG_FIPS 0x400 349#define EVP_CIPH_RAND_KEY 0x200
394/* Allow non FIPS cipher in FIPS mode */
395#define EVP_CIPH_FLAG_NON_FIPS_ALLOW 0x800
396 350
397/* ctrl() values */ 351/* ctrl() values */
398 352
@@ -402,6 +356,7 @@ struct evp_cipher_st
402#define EVP_CTRL_SET_RC2_KEY_BITS 0x3 356#define EVP_CTRL_SET_RC2_KEY_BITS 0x3
403#define EVP_CTRL_GET_RC5_ROUNDS 0x4 357#define EVP_CTRL_GET_RC5_ROUNDS 0x4
404#define EVP_CTRL_SET_RC5_ROUNDS 0x5 358#define EVP_CTRL_SET_RC5_ROUNDS 0x5
359#define EVP_CTRL_RAND_KEY 0x6
405 360
406typedef struct evp_cipher_info_st 361typedef struct evp_cipher_info_st
407 { 362 {
@@ -463,45 +418,47 @@ typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
463 (char *)(dh)) 418 (char *)(dh))
464#endif 419#endif
465 420
421#ifndef OPENSSL_NO_EC
422#define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\
423 (char *)(eckey))
424#endif
425
466/* Add some extra combinations */ 426/* Add some extra combinations */
467#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) 427#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
468#define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a)) 428#define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
469#define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) 429#define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
470#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) 430#define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
471 431
472#define EVP_MD_type(e) ((e)->type) 432int EVP_MD_type(const EVP_MD *md);
473#define EVP_MD_nid(e) EVP_MD_type(e) 433#define EVP_MD_nid(e) EVP_MD_type(e)
474#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e)) 434#define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e))
475#define EVP_MD_pkey_type(e) ((e)->pkey_type) 435int EVP_MD_pkey_type(const EVP_MD *md);
476#define EVP_MD_size(e) ((e)->md_size) 436int EVP_MD_size(const EVP_MD *md);
477#define EVP_MD_block_size(e) ((e)->block_size) 437int EVP_MD_block_size(const EVP_MD *md);
478 438
479#define EVP_MD_CTX_md(e) ((e)->digest) 439const EVP_MD * EVP_MD_CTX_md(const EVP_MD_CTX *ctx);
480#define EVP_MD_CTX_size(e) EVP_MD_size((e)->digest) 440#define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e))
481#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest) 441#define EVP_MD_CTX_block_size(e) EVP_MD_block_size(EVP_MD_CTX_md(e))
482#define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest) 442#define EVP_MD_CTX_type(e) EVP_MD_type(EVP_MD_CTX_md(e))
483 443
484#define EVP_CIPHER_nid(e) ((e)->nid) 444int EVP_CIPHER_nid(const EVP_CIPHER *cipher);
485#define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e)) 445#define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e))
486#define EVP_CIPHER_block_size(e) ((e)->block_size) 446int EVP_CIPHER_block_size(const EVP_CIPHER *cipher);
487#define EVP_CIPHER_key_length(e) ((e)->key_len) 447int EVP_CIPHER_key_length(const EVP_CIPHER *cipher);
488#define EVP_CIPHER_iv_length(e) ((e)->iv_len) 448int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher);
489#define EVP_CIPHER_flags(e) ((e)->flags) 449unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher);
490#define EVP_CIPHER_mode(e) (((e)->flags) & EVP_CIPH_MODE) 450#define EVP_CIPHER_mode(e) (EVP_CIPHER_flags(e) & EVP_CIPH_MODE)
491 451
492#define EVP_CIPHER_CTX_cipher(e) ((e)->cipher) 452const EVP_CIPHER * EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx);
493#define EVP_CIPHER_CTX_nid(e) ((e)->cipher->nid) 453int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx);
494#define EVP_CIPHER_CTX_block_size(e) ((e)->cipher->block_size) 454int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx);
495#define EVP_CIPHER_CTX_key_length(e) ((e)->key_len) 455int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx);
496#define EVP_CIPHER_CTX_iv_length(e) ((e)->cipher->iv_len) 456int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx);
497#define EVP_CIPHER_CTX_get_app_data(e) ((e)->app_data) 457void * EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx);
498#define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d)) 458void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data);
499#define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c)) 459#define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c))
500#define EVP_CIPHER_CTX_flags(e) ((e)->cipher->flags) 460unsigned long EVP_CIPHER_CTX_flags(const EVP_CIPHER_CTX *ctx);
501#define EVP_CIPHER_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs)) 461#define EVP_CIPHER_CTX_mode(e) (EVP_CIPHER_CTX_flags(e) & EVP_CIPH_MODE)
502#define EVP_CIPHER_CTX_clear_flags(ctx,flgs) ((ctx)->flags&=~(flgs))
503#define EVP_CIPHER_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs))
504#define EVP_CIPHER_CTX_mode(e) ((e)->cipher->flags & EVP_CIPH_MODE)
505 462
506#define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80) 463#define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80)
507#define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80) 464#define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80)
@@ -526,7 +483,10 @@ void BIO_set_md(BIO *,const EVP_MD *md);
526#define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL) 483#define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)
527#define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp) 484#define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp)
528 485
529#define EVP_Cipher(c,o,i,l) (c)->cipher->do_cipher((c),(o),(i),(l)) 486int EVP_Cipher(EVP_CIPHER_CTX *c,
487 unsigned char *out,
488 const unsigned char *in,
489 unsigned int inl);
530 490
531#define EVP_add_cipher_alias(n,alias) \ 491#define EVP_add_cipher_alias(n,alias) \
532 OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n)) 492 OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n))
@@ -542,14 +502,14 @@ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
542EVP_MD_CTX *EVP_MD_CTX_create(void); 502EVP_MD_CTX *EVP_MD_CTX_create(void);
543void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx); 503void EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
544int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in); 504int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in);
545#define EVP_MD_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs)) 505void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags);
546#define EVP_MD_CTX_clear_flags(ctx,flgs) ((ctx)->flags&=~(flgs)) 506void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags);
547#define EVP_MD_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs)) 507int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx,int flags);
548int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl); 508int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
549int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d, 509int EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d,
550 unsigned int cnt); 510 size_t cnt);
551int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); 511int EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
552int EVP_Digest(void *data, unsigned int count, 512int EVP_Digest(const void *data, size_t count,
553 unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl); 513 unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl);
554 514
555int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in); 515int EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in);
@@ -557,7 +517,7 @@ int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
557int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s); 517int EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
558 518
559int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify); 519int EVP_read_pw_string(char *buf,int length,const char *prompt,int verify);
560void EVP_set_pw_prompt(char *prompt); 520void EVP_set_pw_prompt(const char *prompt);
561char * EVP_get_pw_prompt(void); 521char * EVP_get_pw_prompt(void);
562 522
563int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md, 523int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md,
@@ -596,43 +556,48 @@ int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
596int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s, 556int EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s,
597 EVP_PKEY *pkey); 557 EVP_PKEY *pkey);
598 558
599int EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf, 559int EVP_VerifyFinal(EVP_MD_CTX *ctx,const unsigned char *sigbuf,
600 unsigned int siglen,EVP_PKEY *pkey); 560 unsigned int siglen,EVP_PKEY *pkey);
601 561
602int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type,unsigned char *ek, 562int EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type,
603 int ekl,unsigned char *iv,EVP_PKEY *priv); 563 const unsigned char *ek, int ekl, const unsigned char *iv,
564 EVP_PKEY *priv);
604int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); 565int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
605 566
606int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek, 567int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type,
607 int *ekl, unsigned char *iv,EVP_PKEY **pubk, int npubk); 568 unsigned char **ek, int *ekl, unsigned char *iv,
569 EVP_PKEY **pubk, int npubk);
608int EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl); 570int EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl);
609 571
610void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); 572void EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
611void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out, 573void EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
612 int *outl,unsigned char *in,int inl); 574 const unsigned char *in,int inl);
613void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl); 575void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl);
614int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n); 576int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n);
615 577
616void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); 578void EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
617int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl, 579int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
618 unsigned char *in, int inl); 580 const unsigned char *in, int inl);
619int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned 581int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
620 char *out, int *outl); 582 char *out, int *outl);
621int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n); 583int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
622 584
623void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a); 585void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
624int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a); 586int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
587EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void);
588void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *a);
625int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); 589int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
626int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad); 590int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad);
627int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); 591int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
592int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key);
628 593
629#ifndef OPENSSL_NO_BIO 594#ifndef OPENSSL_NO_BIO
630BIO_METHOD *BIO_f_md(void); 595BIO_METHOD *BIO_f_md(void);
631BIO_METHOD *BIO_f_base64(void); 596BIO_METHOD *BIO_f_base64(void);
632BIO_METHOD *BIO_f_cipher(void); 597BIO_METHOD *BIO_f_cipher(void);
633BIO_METHOD *BIO_f_reliable(void); 598BIO_METHOD *BIO_f_reliable(void);
634void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,unsigned char *k, 599void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,const unsigned char *k,
635 unsigned char *i, int enc); 600 const unsigned char *i, int enc);
636#endif 601#endif
637 602
638const EVP_MD *EVP_md_null(void); 603const EVP_MD *EVP_md_null(void);
@@ -650,7 +615,8 @@ const EVP_MD *EVP_sha(void);
650const EVP_MD *EVP_sha1(void); 615const EVP_MD *EVP_sha1(void);
651const EVP_MD *EVP_dss(void); 616const EVP_MD *EVP_dss(void);
652const EVP_MD *EVP_dss1(void); 617const EVP_MD *EVP_dss1(void);
653#ifdef OPENSSL_FIPS 618const EVP_MD *EVP_ecdsa(void);
619#endif
654#ifndef OPENSSL_NO_SHA256 620#ifndef OPENSSL_NO_SHA256
655const EVP_MD *EVP_sha224(void); 621const EVP_MD *EVP_sha224(void);
656const EVP_MD *EVP_sha256(void); 622const EVP_MD *EVP_sha256(void);
@@ -659,8 +625,6 @@ const EVP_MD *EVP_sha256(void);
659const EVP_MD *EVP_sha384(void); 625const EVP_MD *EVP_sha384(void);
660const EVP_MD *EVP_sha512(void); 626const EVP_MD *EVP_sha512(void);
661#endif 627#endif
662#endif
663#endif
664#ifndef OPENSSL_NO_MDC2 628#ifndef OPENSSL_NO_MDC2
665const EVP_MD *EVP_mdc2(void); 629const EVP_MD *EVP_mdc2(void);
666#endif 630#endif
@@ -778,6 +742,37 @@ const EVP_CIPHER *EVP_aes_256_ofb(void);
778const EVP_CIPHER *EVP_aes_256_ctr(void); 742const EVP_CIPHER *EVP_aes_256_ctr(void);
779#endif 743#endif
780#endif 744#endif
745#ifndef OPENSSL_NO_CAMELLIA
746const EVP_CIPHER *EVP_camellia_128_ecb(void);
747const EVP_CIPHER *EVP_camellia_128_cbc(void);
748const EVP_CIPHER *EVP_camellia_128_cfb1(void);
749const EVP_CIPHER *EVP_camellia_128_cfb8(void);
750const EVP_CIPHER *EVP_camellia_128_cfb128(void);
751# define EVP_camellia_128_cfb EVP_camellia_128_cfb128
752const EVP_CIPHER *EVP_camellia_128_ofb(void);
753const EVP_CIPHER *EVP_camellia_192_ecb(void);
754const EVP_CIPHER *EVP_camellia_192_cbc(void);
755const EVP_CIPHER *EVP_camellia_192_cfb1(void);
756const EVP_CIPHER *EVP_camellia_192_cfb8(void);
757const EVP_CIPHER *EVP_camellia_192_cfb128(void);
758# define EVP_camellia_192_cfb EVP_camellia_192_cfb128
759const EVP_CIPHER *EVP_camellia_192_ofb(void);
760const EVP_CIPHER *EVP_camellia_256_ecb(void);
761const EVP_CIPHER *EVP_camellia_256_cbc(void);
762const EVP_CIPHER *EVP_camellia_256_cfb1(void);
763const EVP_CIPHER *EVP_camellia_256_cfb8(void);
764const EVP_CIPHER *EVP_camellia_256_cfb128(void);
765# define EVP_camellia_256_cfb EVP_camellia_256_cfb128
766const EVP_CIPHER *EVP_camellia_256_ofb(void);
767#endif
768
769#ifndef OPENSSL_NO_SEED
770const EVP_CIPHER *EVP_seed_ecb(void);
771const EVP_CIPHER *EVP_seed_cbc(void);
772const EVP_CIPHER *EVP_seed_cfb128(void);
773# define EVP_seed_cfb EVP_seed_cfb128
774const EVP_CIPHER *EVP_seed_ofb(void);
775#endif
781 776
782void OPENSSL_add_all_algorithms_noconf(void); 777void OPENSSL_add_all_algorithms_noconf(void);
783void OPENSSL_add_all_algorithms_conf(void); 778void OPENSSL_add_all_algorithms_conf(void);
@@ -803,10 +798,12 @@ const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
803const EVP_MD *EVP_get_digestbyname(const char *name); 798const EVP_MD *EVP_get_digestbyname(const char *name);
804void EVP_cleanup(void); 799void EVP_cleanup(void);
805 800
806int EVP_PKEY_decrypt(unsigned char *dec_key,unsigned char *enc_key, 801int EVP_PKEY_decrypt(unsigned char *dec_key,
807 int enc_key_len,EVP_PKEY *private_key); 802 const unsigned char *enc_key,int enc_key_len,
803 EVP_PKEY *private_key);
808int EVP_PKEY_encrypt(unsigned char *enc_key, 804int EVP_PKEY_encrypt(unsigned char *enc_key,
809 unsigned char *key,int key_len,EVP_PKEY *pub_key); 805 const unsigned char *key,int key_len,
806 EVP_PKEY *pub_key);
810int EVP_PKEY_type(int type); 807int EVP_PKEY_type(int type);
811int EVP_PKEY_bits(EVP_PKEY *pkey); 808int EVP_PKEY_bits(EVP_PKEY *pkey);
812int EVP_PKEY_size(EVP_PKEY *pkey); 809int EVP_PKEY_size(EVP_PKEY *pkey);
@@ -827,24 +824,31 @@ struct dh_st;
827int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key); 824int EVP_PKEY_set1_DH(EVP_PKEY *pkey,struct dh_st *key);
828struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); 825struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey);
829#endif 826#endif
830 827#ifndef OPENSSL_NO_EC
828struct ec_key_st;
829int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey,struct ec_key_st *key);
830struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey);
831#endif
831 832
832EVP_PKEY * EVP_PKEY_new(void); 833EVP_PKEY * EVP_PKEY_new(void);
833void EVP_PKEY_free(EVP_PKEY *pkey); 834void EVP_PKEY_free(EVP_PKEY *pkey);
834EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, unsigned char **pp, 835
836EVP_PKEY * d2i_PublicKey(int type,EVP_PKEY **a, const unsigned char **pp,
835 long length); 837 long length);
836int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp); 838int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);
837 839
838EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, unsigned char **pp, 840EVP_PKEY * d2i_PrivateKey(int type,EVP_PKEY **a, const unsigned char **pp,
839 long length); 841 long length);
840EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, unsigned char **pp, 842EVP_PKEY * d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp,
841 long length); 843 long length);
842int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp); 844int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);
843 845
844int EVP_PKEY_copy_parameters(EVP_PKEY *to,EVP_PKEY *from); 846int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from);
845int EVP_PKEY_missing_parameters(EVP_PKEY *pkey); 847int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey);
846int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode); 848int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode);
847int EVP_PKEY_cmp_parameters(EVP_PKEY *a,EVP_PKEY *b); 849int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b);
850
851int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b);
848 852
849int EVP_CIPHER_type(const EVP_CIPHER *ctx); 853int EVP_CIPHER_type(const EVP_CIPHER *ctx);
850 854
@@ -861,7 +865,7 @@ int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
861 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, 865 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
862 int en_de); 866 int en_de);
863int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, 867int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
864 unsigned char *salt, int saltlen, int iter, 868 const unsigned char *salt, int saltlen, int iter,
865 int keylen, unsigned char *out); 869 int keylen, unsigned char *out);
866int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, 870int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
867 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, 871 ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
@@ -884,30 +888,32 @@ void ERR_load_EVP_strings(void);
884/* Error codes for the EVP functions. */ 888/* Error codes for the EVP functions. */
885 889
886/* Function codes. */ 890/* Function codes. */
887#define EVP_F_AES_INIT_KEY 129 891#define EVP_F_AES_INIT_KEY 133
892#define EVP_F_CAMELLIA_INIT_KEY 159
888#define EVP_F_D2I_PKEY 100 893#define EVP_F_D2I_PKEY 100
889#define EVP_F_EVP_ADD_CIPHER 130 894#define EVP_F_DSAPKEY2PKCS8 134
890#define EVP_F_EVP_ADD_DIGEST 131 895#define EVP_F_DSA_PKEY2PKCS8 135
891#define EVP_F_EVP_CIPHERINIT 123 896#define EVP_F_ECDSA_PKEY2PKCS8 129
897#define EVP_F_ECKEY_PKEY2PKCS8 132
898#define EVP_F_EVP_CIPHERINIT_EX 123
892#define EVP_F_EVP_CIPHER_CTX_CTRL 124 899#define EVP_F_EVP_CIPHER_CTX_CTRL 124
893#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122 900#define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122
894#define EVP_F_EVP_DECRYPTFINAL 101 901#define EVP_F_EVP_DECRYPTFINAL_EX 101
895#define EVP_F_EVP_DIGESTINIT 128 902#define EVP_F_EVP_DIGESTINIT_EX 128
896#define EVP_F_EVP_ENCRYPTFINAL 127 903#define EVP_F_EVP_ENCRYPTFINAL_EX 127
897#define EVP_F_EVP_GET_CIPHERBYNAME 132 904#define EVP_F_EVP_MD_CTX_COPY_EX 110
898#define EVP_F_EVP_GET_DIGESTBYNAME 133
899#define EVP_F_EVP_MD_CTX_COPY 110
900#define EVP_F_EVP_OPENINIT 102 905#define EVP_F_EVP_OPENINIT 102
901#define EVP_F_EVP_PBE_ALG_ADD 115 906#define EVP_F_EVP_PBE_ALG_ADD 115
902#define EVP_F_EVP_PBE_CIPHERINIT 116 907#define EVP_F_EVP_PBE_CIPHERINIT 116
903#define EVP_F_EVP_PKCS82PKEY 111 908#define EVP_F_EVP_PKCS82PKEY 111
904#define EVP_F_EVP_PKCS8_SET_BROKEN 112 909#define EVP_F_EVP_PKEY2PKCS8_BROKEN 113
905#define EVP_F_EVP_PKEY2PKCS8 113
906#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 910#define EVP_F_EVP_PKEY_COPY_PARAMETERS 103
907#define EVP_F_EVP_PKEY_DECRYPT 104 911#define EVP_F_EVP_PKEY_DECRYPT 104
908#define EVP_F_EVP_PKEY_ENCRYPT 105 912#define EVP_F_EVP_PKEY_ENCRYPT 105
909#define EVP_F_EVP_PKEY_GET1_DH 119 913#define EVP_F_EVP_PKEY_GET1_DH 119
910#define EVP_F_EVP_PKEY_GET1_DSA 120 914#define EVP_F_EVP_PKEY_GET1_DSA 120
915#define EVP_F_EVP_PKEY_GET1_ECDSA 130
916#define EVP_F_EVP_PKEY_GET1_EC_KEY 131
911#define EVP_F_EVP_PKEY_GET1_RSA 121 917#define EVP_F_EVP_PKEY_GET1_RSA 121
912#define EVP_F_EVP_PKEY_NEW 106 918#define EVP_F_EVP_PKEY_NEW 106
913#define EVP_F_EVP_RIJNDAEL 126 919#define EVP_F_EVP_RIJNDAEL 126
@@ -915,28 +921,32 @@ void ERR_load_EVP_strings(void);
915#define EVP_F_EVP_VERIFYFINAL 108 921#define EVP_F_EVP_VERIFYFINAL 108
916#define EVP_F_PKCS5_PBE_KEYIVGEN 117 922#define EVP_F_PKCS5_PBE_KEYIVGEN 117
917#define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118 923#define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118
924#define EVP_F_PKCS8_SET_BROKEN 112
918#define EVP_F_RC2_MAGIC_TO_METH 109 925#define EVP_F_RC2_MAGIC_TO_METH 109
919#define EVP_F_RC5_CTRL 125 926#define EVP_F_RC5_CTRL 125
920 927
921/* Reason codes. */ 928/* Reason codes. */
922#define EVP_R_AES_KEY_SETUP_FAILED 140 929#define EVP_R_AES_KEY_SETUP_FAILED 143
930#define EVP_R_ASN1_LIB 140
923#define EVP_R_BAD_BLOCK_LENGTH 136 931#define EVP_R_BAD_BLOCK_LENGTH 136
924#define EVP_R_BAD_DECRYPT 100 932#define EVP_R_BAD_DECRYPT 100
925#define EVP_R_BAD_KEY_LENGTH 137 933#define EVP_R_BAD_KEY_LENGTH 137
926#define EVP_R_BN_DECODE_ERROR 112 934#define EVP_R_BN_DECODE_ERROR 112
927#define EVP_R_BN_PUBKEY_ERROR 113 935#define EVP_R_BN_PUBKEY_ERROR 113
936#define EVP_R_CAMELLIA_KEY_SETUP_FAILED 157
928#define EVP_R_CIPHER_PARAMETER_ERROR 122 937#define EVP_R_CIPHER_PARAMETER_ERROR 122
929#define EVP_R_CTRL_NOT_IMPLEMENTED 132 938#define EVP_R_CTRL_NOT_IMPLEMENTED 132
930#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133 939#define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133
931#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138 940#define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138
932#define EVP_R_DECODE_ERROR 114 941#define EVP_R_DECODE_ERROR 114
933#define EVP_R_DIFFERENT_KEY_TYPES 101 942#define EVP_R_DIFFERENT_KEY_TYPES 101
934#define EVP_R_DISABLED_FOR_FIPS 141
935#define EVP_R_ENCODE_ERROR 115 943#define EVP_R_ENCODE_ERROR 115
936#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119 944#define EVP_R_EVP_PBE_CIPHERINIT_ERROR 119
937#define EVP_R_EXPECTING_AN_RSA_KEY 127 945#define EVP_R_EXPECTING_AN_RSA_KEY 127
938#define EVP_R_EXPECTING_A_DH_KEY 128 946#define EVP_R_EXPECTING_A_DH_KEY 128
939#define EVP_R_EXPECTING_A_DSA_KEY 129 947#define EVP_R_EXPECTING_A_DSA_KEY 129
948#define EVP_R_EXPECTING_A_ECDSA_KEY 141
949#define EVP_R_EXPECTING_A_EC_KEY 142
940#define EVP_R_INITIALIZATION_ERROR 134 950#define EVP_R_INITIALIZATION_ERROR 134
941#define EVP_R_INPUT_NOT_INITIALIZED 111 951#define EVP_R_INPUT_NOT_INITIALIZED 111
942#define EVP_R_INVALID_KEY_LENGTH 130 952#define EVP_R_INVALID_KEY_LENGTH 130
@@ -961,6 +971,7 @@ void ERR_load_EVP_strings(void);
961#define EVP_R_UNSUPPORTED_SALT_TYPE 126 971#define EVP_R_UNSUPPORTED_SALT_TYPE 126
962#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 972#define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109
963#define EVP_R_WRONG_PUBLIC_KEY_TYPE 110 973#define EVP_R_WRONG_PUBLIC_KEY_TYPE 110
974#define EVP_R_SEED_KEY_SETUP_FAILED 162
964 975
965#ifdef __cplusplus 976#ifdef __cplusplus
966} 977}