Latest update.
This commit is contained in:
@@ -2152,9 +2152,10 @@ static int tls_process_ske_dhe(SSL *s, PACKET *pkt, EVP_PKEY **pkey)
|
||||
ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
dh = NULL;
|
||||
|
||||
if (!ssl_security(s, SSL_SECOP_TMP_DH, EVP_PKEY_security_bits(peer_tmp),
|
||||
0, dh)) {
|
||||
0, EVP_PKEY_get0_DH(peer_tmp))) {
|
||||
SSLfatal(s, SSL_AD_HANDSHAKE_FAILURE, SSL_F_TLS_PROCESS_SKE_DHE,
|
||||
SSL_R_DH_KEY_TOO_SMALL);
|
||||
goto err;
|
||||
@@ -2226,6 +2227,21 @@ static int tls_process_ske_ecdhe(SSL *s, PACKET *pkt, EVP_PKEY **pkey)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO(3.0) Remove this when EVP_PKEY_get1_tls_encodedpoint()
|
||||
* knows how to get a key from an encoded point with the help of
|
||||
* a OSSL_SERIALIZER deserializer. We know that EVP_PKEY_get0()
|
||||
* downgrades an EVP_PKEY to contain a legacy key.
|
||||
*
|
||||
* THIS IS TEMPORARY
|
||||
*/
|
||||
EVP_PKEY_get0(s->s3.peer_tmp);
|
||||
if (EVP_PKEY_id(s->s3.peer_tmp) == EVP_PKEY_NONE) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_SKE_ECDHE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!EVP_PKEY_set1_tls_encodedpoint(s->s3.peer_tmp,
|
||||
PACKET_data(&encoded_pt),
|
||||
PACKET_remaining(&encoded_pt))) {
|
||||
@@ -2361,7 +2377,9 @@ MSG_PROCESS_RETURN tls_process_key_exchange(SSL *s, PACKET *pkt)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (EVP_DigestVerifyInit(md_ctx, &pctx, md, NULL, pkey) <= 0) {
|
||||
if (EVP_DigestVerifyInit_ex(md_ctx, &pctx,
|
||||
md == NULL ? NULL : EVP_MD_name(md),
|
||||
s->ctx->propq, pkey, s->ctx->libctx) <= 0) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_KEY_EXCHANGE,
|
||||
ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
@@ -2560,6 +2578,7 @@ MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt)
|
||||
unsigned int sess_len;
|
||||
RAW_EXTENSION *exts = NULL;
|
||||
PACKET nonce;
|
||||
EVP_MD *sha256 = NULL;
|
||||
|
||||
PACKET_null_init(&nonce);
|
||||
|
||||
@@ -2675,20 +2694,28 @@ MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt)
|
||||
* other way is to set zero length session ID when the ticket is
|
||||
* presented and rely on the handshake to determine session resumption.
|
||||
* We choose the former approach because this fits in with assumptions
|
||||
* elsewhere in OpenSSL. The session ID is set to the SHA256 (or SHA1 is
|
||||
* SHA256 is disabled) hash of the ticket.
|
||||
* elsewhere in OpenSSL. The session ID is set to the SHA256 hash of the
|
||||
* ticket.
|
||||
*/
|
||||
sha256 = EVP_MD_fetch(s->ctx->libctx, "SHA2-256", s->ctx->propq);
|
||||
if (sha256 == NULL) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_NEW_SESSION_TICKET,
|
||||
SSL_R_ALGORITHM_FETCH_FAILED);
|
||||
goto err;
|
||||
}
|
||||
/*
|
||||
* TODO(size_t): we use sess_len here because EVP_Digest expects an int
|
||||
* but s->session->session_id_length is a size_t
|
||||
*/
|
||||
if (!EVP_Digest(s->session->ext.tick, ticklen,
|
||||
s->session->session_id, &sess_len,
|
||||
EVP_sha256(), NULL)) {
|
||||
sha256, NULL)) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PROCESS_NEW_SESSION_TICKET,
|
||||
ERR_R_EVP_LIB);
|
||||
goto err;
|
||||
}
|
||||
EVP_MD_free(sha256);
|
||||
sha256 = NULL;
|
||||
s->session->session_id_length = sess_len;
|
||||
s->session->not_resumable = 0;
|
||||
|
||||
@@ -2727,6 +2754,7 @@ MSG_PROCESS_RETURN tls_process_new_session_ticket(SSL *s, PACKET *pkt)
|
||||
|
||||
return MSG_PROCESS_CONTINUE_READING;
|
||||
err:
|
||||
EVP_MD_free(sha256);
|
||||
OPENSSL_free(exts);
|
||||
return MSG_PROCESS_ERROR;
|
||||
}
|
||||
@@ -2990,7 +3018,8 @@ static int tls_construct_cke_rsa(SSL *s, WPACKET *pkt)
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
pctx = EVP_PKEY_CTX_new(pkey, NULL);
|
||||
|
||||
pctx = EVP_PKEY_CTX_new_from_pkey(s->ctx->libctx, pkey, s->ctx->propq);
|
||||
if (pctx == NULL || EVP_PKEY_encrypt_init(pctx) <= 0
|
||||
|| EVP_PKEY_encrypt(pctx, NULL, &enclen, pms, pmslen) <= 0) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_RSA,
|
||||
@@ -3115,6 +3144,21 @@ static int tls_construct_cke_ecdhe(SSL *s, WPACKET *pkt)
|
||||
goto err;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO(3.0) Remove this when EVP_PKEY_get1_tls_encodedpoint()
|
||||
* knows how to get a key from an encoded point with the help of
|
||||
* a OSSL_SERIALIZER deserializer. We know that EVP_PKEY_get0()
|
||||
* downgrades an EVP_PKEY to contain a legacy key.
|
||||
*
|
||||
* THIS IS TEMPORARY
|
||||
*/
|
||||
EVP_PKEY_get0(ckey);
|
||||
if (EVP_PKEY_id(skey) == EVP_PKEY_NONE) {
|
||||
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_CONSTRUCT_CKE_ECDHE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (ssl_derive(s, ckey, skey, 0) == 0) {
|
||||
/* SSLfatal() already called */
|
||||
goto err;
|
||||
|
||||
Reference in New Issue
Block a user