indent has problems with comments that are on the right hand side of a line.
[openssl.git] / crypto / evp / evp.h
index a94f845e93425cd8621560b6e5a823880d66844f..e6b58ffe5dd5b8c064771213561ab60a88222891 100644 (file)
@@ -75,7 +75,7 @@
 #include <openssl/bio.h>
 #endif
 
-/*
+/*-
 #define EVP_RC2_KEY_SIZE               16
 #define EVP_RC4_KEY_SIZE               16
 #define EVP_BLOWFISH_KEY_SIZE          16
@@ -189,13 +189,16 @@ typedef int evp_verify_method(int type,const unsigned char *m,
                            unsigned int m_length,const unsigned char *sigbuf,
                            unsigned int siglen, void *key);
 
-#define EVP_MD_FLAG_ONESHOT    0x0001 /* digest can only handle a single
-                                       * block */
+/* digest can only handle a single block */
+#define EVP_MD_FLAG_ONESHOT    0x0001
 
-#define EVP_MD_FLAG_PKEY_DIGEST        0x0002 /* digest is a "clone" digest used
-                                       * which is a copy of an existing
-                                       * one for a specific public key type.
-                                       * EVP_dss1() etc */
+/*
+ * digest is a "clone" digest used
+ * which is a copy of an existing
+ * one for a specific public key type.
+ * EVP_dss1() etc
+ */
+#define EVP_MD_FLAG_PKEY_DIGEST        0x0002
 
 /* Digest uses EVP_PKEY_METHOD for signing instead of MD specific signing */
 
@@ -217,7 +220,8 @@ typedef int evp_verify_method(int type,const unsigned char *m,
 
 #define EVP_MD_FLAG_DIGALGID_CUSTOM            0x0018
 
-#define EVP_MD_FLAG_FIPS       0x0400 /* Note if suitable for use in FIPS mode */
+/* Note if suitable for use in FIPS mode */
+#define EVP_MD_FLAG_FIPS       0x0400
 
 /* Digest ctrls */
 
@@ -304,19 +308,39 @@ struct evp_cipher_st
        {
        int nid;
        int block_size;
-       int key_len;            /* Default value for variable length ciphers */
+
+       /* Default value for variable length ciphers */
+       int key_len;
        int iv_len;
-       unsigned long flags;    /* Various flags */
+
+       /* Various flags */
+       unsigned long flags;
+       
+       /* init key */
        int (*init)(EVP_CIPHER_CTX *ctx, const unsigned char *key,
-                   const unsigned char *iv, int enc);  /* init key */
+                   const unsigned char *iv, int enc);
+                   
+       /* encrypt/decrypt data */
        int (*do_cipher)(EVP_CIPHER_CTX *ctx, unsigned char *out,
-                        const unsigned char *in, size_t inl);/* encrypt/decrypt data */
-       int (*cleanup)(EVP_CIPHER_CTX *); /* cleanup ctx */
-       int ctx_size;           /* how big ctx->cipher_data needs to be */
-       int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Populate a ASN1_TYPE with parameters */
-       int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *); /* Get parameters from a ASN1_TYPE */
-       int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr); /* Miscellaneous operations */
-       void *app_data;         /* Application data */
+                        const unsigned char *in, size_t inl);
+
+       /* cleanup ctx */
+       int (*cleanup)(EVP_CIPHER_CTX *);
+
+       /* how big ctx->cipher_data needs to be */
+       int ctx_size;
+
+       /* Populate a ASN1_TYPE with parameters */
+       int (*set_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *);
+
+       /* Get parameters from a ASN1_TYPE */
+       int (*get_asn1_parameters)(EVP_CIPHER_CTX *, ASN1_TYPE *);
+
+       /* Miscellaneous operations */
+       int (*ctrl)(EVP_CIPHER_CTX *, int type, int arg, void *ptr);
+
+       /* Application data */
+       void *app_data;
        } /* EVP_CIPHER */;
 
 /* Values for cipher flags */
