remove redundant ERR_load_... declarations
[openssl.git] / crypto / evp / evp.h
index ef77db499e4fdc1e844419ab82627f95ced7966b..8d86d85f8d988dd8eddcfbc0635eb98fe5d9b97a 100644 (file)
@@ -67,7 +67,7 @@
 # undef OPENSSL_ALGORITHM_DEFINES
 #endif
 
-#include <openssl/types.h>
+#include <openssl/ossl_typ.h>
 
 #ifndef OPENSSL_NO_BIO
 #include <openssl/bio.h>
@@ -217,10 +217,14 @@ struct env_md_st
        int type;
        int pkey_type;
        int md_size;
-       int (*init)();
-       int (*update)();
-       int (*final)();
-
+       unsigned long flags;
+       int (*init)(EVP_MD_CTX *ctx);
+       int (*update)(EVP_MD_CTX *ctx,const void *data,unsigned long count);
+       int (*final)(EVP_MD_CTX *ctx,unsigned char *md);
+       int (*copy)(EVP_MD_CTX *to,const EVP_MD_CTX *from);
+       int (*cleanup)(EVP_MD_CTX *ctx);
+
+       /* FIXME: prototype these some day */
        int (*sign)();
        int (*verify)();
        int required_pkey_type[5]; /*EVP_PKEY_xxx */
@@ -228,7 +232,8 @@ struct env_md_st
        int ctx_size; /* how big does the ctx->md_data need to be */
        } /* EVP_MD */;
 
-
+#define EVP_MD_FLAG_ONESHOT    0x0001 /* digest can only handle a single
+                                       * block */
 
 #define EVP_PKEY_NULL_method   NULL,NULL,{0,0,0,0}
 
@@ -254,11 +259,20 @@ struct env_md_st
 
 #endif /* !EVP_MD */
 
-typedef struct env_md_ctx_st
+struct env_md_ctx_st
        {
        const EVP_MD *digest;
+       ENGINE *engine; /* functional reference if 'digest' is ENGINE-provided */
+       unsigned long flags;
        void *md_data;
-       } EVP_MD_CTX;
+       } /* EVP_MD_CTX */;
+
+/* values for EVP_MD_CTX flags */
+
+#define EVP_MD_CTX_FLAG_ONESHOT                0x0001 /* digest update will be called
+                                               * once only */
+#define EVP_MD_CTX_FLAG_CLEANED                0x0002 /* context has already been
+                                               * cleaned */
 
 struct evp_cipher_st
        {
@@ -320,6 +334,7 @@ typedef struct evp_cipher_info_st
 struct evp_cipher_ctx_st
        {
        const EVP_CIPHER *cipher;
+       ENGINE *engine; /* functional reference if 'cipher' is ENGINE-provided */
        int encrypt;            /* encrypt or decrypt */
        int buf_len;            /* number we have left */
 
@@ -410,8 +425,10 @@ typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
 #define EVP_ENCODE_LENGTH(l)   (((l+2)/3*4)+(l/48+1)*2+80)
 #define EVP_DECODE_LENGTH(l)   ((l+3)/4*3+80)
 
+#define EVP_SignInit_ex(a,b,c)         EVP_DigestInit_ex(a,b,c)
 #define EVP_SignInit(a,b)              EVP_DigestInit(a,b)
 #define EVP_SignUpdate(a,b,c)          EVP_DigestUpdate(a,b,c)
+#define        EVP_VerifyInit_ex(a,b,c)        EVP_DigestInit_ex(a,b,c)
 #define        EVP_VerifyInit(a,b)             EVP_DigestInit(a,b)
 #define        EVP_VerifyUpdate(a,b,c)         EVP_DigestUpdate(a,b,c)
 #define EVP_OpenUpdate(a,b,c,d,e)      EVP_DecryptUpdate(a,b,c,d,e)
@@ -442,19 +459,20 @@ void      EVP_MD_CTX_init(EVP_MD_CTX *ctx);
 int    EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx);
 EVP_MD_CTX *EVP_MD_CTX_create(void);
 void   EVP_MD_CTX_destroy(EVP_MD_CTX *ctx);
-int     EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in);  
-#ifdef CRYPTO_MDEBUG
-int    EVP_DigestInit_dbg(EVP_MD_CTX *ctx, const EVP_MD *type,
-                          const char *file,int line);
-#define EVP_DigestInit(ctx,type) EVP_DigestInit_dbg(ctx,type,__FILE__,__LINE__)
-#else
-int    EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
-#endif
+int     EVP_MD_CTX_copy_ex(EVP_MD_CTX *out,const EVP_MD_CTX *in);  
+#define EVP_MD_CTX_set_flags(ctx,flgs) ((ctx)->flags|=(flgs))
+#define EVP_MD_CTX_clear_flags(ctx,flgs) ((ctx)->flags&=~(flgs))
+#define EVP_MD_CTX_test_flags(ctx,flgs) ((ctx)->flags&(flgs))
+int    EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl);
 int    EVP_DigestUpdate(EVP_MD_CTX *ctx,const void *d,
                         unsigned int cnt);
