Copy and paste error... bn_add_part_words() should of course call
[openssl.git] / crypto / evp / evp.h
index 7db80c3d52376552b0d124c7cb35eccbedf182d4..17a0f306eb9b2857f0c1b2aa5e1a752a1a03709f 100644 (file)
 # undef OPENSSL_ALGORITHM_DEFINES
 #endif
 
+#ifndef NO_BIO
+#include <openssl/bio.h>
+#endif
 #ifndef NO_MD2
 #include <openssl/md2.h>
 #endif
+#ifndef NO_MD4
+#include <openssl/md4.h>
+#endif
 #ifndef NO_MD5
 #include <openssl/md5.h>
 #endif
 #ifndef NO_MDC2
 #include <openssl/mdc2.h>
 #endif
+#ifndef NO_RIJNDAEL
+#include <openssl/rijndael.h>
+#endif
 
 #define EVP_RC2_KEY_SIZE               16
 #define EVP_RC4_KEY_SIZE               16
 #define EVP_CAST5_KEY_SIZE             16
 #define EVP_RC5_32_12_16_KEY_SIZE      16
 #define EVP_MAX_MD_SIZE                        (16+20) /* The SSLv3 md5+sha1 type */
-#define EVP_MAX_KEY_LENGTH             24
-#define EVP_MAX_IV_LENGTH              8
+#define EVP_MAX_KEY_LENGTH             32
+#define EVP_MAX_IV_LENGTH              16
+#define EVP_MAX_BLOCK_LENGTH           32
 
 #define PKCS5_SALT_LEN                 8
 /* Default PKCS#5 iteration count */
@@ -306,6 +316,9 @@ typedef struct env_md_ctx_st
 #ifndef NO_MD5
                MD5_CTX md5;
 #endif
+#ifndef NO_MD4
+               MD4_CTX md4;
+#endif
 #ifndef NO_RIPEMD
                RIPEMD160_CTX ripemd160;
 #endif
@@ -328,8 +341,10 @@ struct evp_cipher_st
        int key_len;            /* Default value for variable length ciphers */
        int iv_len;
        unsigned long flags;    /* Various flags */
-       int (*init)(EVP_CIPHER_CTX *, unsigned char *, unsigned char *, int);   /* init key */
-       int (*do_cipher)(EVP_CIPHER_CTX *, unsigned char *, unsigned char *, unsigned int);/* encrypt/decrypt data */
+       int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key,
+                   const unsigned char *iv, int enc);  /* init key */
+       int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
+                        const unsigned char *in, unsigned int inl);/* encrypt/decrypt data */
        int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
        int ctx_size;           /* how big the ctx needs to be */
        int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */
@@ -382,12 +397,13 @@ struct evp_cipher_ctx_st
 
        unsigned char  oiv[EVP_MAX_IV_LENGTH];  /* original iv */
        unsigned char  iv[EVP_MAX_IV_LENGTH];   /* working iv */
-       unsigned char buf[EVP_MAX_IV_LENGTH];   /* saved partial block */
+       unsigned char buf[EVP_MAX_BLOCK_LENGTH];/* saved partial block */
        int num;                                /* used by cfb/ofb mode */
 
        void *app_data;         /* application stuff */
        int key_len;            /* May change for variable length cipher */
-       union   {
+       union
+               {
 #ifndef NO_RC4
                struct
                        {
@@ -414,22 +430,27 @@ struct evp_cipher_ctx_st
                IDEA_KEY_SCHEDULE idea_ks;/* key schedule */
 #endif
 #ifndef NO_RC2
-               struct {
+               struct
+                       {
                        int key_bits;   /* effective key bits */
                        RC2_KEY ks;/* key schedule */
-               } rc2;
+                       } rc2;
 #endif
 #ifndef NO_RC5
-               struct {
+               struct
+                       {
                        int rounds;     /* number of rounds */
                        RC5_32_KEY ks;/* key schedule */
-               } rc5;
+                       } rc5;
 #endif
 #ifndef NO_BF
                BF_KEY bf_ks;/* key schedule */
 #endif
 #ifndef NO_CAST
                CAST_KEY cast_ks;/* key schedule */
+#endif
+#ifndef NO_RIJNDAEL
+               RIJNDAEL_KEY rijndael;
 #endif
                } c;
        };
@@ -452,12 +473,20 @@ typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
                ASN1_TYPE *param, EVP_CIPHER *cipher,
                 EVP_MD *md, int en_de);
 
+#ifndef NO_RSA
 #define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
                                        (char *)(rsa))
+#endif
+
+#ifndef NO_DSA
 #define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\
                                        (char *)(dsa))
+#endif
+
+#ifndef NO_DH
 #define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\
                                        (char *)(dh))
+#endif
 
 /* Add some extra combinations */
 #define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
@@ -591,7 +620,7 @@ int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
 int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
 int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);
 