@@ -360,7 +384,8 @@ struct evp_cipher_st
 /* Cipher handles any and all padding logic as well
  * as finalisation.
  */
-#define        EVP_CIPH_FLAG_CUSTOM_CIPHER     0x10000
+#define        EVP_CIPH_FLAG_CUSTOM_CIPHER     0x100000
+#define                EVP_CIPH_FLAG_AEAD_CIPHER       0x200000
 
 /* ctrl() values */
 
@@ -383,6 +408,23 @@ struct evp_cipher_st
 #define                EVP_CTRL_CCM_SET_TAG            EVP_CTRL_GCM_SET_TAG
 #define                EVP_CTRL_CCM_SET_L              0x14
 #define                EVP_CTRL_CCM_SET_MSGLEN         0x15
+/* AEAD cipher deduces payload length and returns number of bytes
+ * required to store MAC and eventual padding. Subsequent call to
+ * EVP_Cipher even appends/verifies MAC.
+ */
+#define                EVP_CTRL_AEAD_TLS1_AAD          0x16
+/* Used by composite AEAD ciphers, no-op in GCM, CCM... */
+#define                EVP_CTRL_AEAD_SET_MAC_KEY       0x17
+/* Set the GCM invocation field, decrypt only */
+#define                EVP_CTRL_GCM_SET_IV_INV         0x18
+
+/* GCM TLS constants */
+/* Length of fixed part of IV derived from PRF */
+#define EVP_GCM_TLS_FIXED_IV_LEN                       4
+/* Length of explicit part of IV part of TLS records */
+#define EVP_GCM_TLS_EXPLICIT_IV_LEN                    8
+/* Length of tag for TLS */
+#define EVP_GCM_TLS_TAG_LEN                            16
 
 typedef struct evp_cipher_info_st
        {
@@ -400,7 +442,7 @@ 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_BLOCK_LENGTH];/* saved partial block */
-       int num;                                /* used by cfb/ofb mode */
+       int num;                                /* used by cfb/ofb/ctr mode */
 
        void *app_data;         /* application stuff */
        int key_len;            /* May change for variable length cipher */
@@ -413,14 +455,22 @@ struct evp_cipher_ctx_st
 
 typedef struct evp_Encode_Ctx_st
        {
-       int num;        /* number saved in a partial encode/decode */
-       int length;     /* The length is either the output line length
-                        * (in input bytes) or the shortest input line
-                        * length that is ok.  Once decoding begins,
-                        * the length is adjusted up each time a longer
-                        * line is decoded */
-       unsigned char enc_data[80];     /* data to encode */
-       int line_num;   /* number read on current line */
+       /* number saved in a partial encode/decode */
+       int num;
+
+       /* The length is either the output line length
+        * (in input bytes) or the shortest input line
+        * length that is ok.  Once decoding begins,
+        * the length is adjusted up each time a longer
+        * line is decoded
+        */
+       int length;
+
+       /* data to encode */
+       unsigned char enc_data[80];
+
+       /* number read on current line */
+       int line_num;
        int expect_nl;
        } EVP_ENCODE_CTX;
 
@@ -720,6 +770,9 @@ const EVP_MD *EVP_dev_crypto_md5(void);
 #ifndef OPENSSL_NO_RC4
 const EVP_CIPHER *EVP_rc4(void);
 const EVP_CIPHER *EVP_rc4_40(void);
+#ifndef OPENSSL_NO_MD5
+const EVP_CIPHER *EVP_rc4_hmac_md5(void);
+#endif
 #endif
 #ifndef OPENSSL_NO_IDEA
 const EVP_CIPHER *EVP_idea_ecb(void);
@@ -791,6 +844,10 @@ const EVP_CIPHER *EVP_aes_256_ctr(void);
 const EVP_CIPHER *EVP_aes_256_ccm(void);
 const EVP_CIPHER *EVP_aes_256_gcm(void);
 const EVP_CIPHER *EVP_aes_256_xts(void);