-int    EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
+int    EVP_DigestFinal_ex(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
 int    EVP_Digest(void *data, unsigned int count,
-               unsigned char *md, unsigned int *size, const EVP_MD *type);
+               unsigned char *md, unsigned int *size, const EVP_MD *type, ENGINE *impl);
+
+int     EVP_MD_CTX_copy(EVP_MD_CTX *out,const EVP_MD_CTX *in);  
+int    EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
+int    EVP_DigestFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s);
 
 int    EVP_read_pw_string(char *buf,int length,const char *prompt,int verify);
 void   EVP_set_pw_prompt(char *prompt);
@@ -464,24 +482,34 @@ int       EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md,
                const unsigned char *salt, const unsigned char *data,
                int datal, int count, unsigned char *key,unsigned char *iv);
 
-int    EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type,
+int    EVP_EncryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
+               const unsigned char *key, const unsigned char *iv);
+int    EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
                const unsigned char *key, const unsigned char *iv);
 int    EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
                int *outl, const unsigned char *in, int inl);
+int    EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
 int    EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
 
-int    EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type,
+int    EVP_DecryptInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
+               const unsigned char *key, const unsigned char *iv);
+int    EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
                const unsigned char *key, const unsigned char *iv);
 int    EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
                int *outl, const unsigned char *in, int inl);
 int    EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
+int    EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
 
-int    EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type,
+int    EVP_CipherInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher,
+                      const unsigned char *key,const unsigned char *iv,
+                      int enc);
+int    EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
                       const unsigned char *key,const unsigned char *iv,
                       int enc);
 int    EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out,
                int *outl, const unsigned char *in, int inl);
 int    EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
+int    EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, int *outl);
 
 int    EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s,
                EVP_PKEY *pkey);
@@ -489,11 +517,11 @@ int       EVP_SignFinal(EVP_MD_CTX *ctx,unsigned char *md,unsigned int *s,
 int    EVP_VerifyFinal(EVP_MD_CTX *ctx,unsigned char *sigbuf,
                unsigned int siglen,EVP_PKEY *pkey);
 
-int    EVP_OpenInit(EVP_CIPHER_CTX *ctx,EVP_CIPHER *type,unsigned char *ek,
+int    EVP_OpenInit(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *type,unsigned char *ek,
                int ekl,unsigned char *iv,EVP_PKEY *priv);
 int    EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl);
 
-int    EVP_SealInit(EVP_CIPHER_CTX *ctx, EVP_CIPHER *type, unsigned char **ek,
+int    EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, unsigned char **ek,
                int *ekl, unsigned char *iv,EVP_PKEY **pubk, int npubk);
 void   EVP_SealFinal(EVP_CIPHER_CTX *ctx,unsigned char *out,int *outl);
 
@@ -510,8 +538,6 @@ int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned
                char *out, int *outl);
 int    EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n);
 
-void   ERR_load_EVP_strings(void );
-
 void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *a);
 int EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *a);
 int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen);
@@ -564,12 +590,16 @@ const EVP_CIPHER *EVP_des_cbc(void);
 const EVP_CIPHER *EVP_des_ede_cbc(void);
 const EVP_CIPHER *EVP_des_ede3_cbc(void);
 const EVP_CIPHER *EVP_desx_cbc(void);
+/* This should now be supported through the dev_crypto ENGINE. But also, why are
+ * rc4 and md5 declarations made here inside a "NO_DES" precompiler branch? */
+#if 0
 # ifdef OPENSSL_OPENBSD_DEV_CRYPTO
 const EVP_CIPHER *EVP_dev_crypto_des_ede3_cbc(void);
 const EVP_CIPHER *EVP_dev_crypto_rc4(void);
 const EVP_MD *EVP_dev_crypto_md5(void);
 # endif
 #endif
+#endif
 #ifndef OPENSSL_NO_RC4
 const EVP_CIPHER *EVP_rc4(void);
 const EVP_CIPHER *EVP_rc4_40(void);
@@ -705,6 +735,7 @@ void EVP_PBE_cleanup(void);
 /* The following lines are auto generated by the script mkerr.pl. Any changes
  * made after this point may be overwritten when the script is next run.
  */
+void ERR_load_EVP_strings(void);
 
 /* Error codes for the EVP functions. */
 
@@ -714,6 +745,7 @@ void EVP_PBE_cleanup(void);
 #define EVP_F_EVP_CIPHER_CTX_CTRL                       124
 #define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH             122
 #define EVP_F_EVP_DECRYPTFINAL                          101
+#define EVP_F_EVP_DIGESTINIT                            128
 #define EVP_F_EVP_ENCRYPTFINAL                          127
 #define EVP_F_EVP_MD_CTX_COPY                           110
 #define EVP_F_EVP_OPENINIT                              102
@@ -761,6 +793,7 @@ void EVP_PBE_cleanup(void);
 #define EVP_R_KEYGEN_FAILURE                            120
 #define EVP_R_MISSING_PARAMETERS                        103
 #define EVP_R_NO_CIPHER_SET                             131
+#define EVP_R_NO_DIGEST_SET                             139
 #define EVP_R_NO_DSA_PARAMETERS                                 116
 #define EVP_R_NO_SIGN_FUNCTION_CONFIGURED               104
 #define EVP_R_NO_VERIFY_FUNCTION_CONFIGURED             105
@@ -782,4 +815,3 @@ void EVP_PBE_cleanup(void);
 }
 #endif
 #endif
-