Import of old SSLeay release: SSLeay 0.8.1b
[openssl.git] / crypto / evp / evp.h
1 /* crypto/evp/evp.h */
2 /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
3  * All rights reserved.
4  *
5  * This package is an SSL implementation written
6  * by Eric Young (eay@cryptsoft.com).
7  * The implementation was written so as to conform with Netscapes SSL.
8  * 
9  * This library is free for commercial and non-commercial use as long as
10  * the following conditions are aheared to.  The following conditions
11  * apply to all code found in this distribution, be it the RC4, RSA,
12  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13  * included with this distribution is covered by the same copyright terms
14  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15  * 
16  * Copyright remains Eric Young's, and as such any Copyright notices in
17  * the code are not to be removed.
18  * If this package is used in a product, Eric Young should be given attribution
19  * as the author of the parts of the library used.
20  * This can be in the form of a textual message at program startup or
21  * in documentation (online or textual) provided with the package.
22  * 
23  * Redistribution and use in source and binary forms, with or without
24  * modification, are permitted provided that the following conditions
25  * are met:
26  * 1. Redistributions of source code must retain the copyright
27  *    notice, this list of conditions and the following disclaimer.
28  * 2. Redistributions in binary form must reproduce the above copyright
29  *    notice, this list of conditions and the following disclaimer in the
30  *    documentation and/or other materials provided with the distribution.
31  * 3. All advertising materials mentioning features or use of this software
32  *    must display the following acknowledgement:
33  *    "This product includes cryptographic software written by
34  *     Eric Young (eay@cryptsoft.com)"
35  *    The word 'cryptographic' can be left out if the rouines from the library
36  *    being used are not cryptographic related :-).
37  * 4. If you include any Windows specific code (or a derivative thereof) from 
38  *    the apps directory (application code) you must include an acknowledgement:
39  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40  * 
41  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  * 
53  * The licence and distribution terms for any publically available version or
54  * derivative of this code cannot be changed.  i.e. this code cannot simply be
55  * copied and put under another distribution licence
56  * [including the GNU Public Licence.]
57  */
58
59 #ifndef HEADER_ENVELOPE_H
60 #define HEADER_ENVELOPE_H
61
62 #ifdef  __cplusplus
63 extern "C" {
64 #endif
65
66 #ifndef NO_MD2
67 #include "md2.h"
68 #endif
69 #ifndef NO_MD5
70 #include "md5.h"
71 #endif
72 #if !defined(NO_SHA) || !defined(NO_SHA1)
73 #include "sha.h"
74 #endif
75 #ifndef NO_DES
76 #include "des.h"
77 #endif
78 #ifndef NO_RC4
79 #include "rc4.h"
80 #endif
81 #ifndef NO_RC2
82 #include "rc2.h"
83 #endif
84 #ifndef NO_BLOWFISH
85 #include "blowfish.h"
86 #endif
87 #ifndef NO_IDEA
88 #include "idea.h"
89 #endif
90 #ifndef NO_MDC2
91 #include "mdc2.h"
92 #endif
93
94 #define EVP_RC2_KEY_SIZE        16
95 #define EVP_RC4_KEY_SIZE        16
96 #define EVP_BLOWFISH_KEY_SIZE   16
97 #define EVP_MAX_MD_SIZE         20
98 #define EVP_MAX_KEY_LENGTH      24
99 #define EVP_MAX_IV_LENGTH       8
100
101 #ifndef NO_RSA
102 #include "rsa.h"
103 #else
104 #define RSA     long
105 #endif
106
107 #ifndef NO_DSA
108 #include "dsa.h"
109 #else
110 #define DSA     long
111 #endif
112
113 #ifndef NO_DH
114 #include "dh.h"
115 #else
116 #define DH      long
117 #endif
118
119 #include "objects.h"
120
121 #define EVP_PK_RSA      0x0001
122 #define EVP_PK_DSA      0x0002
123 #define EVP_PK_DH       0x0004
124 #define EVP_PKT_SIGN    0x0010
125 #define EVP_PKT_ENC     0x0020
126 #define EVP_PKT_EXCH    0x0040
127 #define EVP_PKS_RSA     0x0100
128 #define EVP_PKS_DSA     0x0200
129 #define EVP_PKT_EXP     0x1000 /* <= 512 bit key */
130
131 #define EVP_PKEY_NONE   NID_undef
132 #define EVP_PKEY_RSA    NID_rsaEncryption
133 #define EVP_PKEY_RSA2   NID_rsa
134 #define EVP_PKEY_DSA    NID_dsa
135 #define EVP_PKEY_DSA2   NID_dsaWithSHA
136 #define EVP_PKEY_DSA3   NID_dsaWithSHA1
137 #define EVP_PKEY_DH     NID_dhKeyAgreement
138
139 typedef struct evp_pkey_st
140         {
141         int type;
142         int save_type;
143         int references;
144         union   {
145                 char *ptr;
146                 struct rsa_st *rsa;     /* RSA */
147                 struct dsa_st *dsa;     /* DSA */
148                 struct dh_st *dh;       /* DH */
149                 } pkey;
150         int save_parameters;
151 #ifdef HEADER_STACK_H
152         STACK /* X509_ATTRIBUTE */ *attributes; /* [ 0 ] */
153 #else
154         char /* X509_ATTRIBUTE */ *attributes; /* [ 0 ] */
155 #endif
156         } EVP_PKEY;
157
158 #ifndef EVP_MD
159 typedef struct env_md_st
160         {
161         int type;
162         int pkey_type;
163         int md_size;
164         void (*init)();
165         void (*update)();
166         void (*final)();
167
168         int (*sign)();
169         int (*verify)();
170         int required_pkey_type[4]; /*EVP_PKEY_xxx */
171         } EVP_MD;
172
173 #define EVP_PKEY_NULL_method    NULL,NULL,{0,0,0,0}
174
175 #ifndef NO_DSA
176 #define EVP_PKEY_DSA_method     DSA_sign,DSA_verify, \
177                                 {EVP_PKEY_DSA,EVP_PKEY_DSA2,EVP_PKEY_DSA3,0}
178 #else
179 #define EVP_PKEY_DSA_method     EVP_PKEY_NULL_method
180 #endif
181
182 #ifndef NO_RSA
183 #define EVP_PKEY_RSA_method     RSA_sign,RSA_verify, \
184                                 {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}
185 #define EVP_PKEY_RSA_ASN1_OCTET_STRING_method \
186                                 RSA_sign_ASN1_OCTET_STRING, \
187                                 RSA_verify_ASN1_OCTET_STRING, \
188                                 {EVP_PKEY_RSA,EVP_PKEY_RSA2,0,0}
189 #else
190 #define EVP_PKEY_RSA_method     EVP_PKEY_NULL_method
191 #define EVP_PKEY_RSA_ASN1_OCTET_STRING_method EVP_PKEY_NULL_method
192 #endif
193
194 #endif /* !EVP_MD */
195
196 typedef struct env_md_ctx_st
197         {
198         EVP_MD *digest;
199         union   {
200                 unsigned char base[4];
201 #ifndef NO_MD2
202                 MD2_CTX md2;
203 #endif
204 #ifndef NO_MD5
205                 MD5_CTX md5;
206 #endif
207 #if !defined(NO_SHA) || !defined(NO_SHA1)
208                 SHA_CTX sha;
209 #endif
210 #ifndef NO_MDC2
211                 MDC2_CTX mdc2;
212 #endif
213                 } md;
214         } EVP_MD_CTX;
215
216 typedef struct evp_cipher_st
217         {
218         int nid;
219         int block_size;
220         int key_len;
221         int iv_len;
222         void (*init)();         /* init for encryption */
223         void (*do_cipher)();    /* encrypt data */
224         void (*cleanup)();      /* used by cipher method */ 
225         } EVP_CIPHER;
226
227 typedef struct evp_cipher_info_st
228         {
229         EVP_CIPHER *cipher;
230         unsigned char iv[EVP_MAX_IV_LENGTH];
231         } EVP_CIPHER_INFO;
232
233 typedef struct evp_cipher_ctx_st
234         {
235         EVP_CIPHER *cipher;
236         int encrypt;            /* encrypt or decrypt */
237         int buf_len;            /* number we have left */
238         unsigned char buf[8];
239         char *app_data;         /* aplication stuff */
240         union   {
241 #ifndef NO_RC4
242                 struct
243                         {
244                         unsigned char key[EVP_RC4_KEY_SIZE];
245                         RC4_KEY ks;     /* working key */
246                         } rc4;
247 #endif
248 #ifndef NO_DES
249                 struct
250                         {
251                         des_key_schedule ks;/* key schedule */
252                         } des_ecb;
253
254                 struct
255                         {
256                         C_Block oiv;    /* original iv */
257                         C_Block iv;     /* working iv */
258                         des_key_schedule ks;/* key schedule */
259                         } des_cbc;
260
261                 struct
262                         {
263                         C_Block oiv;    /* original iv */
264                         C_Block iv;     /* working iv */
265                         C_Block inw;
266                         C_Block outw;
267                         des_key_schedule ks;/* key schedule */
268                         } desx_cbc;
269
270                 struct
271                         {
272                         C_Block oiv;    /* original iv */
273                         C_Block iv;     /* working iv */
274                         des_key_schedule ks;/* key schedule */
275                         des_key_schedule ks2;/* key schedule (for ede) */
276                         des_key_schedule ks3;/* key schedule (for ede3) */
277                         int num;        /* used by cfb mode */
278                         } des_cfb;
279
280                 struct
281                         {
282                         C_Block oiv;    /* original iv */
283                         C_Block iv;     /* working iv */
284                         des_key_schedule ks1;/* ksched 1 */
285                         des_key_schedule ks2;/* ksched 2 */
286                         des_key_schedule ks3;/* ksched 3 */
287                         } des_ede;
288 #endif
289 #ifndef NO_IDEA
290                 struct
291                         {
292                         IDEA_KEY_SCHEDULE ks;/* key schedule */
293                         } idea_ecb;
294                 struct
295                         {
296                         unsigned char oiv[8];/* original iv */
297                         unsigned char iv[8]; /* working iv */
298                         IDEA_KEY_SCHEDULE ks;/* key schedule */
299                         } idea_cbc;
300                 struct
301                         {
302                         unsigned char oiv[8];/* original iv */
303                         unsigned char iv[8]; /* working iv */
304                         IDEA_KEY_SCHEDULE ks;/* key schedule */
305                         int num;        /* used by cfb mode */
306                         } idea_cfb;
307 #endif
308 #ifndef NO_RC2
309                 struct
310                         {
311                         RC2_KEY ks;/* key schedule */
312                         } rc2_ecb;
313                 struct
314                         {
315                         unsigned char oiv[8];/* original iv */
316                         unsigned char iv[8]; /* working iv */
317                         RC2_KEY ks;/* key schedule */
318                         } rc2_cbc;
319                 struct
320                         {
321                         unsigned char oiv[8];/* original iv */
322                         unsigned char iv[8]; /* working iv */
323                         RC2_KEY ks;/* key schedule */
324                         int num;        /* used by cfb mode */
325                         } rc2_cfb;
326 #endif
327 #ifndef NO_BLOWFISH
328                 struct
329                         {
330                         BF_KEY ks;/* key schedule */
331                         } bf_ecb;
332                 struct
333                         {
334                         unsigned char oiv[8];/* original iv */
335                         unsigned char iv[8]; /* working iv */
336                         BF_KEY ks;/* key schedule */
337                         } bf_cbc;
338                 struct
339                         {
340                         unsigned char oiv[8];/* original iv */
341                         unsigned char iv[8]; /* working iv */
342                         BF_KEY ks;/* key schedule */
343                         int num;        /* used by cfb mode */
344                         } bf_cfb;
345 #endif
346                 } c;
347         } EVP_CIPHER_CTX;
348
349 typedef struct evp_Encode_Ctx_st
350         {
351         int num;        /* number saved in a partial encode/decode */
352         int length;     /* The length is either the output line length
353                          * (in input bytes) or the shortest input line
354                          * length that is ok.  Once decoding begins,
355                          * the length is adjusted up each time a longer
356                          * line is decoded */
357         unsigned char enc_data[80];     /* data to encode */
358         int line_num;   /* number read on current line */
359         } EVP_ENCODE_CTX;
360
361 #define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
362                                         (char *)(rsa))
363 #define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
364                                         (char *)(dsa))
365 #define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\
366                                         (char *)(dh))
367
368 /* Add some extra combinations */
369 #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
370 #define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a))
371 #define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a))
372 #define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
373
374 #define EVP_MD_type(e)                  ((e)->type)
375 #define EVP_MD_pkey_type(e)             ((e)->pkey_type)
376 #define EVP_MD_size(e)                  ((e)->md_size)
377 #define EVP_MD_CTX_size(e)              ((e)->digest->md_size)
378 #define EVP_MD_CTX_type(e)              ((e)->digest)
379
380 #define EVP_CIPHER_nid(e)               ((e)->nid)
381 #define EVP_CIPHER_block_size(e)        ((e)->block_size)
382 #define EVP_CIPHER_key_length(e)        ((e)->key_len)
383 #define EVP_CIPHER_iv_length(e)         ((e)->iv_len)
384
385 #define EVP_CIPHER_CTX_cipher(e)        ((e)->cipher)
386 #define EVP_CIPHER_CTX_nid(e)           ((e)->cipher->nid)
387 #define EVP_CIPHER_CTX_block_size(e)    ((e)->cipher->block_size)
388 #define EVP_CIPHER_CTX_key_length(e)    ((e)->cipher->key_len)
389 #define EVP_CIPHER_CTX_iv_length(e)     ((e)->cipher->iv_len)
390 #define EVP_CIPHER_CTX_get_app_data(e)  ((e)->app_data)
391 #define EVP_CIPHER_CTX_set_app_data(e,d) ((e)->app_data=(char *)(d))
392
393 #define EVP_ENCODE_LENGTH(l)    (((l+2)/3*4)+(l/48+1)*2+80)
394 #define EVP_DECODE_LENGTH(l)    ((l+3)/4*3+80)
395
396 #define EVP_SignInit(a,b)               EVP_DigestInit(a,b)
397 #define EVP_SignUpdate(a,b,c)           EVP_DigestUpdate(a,b,c)
398 #define EVP_VerifyInit(a,b)             EVP_DigestInit(a,b)
399 #define EVP_VerifyUpdate(a,b,c)         EVP_DigestUpdate(a,b,c)
400 #define EVP_OpenUpdate(a,b,c,d,e)       EVP_DecryptUpdate(a,b,c,d,e)
401 #define EVP_SealUpdate(a,b,c,d,e)       EVP_EncryptUpdate(a,b,c,d,e)    
402
403 #define BIO_set_md(b,md)                BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md)
404 #define BIO_get_md(b,mdp)               BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp)
405 #define BIO_get_md_ctx(b,mdcp)     BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp)
406 #define BIO_get_cipher_status(b)        BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL)
407
408 #define EVP_Cipher(c,o,i,l)     (c)->cipher->do_cipher((c),(o),(i),(l))
409
410 #ifndef NOPROTO
411
412 void    EVP_DigestInit(EVP_MD_CTX *ctx, EVP_MD *type);
413 void    EVP_DigestUpdate(EVP_MD_CTX *ctx,unsigned char *d,unsigned int cnt);
414 void    EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
415
416 int     EVP_read_pw_string(char *buf,int length,char *prompt,int verify);
417 void    EVP_set_pw_prompt(char *prompt);
418 char *  EVP_get_pw_prompt(void);
419
420 int     EVP_BytesToKey(EVP_CIPHER *type,EVP_MD *md,unsigned char *salt,
421                 unsigned char *data, int datal, int count,
422                 unsigned char *key,unsigned char *iv);
423
424 EVP_CIPHER *EVP_get_cipherbyname(char *name);
425
426 void    EVP_EncryptInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type,
427                 unsigned char *key, unsigned char *iv);
428 void    EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
429                 int *outl, unsigned char *in, int inl);
430 void    EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
431
432 void    EVP_DecryptInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type,
433                 unsigned char *key, unsigned char *iv);
434 void    EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
435                 int *outl, unsigned char *in, int inl);
436 int     EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
437
438 void    EVP_CipherInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type, unsigned char *key,
439                 unsigned char *iv,int enc);
440 void    EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
441                 int *outl, unsigned char *in, int inl);
442 int     EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
443
444 int     EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s,
445                 EVP_PKEY *pkey);
446
447 int     EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf,
448                 unsigned int siglen,EVP_PKEY *pkey);
449
450 int     EVP_OpenInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type,unsigned char *ek,
451                 int ekl,unsigned char *iv,EVP_PKEY *priv);
452 int     EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
453
454 int     EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek,
455                 int *ekl, unsigned char *iv,EVP_PKEY **pubk, int npubk);
456 void    EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl);
457
458 void    EVP_EncodeInit(EVP_ENCODE_CTX *ctx);
459 void    EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,
460                 int *outl,unsigned char *in,int inl);
461 void    EVP_EncodeFinal(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl);
462 int     EVP_EncodeBlock(unsigned char *t, unsigned char *f, int n);
463
464 void    EVP_DecodeInit(EVP_ENCODE_CTX *ctx);
465 int     EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx,unsigned char *out,int *outl,
466                 unsigned char *in, int inl);
467 int     EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
468                 char *out, int *outl);
469 int     EVP_DecodeBlock(unsigned char *t, unsigned
470                 char *f, int n);
471
472 void    ERR_load_EVP_strings(void );
473
474 void EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
475
476 #ifdef HEADER_BIO_H
477 BIO_METHOD *BIO_f_md(void);
478 BIO_METHOD *BIO_f_base64(void);
479 BIO_METHOD *BIO_f_cipher(void);
480 void BIO_set_cipher(BIO *b,EVP_CIPHER *c,unsigned char *k,
481         unsigned char *i, int enc);
482 #endif
483
484 EVP_MD *EVP_md_null(void);
485 EVP_MD *EVP_md2(void);
486 EVP_MD *EVP_md5(void);
487 EVP_MD *EVP_sha(void);
488 EVP_MD *EVP_sha1(void);
489 EVP_MD *EVP_dss(void);
490 EVP_MD *EVP_dss1(void);
491 EVP_MD *EVP_mdc2(void);
492
493 EVP_CIPHER *EVP_enc_null(void);         /* does nothing :-) */
494 EVP_CIPHER *EVP_des_ecb(void);
495 EVP_CIPHER *EVP_des_ede(void);
496 EVP_CIPHER *EVP_des_ede3(void);
497 EVP_CIPHER *EVP_des_cfb(void);
498 EVP_CIPHER *EVP_des_ede_cfb(void);
499 EVP_CIPHER *EVP_des_ede3_cfb(void);
500 EVP_CIPHER *EVP_des_ofb(void);
501 EVP_CIPHER *EVP_des_ede_ofb(void);
502 EVP_CIPHER *EVP_des_ede3_ofb(void);
503 EVP_CIPHER *EVP_des_cbc(void);
504 EVP_CIPHER *EVP_des_ede_cbc(void);
505 EVP_CIPHER *EVP_des_ede3_cbc(void);
506 EVP_CIPHER *EVP_desx_cbc(void);
507 EVP_CIPHER *EVP_rc4(void);
508 EVP_CIPHER *EVP_idea_ecb(void);
509 EVP_CIPHER *EVP_idea_cfb(void);
510 EVP_CIPHER *EVP_idea_ofb(void);
511 EVP_CIPHER *EVP_idea_cbc(void);
512 EVP_CIPHER *EVP_rc2_ecb(void);
513 EVP_CIPHER *EVP_rc2_cbc(void);
514 EVP_CIPHER *EVP_rc2_cfb(void);
515 EVP_CIPHER *EVP_rc2_ofb(void);
516 EVP_CIPHER *EVP_bf_ecb(void);
517 EVP_CIPHER *EVP_bf_cbc(void);
518 EVP_CIPHER *EVP_bf_cfb(void);
519 EVP_CIPHER *EVP_bf_ofb(void);
520
521 void SSLeay_add_all_algorithms(void);
522 void SSLeay_add_all_ciphers(void);
523 void SSLeay_add_all_digests(void);
524
525 int EVP_add_cipher(EVP_CIPHER *cipher);
526 int EVP_add_digest(EVP_MD *digest);
527 int EVP_add_alias(char *name,char *alias);
528 int EVP_delete_alias(char *name);
529
530 EVP_CIPHER *EVP_get_cipherbyname(char *name);
531 EVP_MD *EVP_get_digestbyname(char *name);
532 void EVP_cleanup(void);
533
534 int             EVP_PKEY_type(int type);
535 int             EVP_PKEY_size(EVP_PKEY *pkey);
536 int             EVP_PKEY_assign(EVP_PKEY *pkey,int type,char *key);
537 EVP_PKEY *      EVP_PKEY_new(void);
538 void            EVP_PKEY_free(EVP_PKEY *pkey);
539 EVP_PKEY *      d2i_PublicKey(int type,EVP_PKEY **a, unsigned char **pp,
540                         long length);
541 int             i2d_PublicKey(EVP_PKEY *a, unsigned char **pp);
542
543 EVP_PKEY *      d2i_PrivateKey(int type,EVP_PKEY **a, unsigned char **pp,
544                         long length);
545 int             i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp);
546
547 int EVP_PKEY_copy_parameters(EVP_PKEY *to,EVP_PKEY *from);
548 int EVP_PKEY_missing_parameters(EVP_PKEY *pkey);
549 int EVP_PKEY_save_parameters(EVP_PKEY *pkey,int mode);
550
551 #else
552
553 void    EVP_DigestInit();
554 void    EVP_DigestUpdate();
555 void    EVP_DigestFinal();
556
557 int     EVP_read_pw_string();
558 void    EVP_set_pw_prompt();
559 char *  EVP_get_pw_prompt();
560
561 int     EVP_BytesToKey();
562
563 EVP_CIPHER *EVP_get_cipherbyname();
564
565 void    EVP_EncryptInit();
566 void    EVP_EncryptUpdate();
567 void    EVP_EncryptFinal();
568
569 void    EVP_DecryptInit();
570 void    EVP_DecryptUpdate();
571 int     EVP_DecryptFinal();
572
573 void    EVP_CipherInit();
574 void    EVP_CipherUpdate();
575 int     EVP_CipherFinal();
576
577 int     EVP_SignFinal();
578
579 int     EVP_VerifyFinal();
580
581 int     EVP_OpenInit();
582 int     EVP_OpenFinal();
583
584 int     EVP_SealInit();
585 void    EVP_SealFinal();
586
587 void    EVP_EncodeInit();
588 void    EVP_EncodeUpdate();
589 void    EVP_EncodeFinal();
590 int     EVP_EncodeBlock();
591
592 void    EVP_DecodeInit();
593 int     EVP_DecodeUpdate();
594 int     EVP_DecodeFinal();
595 int     EVP_DecodeBlock();
596
597 void    ERR_load_EVP_strings();
598
599 void EVP_CIPHER_CTX_cleanup();
600
601 #ifdef HEADER_BIO_H
602 BIO_METHOD *BIO_f_md();
603 BIO_METHOD *BIO_f_base64();
604 BIO_METHOD *BIO_f_cipher();
605 void BIO_set_cipher();
606 #endif
607
608 EVP_MD *EVP_md_null();
609 EVP_MD *EVP_md2();
610 EVP_MD *EVP_md5();
611 EVP_MD *EVP_sha();
612 EVP_MD *EVP_sha1();
613 EVP_MD *EVP_dss();
614 EVP_MD *EVP_dss1();
615 EVP_MD *EVP_mdc2();
616
617 EVP_CIPHER *EVP_enc_null();
618 EVP_CIPHER *EVP_des_ecb();
619 EVP_CIPHER *EVP_des_ede();
620 EVP_CIPHER *EVP_des_ede3();
621 EVP_CIPHER *EVP_des_cfb();
622 EVP_CIPHER *EVP_des_ede_cfb();
623 EVP_CIPHER *EVP_des_ede3_cfb();
624 EVP_CIPHER *EVP_des_ofb();
625 EVP_CIPHER *EVP_des_ede_ofb();
626 EVP_CIPHER *EVP_des_ede3_ofb();
627 EVP_CIPHER *EVP_des_cbc();
628 EVP_CIPHER *EVP_des_ede_cbc();
629 EVP_CIPHER *EVP_des_ede3_cbc();
630 EVP_CIPHER *EVP_desx_cbc();
631 EVP_CIPHER *EVP_rc4();
632 EVP_CIPHER *EVP_idea_ecb();
633 EVP_CIPHER *EVP_idea_cfb();
634 EVP_CIPHER *EVP_idea_ofb();
635 EVP_CIPHER *EVP_idea_cbc();
636 EVP_CIPHER *EVP_rc2_ecb();
637 EVP_CIPHER *EVP_rc2_cbc();
638 EVP_CIPHER *EVP_rc2_cfb();
639 EVP_CIPHER *EVP_rc2_ofb();
640 EVP_CIPHER *EVP_bf_ecb();
641 EVP_CIPHER *EVP_bf_cbc();
642 EVP_CIPHER *EVP_bf_cfb();
643 EVP_CIPHER *EVP_bf_ofb();
644
645 void SSLeay_add_all_algorithms();
646 void SSLeay_add_all_ciphers();
647 void SSLeay_add_all_digests();
648
649 int EVP_add_cipher();
650 int EVP_add_digest();
651 int EVP_add_alias();
652 int EVP_delete_alias();
653
654 EVP_CIPHER *EVP_get_cipherbyname();
655 EVP_MD *EVP_get_digestbyname();
656 void EVP_cleanup();
657
658 int             EVP_PKEY_type();
659 int             EVP_PKEY_size();
660 int             EVP_PKEY_assign();
661 EVP_PKEY *      EVP_PKEY_new();
662 void            EVP_PKEY_free();
663 EVP_PKEY *      d2i_PublicKey();
664 int             i2d_PublicKey();
665
666 EVP_PKEY *      d2i_PrivateKey();
667 int             i2d_PrivateKey();
668
669 int EVP_PKEY_copy_parameters();
670 int EVP_PKEY_missing_parameters();
671 int EVP_PKEY_save_parameters();
672
673 #endif
674
675 /* BEGIN ERROR CODES */
676 /* Error codes for the EVP functions. */
677
678 /* Function codes. */
679 #define EVP_F_D2I_PKEY                                   100
680 #define EVP_F_EVP_DECRYPTFINAL                           101
681 #define EVP_F_EVP_OPENINIT                               102
682 #define EVP_F_EVP_PKEY_COPY_PARAMETERS                   103
683 #define EVP_F_EVP_PKEY_NEW                               104
684 #define EVP_F_EVP_SEALINIT                               105
685 #define EVP_F_EVP_SIGNFINAL                              106
686 #define EVP_F_EVP_VERIFYFINAL                            107
687
688 /* Reason codes. */
689 #define EVP_R_BAD_DECRYPT                                100
690 #define EVP_R_DIFFERENT_KEY_TYPES                        101
691 #define EVP_R_IV_TOO_LARGE                               102
692 #define EVP_R_MISSING_PARMATERS                          103
693 #define EVP_R_NO_SIGN_FUNCTION_CONFIGURED                104
694 #define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED              105
695 #define EVP_R_PUBLIC_KEY_NOT_RSA                         106
696 #define EVP_R_UNSUPPORTED_CIPHER                         107
697 #define EVP_R_WRONG_FINAL_BLOCK_LENGTH                   108
698 #define EVP_R_WRONG_PUBLIC_KEY_TYPE                      109
699  
700 #ifdef  __cplusplus
701 }
702 #endif
703 #endif
704