-#ifdef HEADER_BIO_H
+#ifndef NO_BIO
 BIO_METHOD *BIO_f_md(void);
 BIO_METHOD *BIO_f_base64(void);
 BIO_METHOD *BIO_f_cipher(void);
@@ -601,16 +630,29 @@ void BIO_set_cipher(BIO *b,const EVP_CIPHER *c,unsigned char *k,
 #endif
 
 EVP_MD *EVP_md_null(void);
+#ifndef NO_MD2
 EVP_MD *EVP_md2(void);
+#endif
+#ifndef NO_MD4
+EVP_MD *EVP_md4(void);
+#endif
+#ifndef NO_MD5
 EVP_MD *EVP_md5(void);
+#endif
+#ifndef NO_SHA
 EVP_MD *EVP_sha(void);
 EVP_MD *EVP_sha1(void);
 EVP_MD *EVP_dss(void);
 EVP_MD *EVP_dss1(void);
+#endif
+#ifndef NO_MDC2
 EVP_MD *EVP_mdc2(void);
+#endif
+#ifndef NO_RIPEMD
 EVP_MD *EVP_ripemd160(void);
-
+#endif
 EVP_CIPHER *EVP_enc_null(void);                /* does nothing :-) */
+#ifndef NO_DES
 EVP_CIPHER *EVP_des_ecb(void);
 EVP_CIPHER *EVP_des_ede(void);
 EVP_CIPHER *EVP_des_ede3(void);
@@ -624,30 +666,46 @@ EVP_CIPHER *EVP_des_cbc(void);
 EVP_CIPHER *EVP_des_ede_cbc(void);
 EVP_CIPHER *EVP_des_ede3_cbc(void);
 EVP_CIPHER *EVP_desx_cbc(void);
+#endif
+#ifndef NO_RC4
 EVP_CIPHER *EVP_rc4(void);
 EVP_CIPHER *EVP_rc4_40(void);
+#endif
+#ifndef NO_IDEA
 EVP_CIPHER *EVP_idea_ecb(void);
 EVP_CIPHER *EVP_idea_cfb(void);
 EVP_CIPHER *EVP_idea_ofb(void);
 EVP_CIPHER *EVP_idea_cbc(void);
+#endif
+#ifndef NO_RC2
 EVP_CIPHER *EVP_rc2_ecb(void);
 EVP_CIPHER *EVP_rc2_cbc(void);
 EVP_CIPHER *EVP_rc2_40_cbc(void);
 EVP_CIPHER *EVP_rc2_64_cbc(void);
 EVP_CIPHER *EVP_rc2_cfb(void);
 EVP_CIPHER *EVP_rc2_ofb(void);
+#endif
+#ifndef NO_BF
 EVP_CIPHER *EVP_bf_ecb(void);
 EVP_CIPHER *EVP_bf_cbc(void);
 EVP_CIPHER *EVP_bf_cfb(void);
 EVP_CIPHER *EVP_bf_ofb(void);
+#endif
+#ifndef NO_CAST
 EVP_CIPHER *EVP_cast5_ecb(void);
 EVP_CIPHER *EVP_cast5_cbc(void);
 EVP_CIPHER *EVP_cast5_cfb(void);
 EVP_CIPHER *EVP_cast5_ofb(void);
+#endif
+#ifndef NO_RC5
 EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);
 EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
 EVP_CIPHER *EVP_rc5_32_12_16_cfb(void);
 EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
+#endif
+#ifndef NO_RIJNDAEL
+EVP_CIPHER *EVP_rijndael_ecb(int nBlockLength,int nKeyLength);
+#endif
 
 void OpenSSL_add_all_algorithms(void);
 void OpenSSL_add_all_ciphers(void);
@@ -756,6 +814,7 @@ void EVP_PBE_cleanup(void);
 #define EVP_F_EVP_PKEY_GET1_DSA                                 120
 #define EVP_F_EVP_PKEY_GET1_RSA                                 121
 #define EVP_F_EVP_PKEY_NEW                              106
+#define EVP_F_EVP_RIJNDAEL                              126
 #define EVP_F_EVP_SIGNFINAL                             107
 #define EVP_F_EVP_VERIFYFINAL                           108
 #define EVP_F_PKCS5_PBE_KEYIVGEN                        117
@@ -764,7 +823,9 @@ void EVP_PBE_cleanup(void);
 #define EVP_F_RC5_CTRL                                  125
 
 /* Reason codes. */
+#define EVP_R_BAD_BLOCK_LENGTH                          136
 #define EVP_R_BAD_DECRYPT                               100
+#define EVP_R_BAD_KEY_LENGTH                            137
 #define EVP_R_BN_DECODE_ERROR                           112
 #define EVP_R_BN_PUBKEY_ERROR                           113
 #define EVP_R_CIPHER_PARAMETER_ERROR                    122