Changes between 0.9.6 and 0.9.7 [xx XXX 2000]
+ *) Constify the cipher and digest 'method' functions and structures
+ and modify related functions to take constant EVP_MD and EVP_CIPHER
+ pointers.
+ [Steve Henson]
+
*) Implement ssl23_peek (analogous to ssl23_read), which previously
did not exist.
[Bodo Moeller]
char *inrand=NULL,*dsaparams=NULL;
char *passargout = NULL, *passout = NULL;
BIO *out=NULL,*in=NULL;
- EVP_CIPHER *enc=NULL;
+ const EVP_CIPHER *enc=NULL;
char *engine=NULL;
apps_startup();
RSA *rsa=NULL;
int i,num=DEFBITS;
long l;
- EVP_CIPHER *enc=NULL;
+ const EVP_CIPHER *enc=NULL;
unsigned long f4=RSA_F4;
char *outfile=NULL;
char *passargout = NULL, *passout = NULL;
#define PROG pkcs12_main
-EVP_CIPHER *enc;
+const EVP_CIPHER *enc;
#define NOKEYS 0x1
char *engine=NULL;
char *extensions = NULL;
char *req_exts = NULL;
- EVP_CIPHER *cipher=NULL;
+ const EVP_CIPHER *cipher=NULL;
ASN1_INTEGER *serial = NULL;
int modulus=0;
char *inrand=NULL;
char *infile = NULL, *outfile = NULL;
char *signerfile = NULL, *recipfile = NULL;
char *certfile = NULL, *keyfile = NULL, *contfile=NULL;
- EVP_CIPHER *cipher = NULL;
+ const EVP_CIPHER *cipher = NULL;
PKCS7 *p7 = NULL;
X509_STORE *store = NULL;
X509 *cert = NULL, *recip = NULL, *signer = NULL;
const unsigned char *in, unsigned int inl);
#define IMPLEMENT_AES_CIPHER(name, ciph_func, keylen, ivlen, mode) \
-static EVP_CIPHER name##_cipher_st = \
+static const EVP_CIPHER name##_cipher_st = \
{ \
NID_##name, \
16,keylen,ivlen, \
NULL, \
NULL \
}; \
-EVP_CIPHER * EVP_##name(void) \
+const EVP_CIPHER * EVP_##name(void) \
{ \
return &name##_cipher_st; \
}
return 1;
}
-EVP_CIPHER *EVP_des_ede(void)
+const EVP_CIPHER *EVP_des_ede(void)
{
return &des_ede_ecb;
}
-EVP_CIPHER *EVP_des_ede3(void)
+const EVP_CIPHER *EVP_des_ede3(void)
{
return &des_ede3_ecb;
}
const unsigned char *iv,int enc);
static int null_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, unsigned int inl);
-static EVP_CIPHER n_cipher=
+static const EVP_CIPHER n_cipher=
{
NID_undef,
1,0,0,
NULL
};
-EVP_CIPHER *EVP_enc_null(void)
+const EVP_CIPHER *EVP_enc_null(void)
{
return(&n_cipher);
}
#define RC2_64_MAGIC 0x78
#define RC2_128_MAGIC 0x3a
-static EVP_CIPHER r2_64_cbc_cipher=
+static const EVP_CIPHER r2_64_cbc_cipher=
{
NID_rc2_64_cbc,
8,8 /* 64 bit */,8,
NULL
};
-static EVP_CIPHER r2_40_cbc_cipher=
+static const EVP_CIPHER r2_40_cbc_cipher=
{
NID_rc2_40_cbc,
8,5 /* 40 bit */,8,
NULL
};
-EVP_CIPHER *EVP_rc2_64_cbc(void)
+const EVP_CIPHER *EVP_rc2_64_cbc(void)
{
return(&r2_64_cbc_cipher);
}
-EVP_CIPHER *EVP_rc2_40_cbc(void)
+const EVP_CIPHER *EVP_rc2_40_cbc(void)
{
return(&r2_40_cbc_cipher);
}
const unsigned char *iv,int enc);
static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, unsigned int inl);
-static EVP_CIPHER r4_cipher=
+static const EVP_CIPHER r4_cipher=
{
NID_rc4,
1,EVP_RC4_KEY_SIZE,0,
NULL
};
-static EVP_CIPHER r4_40_cipher=
+static const EVP_CIPHER r4_40_cipher=
{
NID_rc4_40,
1,5 /* 40 bit */,0,
NULL
};
-EVP_CIPHER *EVP_rc4(void)
+const EVP_CIPHER *EVP_rc4(void)
{
return(&r4_cipher);
}
-EVP_CIPHER *EVP_rc4_40(void)
+const EVP_CIPHER *EVP_rc4_40(void)
{
return(&r4_40_cipher);
}
const unsigned char *iv,int enc);
static int desx_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, unsigned int inl);
-static EVP_CIPHER d_xcbc_cipher=
+static const EVP_CIPHER d_xcbc_cipher=
{
NID_desx_cbc,
8,24,8,
NULL
};
-EVP_CIPHER *EVP_desx_cbc(void)
+const EVP_CIPHER *EVP_desx_cbc(void)
{
return(&d_xcbc_cipher);
}
/* Password based encryption function */
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);
+ ASN1_TYPE *param, const EVP_CIPHER *cipher,
+ const EVP_MD *md, int en_de);
#ifndef OPENSSL_NO_RSA
#define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\
void EVP_set_pw_prompt(char *prompt);
char * EVP_get_pw_prompt(void);
-int EVP_BytesToKey(const EVP_CIPHER *type,EVP_MD *md,unsigned char *salt,
+int EVP_BytesToKey(const EVP_CIPHER *type,const EVP_MD *md,unsigned char *salt,
unsigned char *data, int datal, int count,
unsigned char *key,unsigned char *iv);
unsigned char *i, int enc);
#endif
-EVP_MD *EVP_md_null(void);
+const EVP_MD *EVP_md_null(void);
#ifndef OPENSSL_NO_MD2
-EVP_MD *EVP_md2(void);
+const EVP_MD *EVP_md2(void);
#endif
#ifndef OPENSSL_NO_MD4
-EVP_MD *EVP_md4(void);
+const EVP_MD *EVP_md4(void);
#endif
#ifndef OPENSSL_NO_MD5
-EVP_MD *EVP_md5(void);
+const EVP_MD *EVP_md5(void);
#endif
#ifndef OPENSSL_NO_SHA
-EVP_MD *EVP_sha(void);
-EVP_MD *EVP_sha1(void);
-EVP_MD *EVP_dss(void);
-EVP_MD *EVP_dss1(void);
+const EVP_MD *EVP_sha(void);
+const EVP_MD *EVP_sha1(void);
+const EVP_MD *EVP_dss(void);
+const EVP_MD *EVP_dss1(void);
#endif
#ifndef OPENSSL_NO_MDC2
-EVP_MD *EVP_mdc2(void);
+const EVP_MD *EVP_mdc2(void);
#endif
#ifndef OPENSSL_NO_RIPEMD
-EVP_MD *EVP_ripemd160(void);
+const EVP_MD *EVP_ripemd160(void);
#endif
-EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */
+const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */
#ifndef OPENSSL_NO_DES
-EVP_CIPHER *EVP_des_ecb(void);
-EVP_CIPHER *EVP_des_ede(void);
-EVP_CIPHER *EVP_des_ede3(void);
-EVP_CIPHER *EVP_des_cfb(void);
-EVP_CIPHER *EVP_des_ede_cfb(void);
-EVP_CIPHER *EVP_des_ede3_cfb(void);
-EVP_CIPHER *EVP_des_ofb(void);
-EVP_CIPHER *EVP_des_ede_ofb(void);
-EVP_CIPHER *EVP_des_ede3_ofb(void);
-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);
+const EVP_CIPHER *EVP_des_ecb(void);
+const EVP_CIPHER *EVP_des_ede(void);
+const EVP_CIPHER *EVP_des_ede3(void);
+const EVP_CIPHER *EVP_des_cfb(void);
+const EVP_CIPHER *EVP_des_ede_cfb(void);
+const EVP_CIPHER *EVP_des_ede3_cfb(void);
+const EVP_CIPHER *EVP_des_ofb(void);
+const EVP_CIPHER *EVP_des_ede_ofb(void);
+const EVP_CIPHER *EVP_des_ede3_ofb(void);
+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);
#endif
#ifndef OPENSSL_NO_RC4
-EVP_CIPHER *EVP_rc4(void);
-EVP_CIPHER *EVP_rc4_40(void);
+const EVP_CIPHER *EVP_rc4(void);
+const EVP_CIPHER *EVP_rc4_40(void);
#endif
#ifndef OPENSSL_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);
+const EVP_CIPHER *EVP_idea_ecb(void);
+const EVP_CIPHER *EVP_idea_cfb(void);
+const EVP_CIPHER *EVP_idea_ofb(void);
+const EVP_CIPHER *EVP_idea_cbc(void);
#endif
#ifndef OPENSSL_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);
+const EVP_CIPHER *EVP_rc2_ecb(void);
+const EVP_CIPHER *EVP_rc2_cbc(void);
+const EVP_CIPHER *EVP_rc2_40_cbc(void);
+const EVP_CIPHER *EVP_rc2_64_cbc(void);
+const EVP_CIPHER *EVP_rc2_cfb(void);
+const EVP_CIPHER *EVP_rc2_ofb(void);
#endif
#ifndef OPENSSL_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);
+const EVP_CIPHER *EVP_bf_ecb(void);
+const EVP_CIPHER *EVP_bf_cbc(void);
+const EVP_CIPHER *EVP_bf_cfb(void);
+const EVP_CIPHER *EVP_bf_ofb(void);
#endif
#ifndef OPENSSL_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);
+const EVP_CIPHER *EVP_cast5_ecb(void);
+const EVP_CIPHER *EVP_cast5_cbc(void);
+const EVP_CIPHER *EVP_cast5_cfb(void);
+const EVP_CIPHER *EVP_cast5_ofb(void);
#endif
#ifndef OPENSSL_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);
+const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void);
+const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void);
+const EVP_CIPHER *EVP_rc5_32_12_16_cfb(void);
+const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void);
#endif
#ifndef OPENSSL_NO_AES
-EVP_CIPHER *EVP_aes_128_ecb(void);
-EVP_CIPHER *EVP_aes_128_cbc(void);
-EVP_CIPHER *EVP_aes_192_ecb(void);
-EVP_CIPHER *EVP_aes_192_cbc(void);
-EVP_CIPHER *EVP_aes_256_ecb(void);
-EVP_CIPHER *EVP_aes_256_cbc(void);
+const EVP_CIPHER *EVP_aes_128_ecb(void);
+const EVP_CIPHER *EVP_aes_128_cbc(void);
+const EVP_CIPHER *EVP_aes_192_ecb(void);
+const EVP_CIPHER *EVP_aes_192_cbc(void);
+const EVP_CIPHER *EVP_aes_256_ecb(void);
+const EVP_CIPHER *EVP_aes_256_cbc(void);
#endif
void OpenSSL_add_all_algorithms(void);
#define SSLeay_add_all_ciphers() OpenSSL_add_all_ciphers()
#define SSLeay_add_all_digests() OpenSSL_add_all_digests()
-int EVP_add_cipher(EVP_CIPHER *cipher);
-int EVP_add_digest(EVP_MD *digest);
+int EVP_add_cipher(const EVP_CIPHER *cipher);
+int EVP_add_digest(const EVP_MD *digest);
const EVP_CIPHER *EVP_get_cipherbyname(const char *name);
const EVP_MD *EVP_get_digestbyname(const char *name);
/* PKCS5 password based encryption */
int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
- ASN1_TYPE *param, EVP_CIPHER *cipher, EVP_MD *md,
+ ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
int en_de);
int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen,
unsigned char *salt, int saltlen, int iter,
int keylen, unsigned char *out);
int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
- ASN1_TYPE *param, EVP_CIPHER *cipher, EVP_MD *md,
+ ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
int en_de);
void PKCS5_PBE_add(void);
int EVP_PBE_CipherInit (ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de);
-int EVP_PBE_alg_add(int nid, EVP_CIPHER *cipher, EVP_MD *md,
+int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
EVP_PBE_KEYGEN *keygen);
void EVP_PBE_cleanup(void);
#endif
}
-int EVP_BytesToKey(const EVP_CIPHER *type, EVP_MD *md, unsigned char *salt,
+int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, unsigned char *salt,
unsigned char *data, int datal, int count, unsigned char *key,
unsigned char *iv)
{
#define BLOCK_CIPHER_defs(cname, kstruct, \
nid, block_size, key_len, iv_len, flags,\
init_key, cleanup, set_asn1, get_asn1, ctrl)\
-static EVP_CIPHER cname##_cbc = {\
+static const EVP_CIPHER cname##_cbc = {\
nid##_cbc, block_size, key_len, iv_len, \
flags | EVP_CIPH_CBC_MODE,\
init_key,\
ctrl, \
NULL \
};\
-EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\
-static EVP_CIPHER cname##_cfb = {\
+const EVP_CIPHER *EVP_##cname##_cbc(void) { return &cname##_cbc; }\
+static const EVP_CIPHER cname##_cfb = {\
nid##_cfb64, 1, key_len, iv_len, \
flags | EVP_CIPH_CFB_MODE,\
init_key,\
ctrl,\
NULL \
};\
-EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\
-static EVP_CIPHER cname##_ofb = {\
+const EVP_CIPHER *EVP_##cname##_cfb(void) { return &cname##_cfb; }\
+static const EVP_CIPHER cname##_ofb = {\
nid##_ofb64, 1, key_len, iv_len, \
flags | EVP_CIPH_OFB_MODE,\
init_key,\
ctrl,\
NULL \
};\
-EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\
-static EVP_CIPHER cname##_ecb = {\
+const EVP_CIPHER *EVP_##cname##_ofb(void) { return &cname##_ofb; }\
+static const EVP_CIPHER cname##_ecb = {\
nid##_ecb, block_size, key_len, iv_len, \
flags | EVP_CIPH_ECB_MODE,\
init_key,\
ctrl,\
NULL \
};\
-EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
+const EVP_CIPHER *EVP_##cname##_ecb(void) { return &cname##_ecb; }
typedef struct {
int pbe_nid;
-EVP_CIPHER *cipher;
-EVP_MD *md;
+const EVP_CIPHER *cipher;
+const EVP_MD *md;
EVP_PBE_KEYGEN *keygen;
} EVP_PBE_CTL;
/* Add a PBE algorithm */
-int EVP_PBE_alg_add (int nid, EVP_CIPHER *cipher, EVP_MD *md,
+int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
EVP_PBE_KEYGEN *keygen)
{
EVP_PBE_CTL *pbe_tmp;
#include <openssl/x509.h>
#ifndef OPENSSL_NO_SHA
-static EVP_MD dsa_md=
+static const EVP_MD dsa_md=
{
NID_dsaWithSHA,
NID_dsaWithSHA,
sizeof(EVP_MD *)+sizeof(SHA_CTX),
};
-EVP_MD *EVP_dss(void)
+const EVP_MD *EVP_dss(void)
{
return(&dsa_md);
}
#include <openssl/objects.h>
#include <openssl/x509.h>
-static EVP_MD dss1_md=
+static const EVP_MD dss1_md=
{
NID_dsa,
NID_dsaWithSHA1,
sizeof(EVP_MD *)+sizeof(SHA_CTX),
};
-EVP_MD *EVP_dss1(void)
+const EVP_MD *EVP_dss1(void)
{
return(&dss1_md);
}
#include <openssl/objects.h>
#include <openssl/x509.h>
-static EVP_MD md2_md=
+static const EVP_MD md2_md=
{
NID_md2,
NID_md2WithRSAEncryption,
sizeof(EVP_MD *)+sizeof(MD2_CTX),
};
-EVP_MD *EVP_md2(void)
+const EVP_MD *EVP_md2(void)
{
return(&md2_md);
}
#include <openssl/objects.h>
#include <openssl/x509.h>
-static EVP_MD md4_md=
+static const EVP_MD md4_md=
{
NID_md4,
0,
sizeof(EVP_MD *)+sizeof(MD4_CTX),
};
-EVP_MD *EVP_md4(void)
+const EVP_MD *EVP_md4(void)
{
return(&md4_md);
}
#include <openssl/objects.h>
#include <openssl/x509.h>
-static EVP_MD md5_md=
+static const EVP_MD md5_md=
{
NID_md5,
NID_md5WithRSAEncryption,
sizeof(EVP_MD *)+sizeof(MD5_CTX),
};
-EVP_MD *EVP_md5(void)
+const EVP_MD *EVP_md5(void)
{
return(&md5_md);
}
#include <openssl/objects.h>
#include <openssl/x509.h>
-static EVP_MD mdc2_md=
+static const EVP_MD mdc2_md=
{
NID_mdc2,
NID_mdc2WithRSA,
sizeof(EVP_MD *)+sizeof(MDC2_CTX),
};
-EVP_MD *EVP_mdc2(void)
+const EVP_MD *EVP_mdc2(void)
{
return(&mdc2_md);
}
return 1;
}
-static EVP_MD null_md=
+static const EVP_MD null_md=
{
NID_undef,
NID_undef,
sizeof(EVP_MD *),
};
-EVP_MD *EVP_md_null(void)
+const EVP_MD *EVP_md_null(void)
{
return(&null_md);
}
#include <openssl/objects.h>
#include <openssl/x509.h>
-static EVP_MD ripemd160_md=
+static const EVP_MD ripemd160_md=
{
NID_ripemd160,
NID_ripemd160WithRSA,
sizeof(EVP_MD *)+sizeof(RIPEMD160_CTX),
};
-EVP_MD *EVP_ripemd160(void)
+const EVP_MD *EVP_ripemd160(void)
{
return(&ripemd160_md);
}
#include <openssl/objects.h>
#include <openssl/x509.h>
-static EVP_MD sha_md=
+static const EVP_MD sha_md=
{
NID_sha,
NID_shaWithRSAEncryption,
sizeof(EVP_MD *)+sizeof(SHA_CTX),
};
-EVP_MD *EVP_sha(void)
+const EVP_MD *EVP_sha(void)
{
return(&sha_md);
}
#include <openssl/objects.h>
#include <openssl/x509.h>
-static EVP_MD sha1_md=
+static const EVP_MD sha1_md=
{
NID_sha1,
NID_sha1WithRSAEncryption,
sizeof(EVP_MD *)+sizeof(SHA_CTX),
};
-EVP_MD *EVP_sha1(void)
+const EVP_MD *EVP_sha1(void)
{
return(&sha1_md);
}
#include <openssl/objects.h>
#include <openssl/x509.h>
-int EVP_add_cipher(EVP_CIPHER *c)
+int EVP_add_cipher(const EVP_CIPHER *c)
{
int r;
return(r);
}
-int EVP_add_digest(EVP_MD *md)
+int EVP_add_digest(const EVP_MD *md)
{
int r;
const char *name;
}
int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *cctx, const char *pass, int passlen,
- ASN1_TYPE *param, EVP_CIPHER *cipher, EVP_MD *md,
+ ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md,
int en_de)
{
EVP_MD_CTX ctx;
*/
int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
- ASN1_TYPE *param, EVP_CIPHER *c, EVP_MD *md,
+ ASN1_TYPE *param, const EVP_CIPHER *c, const EVP_MD *md,
int en_de)
{
unsigned char *pbuf, *salt, key[EVP_MAX_KEY_LENGTH];
}
int PKCS12_PBE_keyivgen (EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
- ASN1_TYPE *param, EVP_CIPHER *cipher, EVP_MD *md, int en_de)
+ ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md, int en_de)
{
PBEPARAM *pbe;
int saltlen, iter;
/* Set a mac */
int PKCS12_set_mac (PKCS12 *p12, const char *pass, int passlen,
- unsigned char *salt, int saltlen, int iter, EVP_MD *md_type)
+ unsigned char *salt, int saltlen, int iter, const EVP_MD *md_type)
{
unsigned char mac[EVP_MAX_MD_SIZE];
unsigned int maclen;
/* Set up a mac structure */
int PKCS12_setup_mac (PKCS12 *p12, int iter, unsigned char *salt, int saltlen,
- EVP_MD *md_type)
+ const EVP_MD *md_type)
{
if (!(p12->mac = PKCS12_MAC_DATA_new())) return PKCS12_ERROR;
if (iter > 1) {
unsigned char *out, const EVP_MD *md_type);
int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, int saltlen, int id, int iter, int n, unsigned char *out, const EVP_MD *md_type);
int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
- ASN1_TYPE *param, EVP_CIPHER *cipher, EVP_MD *md_type,
+ ASN1_TYPE *param, const EVP_CIPHER *cipher, const EVP_MD *md_type,
int en_de);
int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen,
unsigned char *mac, unsigned int *maclen);
int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen);
int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen,
unsigned char *salt, int saltlen, int iter,
- EVP_MD *md_type);
+ const EVP_MD *md_type);
int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt,
- int saltlen, EVP_MD *md_type);
+ int saltlen, const EVP_MD *md_type);
unsigned char *asc2uni(const char *asc, int asclen, unsigned char **uni, int *unilen);
char *uni2asc(unsigned char *uni, int unilen);
}
int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
- EVP_MD *dgst)
+ const EVP_MD *dgst)
{
char is_dsa;
if (pkey->type == EVP_PKEY_DSA) is_dsa = 1;
}
PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, EVP_PKEY *pkey,
- EVP_MD *dgst)
+ const EVP_MD *dgst)
{
PKCS7_SIGNER_INFO *si;
/* Build a complete PKCS#7 enveloped data */
-PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, EVP_CIPHER *cipher,
+PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,
int flags)
{
PKCS7 *p7;
int PKCS7_set_type(PKCS7 *p7, int type);
int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data);
int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey,
- EVP_MD *dgst);
+ const EVP_MD *dgst);
int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i);
int PKCS7_add_certificate(PKCS7 *p7, X509 *x509);
int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509);
PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509,
- EVP_PKEY *pkey, EVP_MD *dgst);
+ EVP_PKEY *pkey, const EVP_MD *dgst);
X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si);
STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7);
int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
BIO *indata, BIO *out, int flags);
STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, int flags);
-PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, EVP_CIPHER *cipher,
+PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher,
int flags);
int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, int flags);
#include <openssl/evp.h>
- void EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
- void EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt);
- void EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md,
+ int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type);
+ 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);
#define EVP_MAX_MD_SIZE (16+20) /* The SSLv3 md5+sha1 type */
#define EVP_MD_CTX_block_size(e) EVP_MD_block_size((e)->digest)
#define EVP_MD_CTX_type(e) EVP_MD_type((e)->digest)
- EVP_MD *EVP_md_null(void);
- EVP_MD *EVP_md2(void);
- EVP_MD *EVP_md5(void);
- EVP_MD *EVP_sha(void);
- EVP_MD *EVP_sha1(void);
- EVP_MD *EVP_dss(void);
- EVP_MD *EVP_dss1(void);
- EVP_MD *EVP_mdc2(void);
- EVP_MD *EVP_ripemd160(void);
+ const EVP_MD *EVP_md_null(void);
+ const EVP_MD *EVP_md2(void);
+ const EVP_MD *EVP_md5(void);
+ const EVP_MD *EVP_sha(void);
+ const EVP_MD *EVP_sha1(void);
+ const EVP_MD *EVP_dss(void);
+ const EVP_MD *EVP_dss1(void);
+ const EVP_MD *EVP_mdc2(void);
+ const EVP_MD *EVP_ripemd160(void);
const EVP_MD *EVP_get_digestbyname(const char *name);
#define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a))
=head1 RETURN VALUES
-EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() do not return values.
+EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal() return 1 for
+success and 0 for failure.
EVP_MD_CTX_copy() returns 1 if successful or 0 for failure.
SHA1 is the digest of choice for new applications. The other digest algorithms
are still in common use.
+The functions EVP_DigestInit(), EVP_DigestUpdate() and EVP_DigestFinal(),
+did not return errors in OpenSSL versions before 0.9.7 or earlier. Software only
+versions of digest algorithms will never return error codes for these functions.
+
=head1 EXAMPLE
This example digests the data "Test Message\n" and "Hello World\n", using the
=head1 BUGS
-Several of the functions do not return values: maybe they should. Although the
-internal digest operations will never fail some future hardware based operations
-might.
-
The link between digests and signing algorithms results in a situation where
EVP_sha1() must be used with RSA and EVP_dss1() must be used with DSS
even though they are identical digests.