salt_len = strlen(salt_out);
assert(salt_len <= 8);
- md = EVP_MD_CTX_create();
+ md = EVP_MD_CTX_new();
if (md == NULL)
return NULL;
EVP_DigestInit_ex(md, EVP_md5(), NULL);
EVP_DigestUpdate(md, "$", 1);
EVP_DigestUpdate(md, salt_out, salt_len);
- md2 = EVP_MD_CTX_create();
+ md2 = EVP_MD_CTX_new();
if (md2 == NULL)
return NULL;
EVP_DigestInit_ex(md2, EVP_md5(), NULL);
(i & 1) ? sizeof buf : passwd_len);
EVP_DigestFinal_ex(md2, buf, NULL);
}
- EVP_MD_CTX_destroy(md2);
- EVP_MD_CTX_destroy(md);
+ EVP_MD_CTX_free(md2);
+ EVP_MD_CTX_free(md);
{
/* transform buf into output string */
STACK_OF(OPENSSL_STRING) *sigopts)
{
int rv;
- EVP_MD_CTX *mctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *mctx = EVP_MD_CTX_new();
rv = do_sign_init(mctx, pkey, md, sigopts);
/* Note: X509_sign_ctx() calls ASN1_item_sign_ctx(), which destroys
if (rv > 0)
rv = X509_sign_ctx(x, mctx);
else
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
return rv > 0 ? 1 : 0;
}
STACK_OF(OPENSSL_STRING) *sigopts)
{
int rv;
- EVP_MD_CTX *mctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *mctx = EVP_MD_CTX_new();
rv = do_sign_init(mctx, pkey, md, sigopts);
/* Note: X509_REQ_sign_ctx() calls ASN1_item_sign_ctx(), which destroys
* the EVP_MD_CTX we send it, so only destroy it here if the former
if (rv > 0)
rv = X509_REQ_sign_ctx(x, mctx);
else
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
return rv > 0 ? 1 : 0;
}
STACK_OF(OPENSSL_STRING) *sigopts)
{
int rv;
- EVP_MD_CTX *mctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *mctx = EVP_MD_CTX_new();
rv = do_sign_init(mctx, pkey, md, sigopts);
/* Note: X509_CRL_sign_ctx() calls ASN1_item_sign_ctx(), which destroys
* the EVP_MD_CTX we send it, so only destroy it here if the former
if (rv > 0)
rv = X509_CRL_sign_ctx(x, mctx);
else
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
return rv > 0 ? 1 : 0;
}
return 0;
if (input) {
- EVP_MD_CTX *md_ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
unsigned char buffer[4096];
int length;
EVP_DigestUpdate(md_ctx, buffer, length);
}
if (!EVP_DigestFinal(md_ctx, *md_value, NULL)) {
- EVP_MD_CTX_destroy(md_ctx);
+ EVP_MD_CTX_free(md_ctx);
return 0;
}
- EVP_MD_CTX_destroy(md_ctx);
+ EVP_MD_CTX_free(md_ctx);
} else {
long digest_len;
*md_value = string_to_hex(digest, &digest_len);
ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey,
const EVP_MD *type)
{
- EVP_MD_CTX *ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *ctx = EVP_MD_CTX_new();
unsigned char *p, *buf_in = NULL, *buf_out = NULL;
int i, inl = 0, outl = 0, outll = 0;
X509_ALGOR *a;
signature->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);
signature->flags |= ASN1_STRING_FLAG_BITS_LEFT;
err:
- EVP_MD_CTX_destroy(ctx);
+ EVP_MD_CTX_free(ctx);
OPENSSL_clear_free((char *)buf_in, (unsigned int)inl);
OPENSSL_clear_free((char *)buf_out, outll);
return (outl);
X509_ALGOR *algor2, ASN1_BIT_STRING *signature, void *asn,
EVP_PKEY *pkey, const EVP_MD *type)
{
- EVP_MD_CTX *ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *ctx = EVP_MD_CTX_new();
if (ctx == NULL) {
ASN1err(ASN1_F_ASN1_ITEM_SIGN, ERR_R_MALLOC_FAILURE);
return 0;
}
if (!EVP_DigestSignInit(ctx, NULL, type, NULL, pkey)) {
- EVP_MD_CTX_destroy(ctx);
+ EVP_MD_CTX_free(ctx);
return 0;
}
return ASN1_item_sign_ctx(it, algor1, algor2, signature, asn, ctx);
signature->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);
signature->flags |= ASN1_STRING_FLAG_BITS_LEFT;
err:
- EVP_MD_CTX_destroy(ctx);
+ EVP_MD_CTX_free(ctx);
OPENSSL_clear_free((char *)buf_in, (unsigned int)inl);
OPENSSL_clear_free((char *)buf_out, outll);
return (outl);
int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *a, ASN1_BIT_STRING *signature,
char *data, EVP_PKEY *pkey)
{
- EVP_MD_CTX *ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *ctx = EVP_MD_CTX_new();
const EVP_MD *type;
unsigned char *p, *buf_in = NULL;
int ret = -1, i, inl;
}
ret = 1;
err:
- EVP_MD_CTX_destroy(ctx);
+ EVP_MD_CTX_free(ctx);
return (ret);
}
return -1;
}
- ctx = EVP_MD_CTX_create();
+ ctx = EVP_MD_CTX_new();
if (ctx == NULL) {
ASN1err(ASN1_F_ASN1_ITEM_VERIFY, ERR_R_MALLOC_FAILURE);
goto err;
}
ret = 1;
err:
- EVP_MD_CTX_destroy(ctx);
+ EVP_MD_CTX_free(ctx);
return (ret);
}
CMS_SignerInfo *si = (CMS_SignerInfo *)*pval;
EVP_PKEY_free(si->pkey);
X509_free(si->signer);
- EVP_MD_CTX_destroy(si->mctx);
+ EVP_MD_CTX_free(si->mctx);
}
return 1;
}
int cms_DigestedData_do_final(CMS_ContentInfo *cms, BIO *chain, int verify)
{
- EVP_MD_CTX *mctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *mctx = EVP_MD_CTX_new();
unsigned char md[EVP_MAX_MD_SIZE];
unsigned int mdlen;
int r = 0;
}
err:
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
return r;
si->pkey = pk;
si->signer = signer;
- si->mctx = EVP_MD_CTX_create();
+ si->mctx = EVP_MD_CTX_new();
si->pctx = NULL;
if (si->mctx == NULL) {
static int cms_SignerInfo_content_sign(CMS_ContentInfo *cms,
CMS_SignerInfo *si, BIO *chain)
{
- EVP_MD_CTX *mctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *mctx = EVP_MD_CTX_new();
int r = 0;
EVP_PKEY_CTX *pctx = NULL;
r = 1;
err:
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
EVP_PKEY_CTX_free(pctx);
return r;
if (si->pctx)
pctx = si->pctx;
else {
- EVP_MD_CTX_init(mctx);
+ EVP_MD_CTX_reset(mctx);
if (EVP_DigestSignInit(mctx, &pctx, md, NULL, si->pkey) <= 0)
goto err;
}
goto err;
}
- EVP_MD_CTX_init(mctx);
+ EVP_MD_CTX_reset(mctx);
ASN1_STRING_set0(si->signature, abuf, siglen);
err:
OPENSSL_free(abuf);
- EVP_MD_CTX_init(mctx);
+ EVP_MD_CTX_reset(mctx);
return 0;
}
if (md == NULL)
return -1;
if (si->mctx == NULL)
- si->mctx = EVP_MD_CTX_create();
+ si->mctx = EVP_MD_CTX_new();
mctx = si->mctx;
if (EVP_DigestVerifyInit(mctx, &si->pctx, md, NULL, si->pkey) <= 0)
goto err;
if (r <= 0)
CMSerr(CMS_F_CMS_SIGNERINFO_VERIFY, CMS_R_VERIFICATION_FAILURE);
err:
- EVP_MD_CTX_init(mctx);
+ EVP_MD_CTX_reset(mctx);
return r;
}
int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain)
{
ASN1_OCTET_STRING *os = NULL;
- EVP_MD_CTX *mctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *mctx = EVP_MD_CTX_new();
EVP_PKEY_CTX *pkctx = NULL;
int r = -1;
unsigned char mval[EVP_MAX_MD_SIZE];
err:
EVP_PKEY_CTX_free(pkctx);
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
return r;
}
int derlen;
if (Zlen > DH_KDF_MAX)
return 0;
- mctx = EVP_MD_CTX_create();
+ mctx = EVP_MD_CTX_new();
if (mctx == NULL)
return 0;
mdlen = EVP_MD_size(md);
rv = 1;
err:
OPENSSL_free(der);
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
return rv;
}
#endif
int counter = 0;
int r = 0;
BN_CTX *ctx = NULL;
- EVP_MD_CTX *mctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *mctx = EVP_MD_CTX_new();
unsigned int h = 2;
if (mctx == NULL)
BN_CTX_end(ctx);
BN_CTX_free(ctx);
BN_MONT_CTX_free(mont);
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
return ok;
}
if (sinfolen > ECDH_KDF_MAX || outlen > ECDH_KDF_MAX
|| Zlen > ECDH_KDF_MAX)
return 0;
- mctx = EVP_MD_CTX_create();
+ mctx = EVP_MD_CTX_new();
if (mctx == NULL)
return 0;
mdlen = EVP_MD_size(md);
}
rv = 1;
err:
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
return rv;
}
{
EVP_MD_CTX *ctx;
- ctx = EVP_MD_CTX_create();
+ ctx = EVP_MD_CTX_new();
if (ctx == NULL)
return (0);
{
if (a == NULL)
return (0);
- EVP_MD_CTX_destroy(a->ptr);
+ EVP_MD_CTX_free(a->ptr);
a->ptr = NULL;
a->init = 0;
a->flags = 0;
ctx->cont = 1;
ctx->sigio = 1;
- ctx->md = EVP_MD_CTX_create();
+ ctx->md = EVP_MD_CTX_new();
bi->init = 0;
bi->ptr = (char *)ctx;
bi->flags = 0;
{
if (a == NULL)
return (0);
- EVP_MD_CTX_destroy(((BIO_OK_CTX *)a->ptr)->md);
+ EVP_MD_CTX_free(((BIO_OK_CTX *)a->ptr)->md);
OPENSSL_clear_free(a->ptr, sizeof(BIO_OK_CTX));
a->ptr = NULL;
a->init = 0;
unsigned char *md, unsigned int *size, const EVP_MD *type,
ENGINE *impl)
{
- EVP_MD_CTX *ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *ctx = EVP_MD_CTX_new();
int ret;
if (ctx == NULL)
ret = EVP_DigestInit_ex(ctx, type, impl)
&& EVP_DigestUpdate(ctx, data, count)
&& EVP_DigestFinal_ex(ctx, md, size);
- EVP_MD_CTX_destroy(ctx);
+ EVP_MD_CTX_free(ctx);
return ret;
}
if (data == NULL)
return (nkey);
- c = EVP_MD_CTX_create();
+ c = EVP_MD_CTX_new();
if (c == NULL)
goto err;
for (;;) {
}
rv = type->key_len;
err:
- EVP_MD_CTX_destroy(c);
+ EVP_MD_CTX_free(c);
OPENSSL_cleanse(md_buf, sizeof(md_buf));
return rv;
}
else
r = EVP_DigestFinal_ex(ctx, md, &mdlen);
} else {
- EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
return 0;
if (sctx)
sigret, siglen, tmp_ctx);
else
r = EVP_DigestFinal_ex(tmp_ctx, md, &mdlen);
- EVP_MD_CTX_destroy(tmp_ctx);
+ EVP_MD_CTX_free(tmp_ctx);
}
if (sctx || !r)
return r;
} else
r = EVP_DigestFinal_ex(ctx, md, &mdlen);
} else {
- EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
if (tmp_ctx == NULL || !EVP_MD_CTX_copy_ex(tmp_ctx, ctx))
return -1;
if (vctx) {
sig, siglen, tmp_ctx);
} else
r = EVP_DigestFinal_ex(tmp_ctx, md, &mdlen);
- EVP_MD_CTX_destroy(tmp_ctx);
+ EVP_MD_CTX_free(tmp_ctx);
}
if (vctx || !r)
return r;
else if (passlen == -1)
passlen = strlen(pass);
- ctx = EVP_MD_CTX_create();
+ ctx = EVP_MD_CTX_new();
if (ctx == NULL) {
EVPerr(EVP_F_PKCS5_PBE_KEYIVGEN, ERR_R_MALLOC_FAILURE);
goto err;
OPENSSL_cleanse(iv, EVP_MAX_IV_LENGTH);
rv = 1;
err:
- EVP_MD_CTX_destroy(ctx);
+ EVP_MD_CTX_free(ctx);
return rv;
}
goto err;
} else {
int rv = 0;
- EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
if (tmp_ctx == NULL) {
EVPerr(EVP_F_EVP_SIGNFINAL, ERR_R_MALLOC_FAILURE);
return 0;
rv = EVP_MD_CTX_copy_ex(tmp_ctx, ctx);
if (rv)
rv = EVP_DigestFinal_ex(tmp_ctx, m, &m_len);
- EVP_MD_CTX_destroy(tmp_ctx);
+ EVP_MD_CTX_free(tmp_ctx);
if (!rv)
return 0;
}
goto err;
} else {
int rv = 0;
- EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *tmp_ctx = EVP_MD_CTX_new();
if (tmp_ctx == NULL) {
EVPerr(EVP_F_EVP_VERIFYFINAL, ERR_R_MALLOC_FAILURE);
return 0;
rv = EVP_MD_CTX_copy_ex(tmp_ctx, ctx);
if (rv)
rv = EVP_DigestFinal_ex(tmp_ctx, m, &m_len);
- EVP_MD_CTX_destroy(tmp_ctx);
+ EVP_MD_CTX_free(tmp_ctx);
if (!rv)
return 0;
}
static void hmac_ctx_cleanup(HMAC_CTX *ctx)
{
- EVP_MD_CTX_init(ctx->i_ctx);
- EVP_MD_CTX_init(ctx->o_ctx);
- EVP_MD_CTX_init(ctx->md_ctx);
+ EVP_MD_CTX_reset(ctx->i_ctx);
+ EVP_MD_CTX_reset(ctx->o_ctx);
+ EVP_MD_CTX_reset(ctx->md_ctx);
ctx->md = NULL;
ctx->key_length = 0;
memset(ctx->key, 0, sizeof(HMAC_MAX_MD_CBLOCK));
{
if (ctx != NULL) {
hmac_ctx_cleanup(ctx);
- EVP_MD_CTX_destroy(ctx->i_ctx);
- EVP_MD_CTX_destroy(ctx->o_ctx);
- EVP_MD_CTX_destroy(ctx->md_ctx);
+ EVP_MD_CTX_free(ctx->i_ctx);
+ EVP_MD_CTX_free(ctx->o_ctx);
+ EVP_MD_CTX_free(ctx->md_ctx);
OPENSSL_free(ctx);
}
}
{
hmac_ctx_cleanup(ctx);
if (ctx->i_ctx == NULL)
- ctx->i_ctx = EVP_MD_CTX_create();
+ ctx->i_ctx = EVP_MD_CTX_new();
if (ctx->i_ctx == NULL)
goto err;
if (ctx->o_ctx == NULL)
- ctx->o_ctx = EVP_MD_CTX_create();
+ ctx->o_ctx = EVP_MD_CTX_new();
if (ctx->o_ctx == NULL)
goto err;
if (ctx->md_ctx == NULL)
- ctx->md_ctx = EVP_MD_CTX_create();
+ ctx->md_ctx = EVP_MD_CTX_new();
if (ctx->md_ctx == NULL)
goto err;
ctx->md = NULL;
EVP_EncodeInit(&ctx->encode);
- ctx->md = EVP_MD_CTX_create();
+ ctx->md = EVP_MD_CTX_new();
if (!EVP_SignInit(ctx->md, md_type))
goto err;
ret = 1;
err:
- EVP_MD_CTX_destroy(ctx->md);
+ EVP_MD_CTX_free(ctx->md);
EVP_CIPHER_CTX_cleanup(&ctx->cipher);
OPENSSL_free(s);
return (ret);
const unsigned char *salt, unsigned int saltlen,
const unsigned char *pass, int passlen)
{
- EVP_MD_CTX *mctx = EVP_MD_CTX_create();;
+ EVP_MD_CTX *mctx = EVP_MD_CTX_new();;
int rv = 1;
if (mctx == NULL
|| !EVP_DigestInit_ex(mctx, EVP_sha1(), NULL)
|| !EVP_DigestFinal_ex(mctx, key, NULL))
rv = 0;
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
return rv;
}
int tmpn = n;
#endif
- ctx = EVP_MD_CTX_create();
+ ctx = EVP_MD_CTX_new();
if (ctx == NULL)
goto err;
OPENSSL_free(I);
BN_free(Ij);
BN_free(Bpl1);
- EVP_MD_CTX_destroy(ctx);
+ EVP_MD_CTX_free(ctx);
return ret;
}
return 0;
}
- ctx_tmp = EVP_MD_CTX_create();
+ ctx_tmp = EVP_MD_CTX_new();
if (ctx_tmp == NULL) {
PKCS7err(PKCS7_F_PKCS7_DATAFINAL, ERR_R_MALLOC_FAILURE);
return 0;
}
ret = 1;
err:
- EVP_MD_CTX_destroy(ctx_tmp);
+ EVP_MD_CTX_free(ctx_tmp);
return (ret);
}
if (md == NULL)
return 0;
- mctx = EVP_MD_CTX_create();
+ mctx = EVP_MD_CTX_new();
if (mctx == NULL) {
PKCS7err(PKCS7_F_PKCS7_SIGNER_INFO_SIGN, ERR_R_MALLOC_FAILURE);
goto err;
goto err;
}
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
ASN1_STRING_set0(si->enc_digest, abuf, siglen);
err:
OPENSSL_free(abuf);
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
return 0;
}
BIO *btmp;
EVP_PKEY *pkey;
- mdc_tmp = EVP_MD_CTX_create();
+ mdc_tmp = EVP_MD_CTX_new();
if (mdc_tmp == NULL) {
PKCS7err(PKCS7_F_PKCS7_SIGNATUREVERIFY, ERR_R_MALLOC_FAILURE);
goto err;
}
ret = 1;
err:
- EVP_MD_CTX_destroy(mdc_tmp);
+ EVP_MD_CTX_free(mdc_tmp);
return (ret);
}
* hash function.
*/
- m = EVP_MD_CTX_create();
+ m = EVP_MD_CTX_new();
if (m == NULL)
goto err;
#endif
rv = 1;
err:
- EVP_MD_CTX_destroy(m);
+ EVP_MD_CTX_free(m);
return rv;
}
if (num <= 0)
return 1;
- m = EVP_MD_CTX_create();
+ m = EVP_MD_CTX_new();
if (m == NULL)
goto err_mem;
ASYNC_unblock_pause();
CRYPTO_w_unlock(CRYPTO_LOCK_RAND);
- EVP_MD_CTX_destroy(m);
+ EVP_MD_CTX_free(m);
if (ok)
return (1);
else if (pseudo)
}
err:
RANDerr(RAND_F_RAND_BYTES, ERR_R_EVP_LIB);
- EVP_MD_CTX_destroy(m);
+ EVP_MD_CTX_free(m);
return 0;
err_mem:
RANDerr(RAND_F_RAND_BYTES, ERR_R_MALLOC_FAILURE);
- EVP_MD_CTX_destroy(m);
+ EVP_MD_CTX_free(m);
return 0;
}
{
long i, outlen = 0;
unsigned char cnt[4];
- EVP_MD_CTX *c = EVP_MD_CTX_create();
+ EVP_MD_CTX *c = EVP_MD_CTX_new();
unsigned char md[EVP_MAX_MD_SIZE];
int mdlen;
int rv = -1;
}
rv = 0;
err:
- EVP_MD_CTX_destroy(c);
+ EVP_MD_CTX_free(c);
return rv;
}
int hLen, maskedDBLen, MSBits, emLen;
const unsigned char *H;
unsigned char *DB = NULL;
- EVP_MD_CTX *ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *ctx = EVP_MD_CTX_new();
unsigned char H_[EVP_MAX_MD_SIZE];
err:
OPENSSL_free(DB);
- EVP_MD_CTX_destroy(ctx);
+ EVP_MD_CTX_free(ctx);
return ret;
}
maskedDBLen = emLen - hLen - 1;
H = EM + maskedDBLen;
- ctx = EVP_MD_CTX_create();
+ ctx = EVP_MD_CTX_new();
if (ctx == NULL)
goto err;
if (!EVP_DigestInit_ex(ctx, Hash, NULL)
ret = 1;
err:
- EVP_MD_CTX_destroy(ctx);
+ EVP_MD_CTX_free(ctx);
OPENSSL_free(salt);
return ret;
if (BN_ucmp(g, N) >= 0)
return NULL;
- ctxt = EVP_MD_CTX_create();
+ ctxt = EVP_MD_CTX_new();
if (ctxt == NULL)
return NULL;
if ((tmp = OPENSSL_malloc(longN)) == NULL)
EVP_DigestFinal_ex(ctxt, digest, NULL);
res = BN_bin2bn(digest, sizeof(digest), NULL);
err:
- EVP_MD_CTX_destroy(ctxt);
+ EVP_MD_CTX_free(ctxt);
return res;
}
longN = BN_num_bytes(N);
- ctxt = EVP_MD_CTX_create();
+ ctxt = EVP_MD_CTX_new();
if (ctxt == NULL)
return NULL;
if ((cAB = OPENSSL_malloc(2 * longN)) == NULL)
u = NULL;
}
err:
- EVP_MD_CTX_destroy(ctxt);
+ EVP_MD_CTX_free(ctxt);
return u;
}
if ((s == NULL) || (user == NULL) || (pass == NULL))
return NULL;
- ctxt = EVP_MD_CTX_create();
+ ctxt = EVP_MD_CTX_new();
if (ctxt == NULL)
return NULL;
if ((cs = OPENSSL_malloc(BN_num_bytes(s))) == NULL)
res = BN_bin2bn(dig, sizeof(dig), NULL);
err:
- EVP_MD_CTX_destroy(ctxt);
+ EVP_MD_CTX_free(ctxt);
return res;
}
if (RAND_bytes(digv, SHA_DIGEST_LENGTH) <= 0)
goto err;
- ctxt = EVP_MD_CTX_create();
+ ctxt = EVP_MD_CTX_new();
EVP_DigestInit_ex(ctxt, EVP_sha1(), NULL);
EVP_DigestUpdate(ctxt, vb->seed_key, strlen(vb->seed_key));
EVP_DigestUpdate(ctxt, username, strlen(username));
EVP_DigestFinal_ex(ctxt, digs, NULL);
- EVP_MD_CTX_destroy(ctxt);
+ EVP_MD_CTX_free(ctxt);
ctxt = NULL;
if (SRP_user_pwd_set_sv_BN(user,
BN_bin2bn(digs, SHA_DIGEST_LENGTH, NULL),
return user;
err:
- EVP_MD_CTX_destroy(ctxt);
+ EVP_MD_CTX_free(ctxt);
SRP_user_pwd_free(user);
return NULL;
}
goto err;
}
- md_ctx = EVP_MD_CTX_create();
+ md_ctx = EVP_MD_CTX_new();
if (md_ctx == NULL) {
TSerr(TS_F_TS_COMPUTE_IMPRINT, ERR_R_MALLOC_FAILURE);
goto err;
}
if (!EVP_DigestFinal(md_ctx, *imprint, NULL))
goto err;
- EVP_MD_CTX_destroy(md_ctx);
+ EVP_MD_CTX_free(md_ctx);
return 1;
err:
- EVP_MD_CTX_destroy(md_ctx);
+ EVP_MD_CTX_free(md_ctx);
X509_ALGOR_free(*md_alg);
OPENSSL_free(*imprint);
*imprint_len = 0;
unsigned long X509_issuer_and_serial_hash(X509 *a)
{
unsigned long ret = 0;
- EVP_MD_CTX *ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *ctx = EVP_MD_CTX_new();
unsigned char md[16];
char *f;
((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)
) & 0xffffffffL;
err:
- EVP_MD_CTX_destroy(ctx);
+ EVP_MD_CTX_free(ctx);
return (ret);
}
#endif
unsigned long X509_NAME_hash_old(X509_NAME *x)
{
- EVP_MD_CTX *md_ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
unsigned long ret = 0;
unsigned char md[16];
ret = (((unsigned long)md[0]) | ((unsigned long)md[1] << 8L) |
((unsigned long)md[2] << 16L) | ((unsigned long)md[3] << 24L)
) & 0xffffffffL;
- EVP_MD_CTX_destroy(md_ctx);
+ EVP_MD_CTX_free(md_ctx);
return (ret);
}
} else {
unsigned int md_size_u;
/* Chop the digest off the end :-) */
- EVP_MD_CTX *md_ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
if (md_ctx == NULL)
return -1;
|| EVP_DigestUpdate(md_ctx, ssl3_pad_2, npad) <= 0
|| EVP_DigestUpdate(md_ctx, md, md_size) <= 0
|| EVP_DigestFinal_ex(md_ctx, md, &md_size_u) <= 0) {
- EVP_MD_CTX_init(md_ctx);
+ EVP_MD_CTX_reset(md_ctx);
return -1;
}
md_size = md_size_u;
- EVP_MD_CTX_destroy(md_ctx);
+ EVP_MD_CTX_free(md_ctx);
}
ssl3_record_sequence_update(seq);
if (stream_mac) {
mac_ctx = hash;
} else {
- hmac = EVP_MD_CTX_create();
+ hmac = EVP_MD_CTX_new();
if (hmac == NULL
|| !EVP_MD_CTX_copy(hmac, hash))
return -1;
rec->length + md_size, rec->orig_len,
ssl->s3->read_mac_secret,
ssl->s3->read_mac_secret_size, 0) <= 0) {
- EVP_MD_CTX_destroy(hmac);
+ EVP_MD_CTX_free(hmac);
return -1;
}
} else {
if (EVP_DigestSignUpdate(mac_ctx, header, sizeof(header)) <= 0
|| EVP_DigestSignUpdate(mac_ctx, rec->input, rec->length) <= 0
|| EVP_DigestSignFinal(mac_ctx, md, &md_size) <= 0) {
- EVP_MD_CTX_destroy(hmac);
+ EVP_MD_CTX_free(hmac);
return -1;
}
if (!send && !SSL_USE_ETM(ssl) && FIPS_mode())
rec->length, rec->orig_len);
}
- EVP_MD_CTX_destroy(hmac);
+ EVP_MD_CTX_free(hmac);
#ifdef TLS_DEBUG
fprintf(stderr, "seq=");
mac_out[j] |= block[j] & is_block_b;
}
- md_ctx = EVP_MD_CTX_create();
+ md_ctx = EVP_MD_CTX_new();
if (md_ctx == NULL)
goto err;
if (EVP_DigestInit_ex(md_ctx, EVP_MD_CTX_md(ctx), NULL /* engine */ ) <= 0)
ret = EVP_DigestFinal(md_ctx, md_out, &md_out_size_u);
if (ret && md_out_size)
*md_out_size = md_out_size_u;
- EVP_MD_CTX_destroy(md_ctx);
+ EVP_MD_CTX_free(md_ctx);
return 1;
err:
- EVP_MD_CTX_destroy(md_ctx);
+ EVP_MD_CTX_free(md_ctx);
return 0;
}
c = os_toascii[c]; /* 'A' in ASCII */
#endif
k = 0;
- m5 = EVP_MD_CTX_create();
- s1 = EVP_MD_CTX_create();
+ m5 = EVP_MD_CTX_new();
+ s1 = EVP_MD_CTX_new();
if (m5 == NULL || s1 == NULL) {
SSLerr(SSL_F_SSL3_GENERATE_KEY_BLOCK, ERR_R_MALLOC_FAILURE);
goto err;
OPENSSL_cleanse(smd, sizeof(smd));
ret = 1;
err:
- EVP_MD_CTX_destroy(m5);
- EVP_MD_CTX_destroy(s1);
+ EVP_MD_CTX_free(m5);
+ EVP_MD_CTX_free(s1);
return ret;
}
{
BIO_free(s->s3->handshake_buffer);
s->s3->handshake_buffer = NULL;
- EVP_MD_CTX_destroy(s->s3->handshake_dgst);
+ EVP_MD_CTX_free(s->s3->handshake_dgst);
s->s3->handshake_dgst = NULL;
}
return 0;
}
- s->s3->handshake_dgst = EVP_MD_CTX_create();
+ s->s3->handshake_dgst = EVP_MD_CTX_new();
if (s->s3->handshake_dgst == NULL) {
SSLerr(SSL_F_SSL3_DIGEST_CACHED_RECORDS, ERR_R_MALLOC_FAILURE);
return 0;
return 0;
}
- ctx = EVP_MD_CTX_create();
+ ctx = EVP_MD_CTX_new();
if (ctx == NULL) {
SSLerr(SSL_F_SSL3_FINAL_FINISH_MAC, ERR_R_MALLOC_FAILURE);
return 0;
ret = EVP_MD_CTX_size(ctx);
if (ret < 0) {
- EVP_MD_CTX_init(ctx);
+ EVP_MD_CTX_reset(ctx);
return 0;
}
ret = 0;
}
- EVP_MD_CTX_destroy(ctx);
+ EVP_MD_CTX_free(ctx);
return ret;
}
#endif
};
unsigned char buf[EVP_MAX_MD_SIZE];
- EVP_MD_CTX *ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *ctx = EVP_MD_CTX_new();
int i, ret = 0;
unsigned int n;
#ifdef OPENSSL_SSL_TRACE_CRYPTO
out += n;
ret += n;
}
- EVP_MD_CTX_destroy(ctx);
+ EVP_MD_CTX_free(ctx);
#ifdef OPENSSL_SSL_TRACE_CRYPTO
if (ret > 0 && s->msg_callback) {
EVP_MD_CTX *ssl_replace_hash(EVP_MD_CTX **hash, const EVP_MD *md)
{
ssl_clear_hash_ctx(hash);
- *hash = EVP_MD_CTX_create();
+ *hash = EVP_MD_CTX_new();
if (*hash == NULL || (md && EVP_DigestInit_ex(*hash, md, NULL) <= 0)) {
- EVP_MD_CTX_destroy(*hash);
+ EVP_MD_CTX_free(*hash);
*hash = NULL;
return NULL;
}
{
if (*hash)
- EVP_MD_CTX_destroy(*hash);
+ EVP_MD_CTX_free(*hash);
*hash = NULL;
}
ret = 0;
goto err;
}
- ctx = EVP_MD_CTX_create();
+ ctx = EVP_MD_CTX_new();
if (ctx == NULL) {
ret = 0;
goto err;
|| EVP_DigestFinal_ex(ctx, out, NULL) <= 0)
ret = 0;
err:
- EVP_MD_CTX_destroy(ctx);
+ EVP_MD_CTX_free(ctx);
return ret;
}
#endif
PACKET save_param_start, signature;
- md_ctx = EVP_MD_CTX_create();
+ md_ctx = EVP_MD_CTX_new();
if (md_ctx == NULL) {
al = SSL_AD_INTERNAL_ERROR;
SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE);
}
}
EVP_PKEY_free(pkey);
- EVP_MD_CTX_destroy(md_ctx);
+ EVP_MD_CTX_free(md_ctx);
return MSG_PROCESS_CONTINUE_READING;
f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
EC_POINT_free(srvr_ecpoint);
EC_KEY_free(ecdh);
#endif
- EVP_MD_CTX_destroy(md_ctx);
+ EVP_MD_CTX_free(md_ctx);
ossl_statem_set_error(s);
return MSG_PROCESS_ERROR;
}
* Compute shared IV and store it in algorithm-specific context
* data
*/
- ukm_hash = EVP_MD_CTX_create();
+ ukm_hash = EVP_MD_CTX_new();
if (EVP_DigestInit(ukm_hash,
EVP_get_digestbynid(dgst_nid)) <= 0
|| EVP_DigestUpdate(ukm_hash, s->s3->client_random,
|| EVP_DigestUpdate(ukm_hash, s->s3->server_random,
SSL3_RANDOM_SIZE) <= 0
|| EVP_DigestFinal_ex(ukm_hash, shared_ukm, &md_len) <= 0) {
- EVP_MD_CTX_destroy(ukm_hash);
+ EVP_MD_CTX_free(ukm_hash);
SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE,
ERR_R_INTERNAL_ERROR);
goto err;
}
- EVP_MD_CTX_destroy(ukm_hash);
+ EVP_MD_CTX_free(ukm_hash);
if (EVP_PKEY_CTX_ctrl
(pkey_ctx, -1, EVP_PKEY_OP_ENCRYPT, EVP_PKEY_CTRL_SET_IV, 8,
shared_ukm) < 0) {
long hdatalen = 0;
void *hdata;
- mctx = EVP_MD_CTX_create();
+ mctx = EVP_MD_CTX_new();
if (mctx == NULL) {
SSLerr(SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY, ERR_R_MALLOC_FAILURE);
goto err;
goto err;
}
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
return 1;
err:
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
return 0;
}
if (frag->msg_header.is_ccs) {
EVP_CIPHER_CTX_free(frag->msg_header.
saved_retransmit_state.enc_write_ctx);
- EVP_MD_CTX_destroy(frag->msg_header.
- saved_retransmit_state.write_hash);
+ EVP_MD_CTX_free(frag->msg_header.saved_retransmit_state.write_hash);
}
OPENSSL_free(frag->fragment);
OPENSSL_free(frag->reassembly);
BIGNUM *r[4];
int nr[4], kn;
BUF_MEM *buf;
- EVP_MD_CTX *md_ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
if (md_ctx == NULL) {
SSLerr(SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE, ERR_R_MALLOC_FAILURE);
goto f_err;
}
- EVP_MD_CTX_destroy(md_ctx);
+ EVP_MD_CTX_free(md_ctx);
return 1;
f_err:
ssl3_send_alert(s, SSL3_AL_FATAL, al);
OPENSSL_free(encodedPoint);
BN_CTX_free(bn_ctx);
#endif
- EVP_MD_CTX_destroy(md_ctx);
+ EVP_MD_CTX_free(md_ctx);
ossl_statem_set_error(s);
return 0;
}
long hdatalen = 0;
void *hdata;
- EVP_MD_CTX *mctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *mctx = EVP_MD_CTX_new();
if (mctx == NULL) {
SSLerr(SSL_F_TLS_PROCESS_CERT_VERIFY, ERR_R_MALLOC_FAILURE);
}
BIO_free(s->s3->handshake_buffer);
s->s3->handshake_buffer = NULL;
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
EVP_PKEY_free(pkey);
return ret;
}
chunk = EVP_MD_size(md);
OPENSSL_assert(chunk >= 0);
- ctx = EVP_MD_CTX_create();
- ctx_tmp = EVP_MD_CTX_create();
- ctx_init = EVP_MD_CTX_create();
+ ctx = EVP_MD_CTX_new();
+ ctx_tmp = EVP_MD_CTX_new();
+ ctx_init = EVP_MD_CTX_new();
if (ctx == NULL || ctx_tmp == NULL || ctx_init == NULL)
goto err;
EVP_MD_CTX_set_flags(ctx_init, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
ret = 1;
err:
EVP_PKEY_free(mac_key);
- EVP_MD_CTX_destroy(ctx);
- EVP_MD_CTX_destroy(ctx_tmp);
- EVP_MD_CTX_destroy(ctx_init);
+ EVP_MD_CTX_free(ctx);
+ EVP_MD_CTX_free(ctx_tmp);
+ EVP_MD_CTX_free(ctx_init);
OPENSSL_cleanse(A1, sizeof(A1));
return ret;
}
goto err;
dd = s->enc_write_ctx;
if (SSL_IS_DTLS(s)) {
- mac_ctx = EVP_MD_CTX_create();
+ mac_ctx = EVP_MD_CTX_new();
if (mac_ctx == NULL)
goto err;
s->write_hash = mac_ctx;
const char message[] = "abc";
unsigned char digest[20];
unsigned int dgst_len = 0;
- EVP_MD_CTX *md_ctx = EVP_MD_CTX_create();
+ EVP_MD_CTX *md_ctx = EVP_MD_CTX_new();
EC_KEY *key = NULL;
ECDSA_SIG *signature = NULL;
BIGNUM *r = NULL, *s = NULL;
ECDSA_SIG_free(signature);
BN_free(r);
BN_free(s);
- EVP_MD_CTX_destroy(md_ctx);
+ EVP_MD_CTX_free(md_ctx);
BN_clear_free(kinv);
BN_clear_free(rp);
return ret;
size_t sig_len = 0;
EVP_MD_CTX *md_ctx, *md_ctx_verify;
- md_ctx = EVP_MD_CTX_create();
- md_ctx_verify = EVP_MD_CTX_create();
+ md_ctx = EVP_MD_CTX_new();
+ md_ctx_verify = EVP_MD_CTX_new();
if (md_ctx == NULL || md_ctx_verify == NULL)
goto out;
ERR_print_errors_fp(stderr);
}
- EVP_MD_CTX_destroy(md_ctx);
- EVP_MD_CTX_destroy(md_ctx_verify);
+ EVP_MD_CTX_free(md_ctx);
+ EVP_MD_CTX_free(md_ctx_verify);
EVP_PKEY_free(pkey);
OPENSSL_free(sig);
EVP_PKEY *pkey = NULL;
EVP_MD_CTX *md_ctx;
- md_ctx = EVP_MD_CTX_create();
+ md_ctx = EVP_MD_CTX_new();
pkey = load_example_rsa_key();
if (pkey == NULL ||
ERR_print_errors_fp(stderr);
}
- EVP_MD_CTX_destroy(md_ctx);
+ EVP_MD_CTX_free(md_ctx);
EVP_PKEY_free(pkey);
return ret;
EVP_MD_CTX *mctx;
unsigned char md[EVP_MAX_MD_SIZE];
unsigned int md_len;
- mctx = EVP_MD_CTX_create();
+ mctx = EVP_MD_CTX_new();
if (!mctx)
goto err;
err = "DIGESTINIT_ERROR";
goto err;
err = NULL;
err:
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
t->err = err;
return 1;
}
if (!md)
goto err;
}
- mctx = EVP_MD_CTX_create();
+ mctx = EVP_MD_CTX_new();
if (!mctx)
goto err;
err = "DIGESTSIGNINIT_ERROR";
goto err;
err = NULL;
err:
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
OPENSSL_free(mac);
EVP_PKEY_CTX_free(genctx);
EVP_PKEY_free(key);
*/
continue;
}
- mctx = EVP_MD_CTX_create();
+ mctx = EVP_MD_CTX_new();
if (mctx == NULL) {
fflush(NULL);
fprintf(stderr, "ENGINE_ctrl_cmd_string: malloc failure\n");
siglen = 4;
OPENSSL_assert(EVP_DigestSignFinal(mctx, bTest, &siglen));
EVP_PKEY_free(mac_key);
- EVP_MD_CTX_destroy(mctx);
+ EVP_MD_CTX_free(mctx);
enlu = (int)tcs[t].ullLen;
enlf = 0;
l = siglen;
ebcdic2ascii(text, text, strlen(text));
# endif
- c = EVP_MD_CTX_create();
+ c = EVP_MD_CTX_new();
EVP_DigestInit_ex(c, EVP_mdc2(), NULL);
EVP_DigestUpdate(c, (unsigned char *)text, strlen(text));
EVP_DigestFinal_ex(c, &(md[0]), NULL);
} else
printf("pad2 - ok\n");
- EVP_MD_CTX_destroy(c);
+ EVP_MD_CTX_free(c);
# ifdef OPENSSL_SYS_NETWARE
if (ret)
printf("ERROR: %d\n", ret);
ebcdic2ascii(test[1], test[1], strlen(test[1]));
#endif
- c = EVP_MD_CTX_create();
+ c = EVP_MD_CTX_new();
P = test;
R = ret;
i = 1;
printf("ERROR: %d\n", err);
#endif
EXIT(err);
- EVP_MD_CTX_destroy(c);
+ EVP_MD_CTX_free(c);
return (0);
}
fprintf(stdout, ".");
fflush(stdout);
- evp = EVP_MD_CTX_create();
+ evp = EVP_MD_CTX_new();
if (evp == NULL) {
fflush(stdout);
fprintf(stderr, "\nTEST 3 of 3 failed. (malloc failure)\n");
fprintf(stdout, ".");
fflush(stdout);
- EVP_MD_CTX_init(evp);
+ EVP_MD_CTX_reset(evp);
EVP_DigestInit_ex(evp, EVP_sha224(), NULL);
for (i = 0; i < 1000000; i += 64)
EVP_DigestUpdate(evp, "aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa"
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa",
(1000000 - i) < 64 ? 1000000 - i : 64);
EVP_DigestFinal_ex(evp, md, NULL);
- EVP_MD_CTX_destroy(evp);
+ EVP_MD_CTX_free(evp);
if (memcmp(md, addenum_3, sizeof(addenum_3))) {
fflush(stdout);
fprintf(stdout, ".");
fflush(stdout);
- evp = EVP_MD_CTX_create();
+ evp = EVP_MD_CTX_new();
if (evp == NULL) {
fflush(stdout);
fprintf(stderr, "\nTEST 3 of 3 failed. (malloc failure)\n");
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa",
(1000000 - i) < 288 ? 1000000 - i : 288);
EVP_DigestFinal_ex(evp, md, NULL);
- EVP_MD_CTX_init(evp);
+ EVP_MD_CTX_reset(evp);
if (memcmp(md, app_c3, sizeof(app_c3))) {
fflush(stdout);
"aaaaaaaa" "aaaaaaaa" "aaaaaaaa" "aaaaaaaa",
(1000000 - i) < 64 ? 1000000 - i : 64);
EVP_DigestFinal_ex(evp, md, NULL);
- EVP_MD_CTX_destroy(evp);
+ EVP_MD_CTX_free(evp);
if (memcmp(md, app_d3, sizeof(app_d3))) {
fflush(stdout);