-/* $OpenBSD: ssl_clnt.c,v 1.122 2021/12/04 13:50:35 jsing Exp $ */
+/* $OpenBSD: ssl_clnt.c,v 1.123 2021/12/09 17:50:48 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
{
CBS cbs, signature;
EVP_PKEY *pkey = NULL;
- EVP_MD_CTX md_ctx;
+ EVP_MD_CTX *md_ctx;
const unsigned char *param;
size_t param_len;
long alg_k, alg_a;
int al, ret;
- EVP_MD_CTX_init(&md_ctx);
-
alg_k = S3I(s)->hs.cipher->algorithm_mkey;
alg_a = S3I(s)->hs.cipher->algorithm_auth;
SSL3_ST_CR_KEY_EXCH_B, -1, s->internal->max_cert_list)) <= 0)
return ret;
+ if ((md_ctx = EVP_MD_CTX_new()) == NULL)
+ goto err;
+
if (s->internal->init_num < 0)
goto err;
}
S3I(s)->hs.tls12.reuse_message = 1;
- EVP_MD_CTX_cleanup(&md_ctx);
+ EVP_MD_CTX_free(md_ctx);
return (1);
}
}
S3I(s)->hs.peer_sigalg = sigalg;
- if (!EVP_DigestVerifyInit(&md_ctx, &pctx, sigalg->md(),
+ if (!EVP_DigestVerifyInit(md_ctx, &pctx, sigalg->md(),
NULL, pkey))
goto err;
- if (!EVP_DigestVerifyUpdate(&md_ctx, s->s3->client_random,
+ if (!EVP_DigestVerifyUpdate(md_ctx, s->s3->client_random,
SSL3_RANDOM_SIZE))
goto err;
if ((sigalg->flags & SIGALG_FLAG_RSA_PSS) &&
RSA_PKCS1_PSS_PADDING) ||
!EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1)))
goto err;
- if (!EVP_DigestVerifyUpdate(&md_ctx, s->s3->server_random,
+ if (!EVP_DigestVerifyUpdate(md_ctx, s->s3->server_random,
SSL3_RANDOM_SIZE))
goto err;
- if (!EVP_DigestVerifyUpdate(&md_ctx, param, param_len))
+ if (!EVP_DigestVerifyUpdate(md_ctx, param, param_len))
goto err;
- if (EVP_DigestVerifyFinal(&md_ctx, CBS_data(&signature),
+ if (EVP_DigestVerifyFinal(md_ctx, CBS_data(&signature),
CBS_len(&signature)) <= 0) {
al = SSL_AD_DECRYPT_ERROR;
SSLerror(s, SSL_R_BAD_SIGNATURE);
}
EVP_PKEY_free(pkey);
- EVP_MD_CTX_cleanup(&md_ctx);
+ EVP_MD_CTX_free(md_ctx);
return (1);
err:
EVP_PKEY_free(pkey);
- EVP_MD_CTX_cleanup(&md_ctx);
+ EVP_MD_CTX_free(md_ctx);
return (-1);
}
{
CBB cbb_signature;
EVP_PKEY_CTX *pctx = NULL;
- EVP_MD_CTX mctx;
+ EVP_MD_CTX *mctx = NULL;
const unsigned char *hdata;
unsigned char *signature = NULL;
size_t signature_len, hdata_len;
int ret = 0;
- EVP_MD_CTX_init(&mctx);
+ if ((mctx = EVP_MD_CTX_new()) == NULL)
+ goto err;
if (!tls1_transcript_data(s, &hdata, &hdata_len)) {
SSLerror(s, ERR_R_INTERNAL_ERROR);
goto err;
}
- if (!EVP_DigestSignInit(&mctx, &pctx, sigalg->md(), NULL, pkey)) {
+ if (!EVP_DigestSignInit(mctx, &pctx, sigalg->md(), NULL, pkey)) {
SSLerror(s, ERR_R_EVP_LIB);
goto err;
}
SSLerror(s, ERR_R_EVP_LIB);
goto err;
}
- if (!EVP_DigestSignUpdate(&mctx, hdata, hdata_len)) {
+ if (!EVP_DigestSignUpdate(mctx, hdata, hdata_len)) {
SSLerror(s, ERR_R_EVP_LIB);
goto err;
}
- if (!EVP_DigestSignFinal(&mctx, NULL, &signature_len) ||
+ if (!EVP_DigestSignFinal(mctx, NULL, &signature_len) ||
signature_len == 0) {
SSLerror(s, ERR_R_EVP_LIB);
goto err;
SSLerror(s, ERR_R_MALLOC_FAILURE);
goto err;
}
- if (!EVP_DigestSignFinal(&mctx, signature, &signature_len)) {
+ if (!EVP_DigestSignFinal(mctx, signature, &signature_len)) {
SSLerror(s, ERR_R_EVP_LIB);
goto err;
}
ret = 1;
err:
- EVP_MD_CTX_cleanup(&mctx);
+ EVP_MD_CTX_free(mctx);
free(signature);
return ret;
}
ssl3_send_client_verify_gost(SSL *s, EVP_PKEY *pkey, CBB *cert_verify)
{
CBB cbb_signature;
- EVP_MD_CTX mctx;
+ EVP_MD_CTX *mctx;
EVP_PKEY_CTX *pctx;
const EVP_MD *md;
const unsigned char *hdata;
int nid;
int ret = 0;
- EVP_MD_CTX_init(&mctx);
+ if ((mctx = EVP_MD_CTX_new()) == NULL)
+ goto err;
if (!tls1_transcript_data(s, &hdata, &hdata_len)) {
SSLerror(s, ERR_R_INTERNAL_ERROR);
SSLerror(s, ERR_R_EVP_LIB);
goto err;
}
- if (!EVP_DigestSignInit(&mctx, &pctx, md, NULL, pkey)) {
+ if (!EVP_DigestSignInit(mctx, &pctx, md, NULL, pkey)) {
SSLerror(s, ERR_R_EVP_LIB);
goto err;
}
SSLerror(s, ERR_R_EVP_LIB);
goto err;
}
- if (!EVP_DigestSignUpdate(&mctx, hdata, hdata_len)) {
+ if (!EVP_DigestSignUpdate(mctx, hdata, hdata_len)) {
SSLerror(s, ERR_R_EVP_LIB);
goto err;
}
- if (!EVP_DigestSignFinal(&mctx, NULL, &signature_len) ||
+ if (!EVP_DigestSignFinal(mctx, NULL, &signature_len) ||
signature_len == 0) {
SSLerror(s, ERR_R_EVP_LIB);
goto err;
SSLerror(s, ERR_R_MALLOC_FAILURE);
goto err;
}
- if (!EVP_DigestSignFinal(&mctx, signature, &signature_len)) {
+ if (!EVP_DigestSignFinal(mctx, signature, &signature_len)) {
SSLerror(s, ERR_R_EVP_LIB);
goto err;
}
ret = 1;
err:
- EVP_MD_CTX_cleanup(&mctx);
+ EVP_MD_CTX_free(mctx);
free(signature);
return ret;
}