Change some EVP prototypes to use "cipher" rather than "type" as a variable
[openssl.git] / crypto / evp / evp.h
index 807b8e1f2231750181b13782d1292eadffbd74c4..718b3d5ecbc9be2fdf5ee48a906e3560f01e2437 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 */
 
@@ -377,6 +392,8 @@ typedef int (EVP_PBE_KEYGEN)(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
 #define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a))
 
 #define EVP_MD_type(e)                 ((e)->type)
+#define EVP_MD_nid(e)                  EVP_MD_type(e)
+#define EVP_MD_name(e)                 OBJ_nid2sn(EVP_MD_nid(e))
 #define EVP_MD_pkey_type(e)            ((e)->pkey_type)
 #define EVP_MD_size(e)                 ((e)->md_size)
 #define EVP_MD_block_size(e)           ((e)->block_size)
@@ -441,7 +458,11 @@ 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);  
+#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(EVP_MD_CTX *ctx, const EVP_MD *type);
+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);
@@ -456,19 +477,26 @@ 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(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_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,
@@ -481,11 +509,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);
 
@@ -556,11 +584,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);
@@ -696,6 +729,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. */
 
@@ -705,6 +739,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
@@ -752,6 +787,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
@@ -773,4 +809,3 @@ void EVP_PBE_cleanup(void);
 }
 #endif
 #endif
-