+#if !defined(OPENSSL_NO_SHA) && !defined(OPENSSL_NO_SHA1)
+const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void);
+const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void);
+#endif
 #endif
 #ifndef OPENSSL_NO_CAMELLIA
 const EVP_CIPHER *EVP_camellia_128_ecb(void);
@@ -1217,6 +1274,8 @@ void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth,
        int (*ctrl_str)(EVP_PKEY_CTX *ctx,
                                        const char *type, const char *value));
 
+void EVP_add_alg_module(void);
+
 /* BEGIN ERROR CODES */
 /* 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.
@@ -1227,9 +1286,13 @@ void ERR_load_EVP_strings(void);
 
 /* Function codes. */
 #define EVP_F_AESNI_INIT_KEY                            165
+#define EVP_F_AESNI_XTS_CIPHER                          176
 #define EVP_F_AES_INIT_KEY                              133
 #define EVP_F_AES_XTS                                   172
+#define EVP_F_AES_XTS_CIPHER                            175
+#define EVP_F_ALG_MODULE_INIT                           177
 #define EVP_F_CAMELLIA_INIT_KEY                                 159
+#define EVP_F_CMAC_INIT                                         173
 #define EVP_F_D2I_PKEY                                  100
 #define EVP_F_DO_SIGVER_INIT                            161
 #define EVP_F_DSAPKEY2PKCS8                             134
@@ -1290,6 +1353,7 @@ void ERR_load_EVP_strings(void);
 #define EVP_F_FIPS_CIPHER_CTX_SET_KEY_LENGTH            171
 #define EVP_F_FIPS_DIGESTINIT                           168
 #define EVP_F_FIPS_MD_CTX_COPY                          169
+#define EVP_F_HMAC_INIT_EX                              174
 #define EVP_F_INT_CTX_NEW                               157
 #define EVP_F_PKCS5_PBE_KEYIVGEN                        117
 #define EVP_F_PKCS5_V2_PBE_KEYIVGEN                     118
@@ -1320,15 +1384,19 @@ void ERR_load_EVP_strings(void);
 #define EVP_R_DIFFERENT_PARAMETERS                      153
 #define EVP_R_DISABLED_FOR_FIPS                                 163
 #define EVP_R_ENCODE_ERROR                              115
+#define EVP_R_ERROR_LOADING_SECTION                     165
+#define EVP_R_ERROR_SETTING_FIPS_MODE                   166
 #define EVP_R_EVP_PBE_CIPHERINIT_ERROR                  119
 #define EVP_R_EXPECTING_AN_RSA_KEY                      127
 #define EVP_R_EXPECTING_A_DH_KEY                        128
 #define EVP_R_EXPECTING_A_DSA_KEY                       129
 #define EVP_R_EXPECTING_A_ECDSA_KEY                     141
 #define EVP_R_EXPECTING_A_EC_KEY                        142
+#define EVP_R_FIPS_MODE_NOT_SUPPORTED                   167
 #define EVP_R_INITIALIZATION_ERROR                      134
 #define EVP_R_INPUT_NOT_INITIALIZED                     111
 #define EVP_R_INVALID_DIGEST                            152
+#define EVP_R_INVALID_FIPS_MODE                                 168
 #define EVP_R_INVALID_KEY_LENGTH                        130
 #define EVP_R_INVALID_OPERATION                                 148
 #define EVP_R_IV_TOO_LARGE                              102
@@ -1353,6 +1421,7 @@ void ERR_load_EVP_strings(void);
 #define EVP_R_TOO_LARGE                                         164
 #define EVP_R_UNKNOWN_CIPHER                            160
 #define EVP_R_UNKNOWN_DIGEST                            161
+#define EVP_R_UNKNOWN_OPTION                            169
 #define EVP_R_UNKNOWN_PBE_ALGORITHM                     121
 #define EVP_R_UNSUPORTED_NUMBER_OF_ROUNDS               135
 #define EVP_R_UNSUPPORTED_ALGORITHM                     156