Update to OpenSSL 1.0.2.o
This commit is contained in:
@@ -311,7 +311,12 @@ int ssl3_accept(SSL *s)
|
||||
goto end;
|
||||
}
|
||||
|
||||
ssl3_init_finished_mac(s);
|
||||
if (!ssl3_init_finished_mac(s)) {
|
||||
ret = -1;
|
||||
s->state = SSL_ST_ERR;
|
||||
goto end;
|
||||
}
|
||||
|
||||
s->state = SSL3_ST_SR_CLNT_HELLO_A;
|
||||
s->ctx->stats.sess_accept++;
|
||||
} else if (!s->s3->send_connection_binding &&
|
||||
@@ -348,7 +353,11 @@ int ssl3_accept(SSL *s)
|
||||
s->state = SSL3_ST_SW_FLUSH;
|
||||
s->init_num = 0;
|
||||
|
||||
ssl3_init_finished_mac(s);
|
||||
if (!ssl3_init_finished_mac(s)) {
|
||||
ret = -1;
|
||||
s->state = SSL_ST_ERR;
|
||||
goto end;
|
||||
}
|
||||
break;
|
||||
|
||||
case SSL3_ST_SW_HELLO_REQ_C:
|
||||
@@ -1704,6 +1713,12 @@ int ssl3_send_server_key_exchange(SSL *s)
|
||||
if (type & SSL_kEECDH) {
|
||||
const EC_GROUP *group;
|
||||
|
||||
if (s->s3->tmp.ecdh != NULL) {
|
||||
SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ecdhp = cert->ecdh_tmp;
|
||||
if (s->cert->ecdh_tmp_auto) {
|
||||
/* Get NID of appropriate shared curve */
|
||||
@@ -1724,17 +1739,7 @@ int ssl3_send_server_key_exchange(SSL *s)
|
||||
goto f_err;
|
||||
}
|
||||
|
||||
if (s->s3->tmp.ecdh != NULL) {
|
||||
SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE,
|
||||
ERR_R_INTERNAL_ERROR);
|
||||
goto err;
|
||||
}
|
||||
|
||||
/* Duplicate the ECDH structure. */
|
||||
if (ecdhp == NULL) {
|
||||
SSLerr(SSL_F_SSL3_SEND_SERVER_KEY_EXCHANGE, ERR_R_ECDH_LIB);
|
||||
goto err;
|
||||
}
|
||||
if (s->cert->ecdh_tmp_auto)
|
||||
ecdh = ecdhp;
|
||||
else if ((ecdh = EC_KEY_dup(ecdhp)) == NULL) {
|
||||
@@ -2084,7 +2089,7 @@ int ssl3_send_certificate_request(SSL *s)
|
||||
|
||||
if (SSL_USE_SIGALGS(s)) {
|
||||
const unsigned char *psigs;
|
||||
nl = tls12_get_psigalgs(s, &psigs);
|
||||
nl = tls12_get_psigalgs(s, 1, &psigs);
|
||||
s2n(nl, p);
|
||||
memcpy(p, psigs, nl);
|
||||
p += nl;
|
||||
@@ -2197,7 +2202,7 @@ int ssl3_get_client_key_exchange(SSL *s)
|
||||
unsigned char rand_premaster_secret[SSL_MAX_MASTER_KEY_LENGTH];
|
||||
int decrypt_len;
|
||||
unsigned char decrypt_good, version_good;
|
||||
size_t j;
|
||||
size_t j, padding_len;
|
||||
|
||||
/* FIX THIS UP EAY EAY EAY EAY */
|
||||
if (s->s3->tmp.use_rsa_tmp) {
|
||||
@@ -2265,16 +2270,38 @@ int ssl3_get_client_key_exchange(SSL *s)
|
||||
if (RAND_bytes(rand_premaster_secret,
|
||||
sizeof(rand_premaster_secret)) <= 0)
|
||||
goto err;
|
||||
decrypt_len =
|
||||
RSA_private_decrypt((int)n, p, p, rsa, RSA_PKCS1_PADDING);
|
||||
ERR_clear_error();
|
||||
|
||||
/*
|
||||
* decrypt_len should be SSL_MAX_MASTER_KEY_LENGTH. decrypt_good will
|
||||
* be 0xff if so and zero otherwise.
|
||||
* Decrypt with no padding. PKCS#1 padding will be removed as part of
|
||||
* the timing-sensitive code below.
|
||||
*/
|
||||
decrypt_good =
|
||||
constant_time_eq_int_8(decrypt_len, SSL_MAX_MASTER_KEY_LENGTH);
|
||||
decrypt_len =
|
||||
RSA_private_decrypt((int)n, p, p, rsa, RSA_NO_PADDING);
|
||||
if (decrypt_len < 0)
|
||||
goto err;
|
||||
|
||||
/* Check the padding. See RFC 3447, section 7.2.2. */
|
||||
|
||||
/*
|
||||
* The smallest padded premaster is 11 bytes of overhead. Small keys
|
||||
* are publicly invalid, so this may return immediately. This ensures
|
||||
* PS is at least 8 bytes.
|
||||
*/
|
||||
if (decrypt_len < 11 + SSL_MAX_MASTER_KEY_LENGTH) {
|
||||
al = SSL_AD_DECRYPT_ERROR;
|
||||
SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
|
||||
SSL_R_DECRYPTION_FAILED);
|
||||
goto f_err;
|
||||
}
|
||||
|
||||
padding_len = decrypt_len - SSL_MAX_MASTER_KEY_LENGTH;
|
||||
decrypt_good = constant_time_eq_int_8(p[0], 0) &
|
||||
constant_time_eq_int_8(p[1], 2);
|
||||
for (j = 2; j < padding_len - 1; j++) {
|
||||
decrypt_good &= ~constant_time_is_zero_8(p[j]);
|
||||
}
|
||||
decrypt_good &= constant_time_is_zero_8(p[padding_len - 1]);
|
||||
p += padding_len;
|
||||
|
||||
/*
|
||||
* If the version in the decrypted pre-master secret is correct then
|
||||
@@ -2483,7 +2510,7 @@ int ssl3_get_client_key_exchange(SSL *s)
|
||||
/*
|
||||
* Note that the length is checked again below, ** after decryption
|
||||
*/
|
||||
if (enc_pms.length > sizeof pms) {
|
||||
if (enc_pms.length > sizeof(pms)) {
|
||||
SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
|
||||
SSL_R_DATA_LENGTH_TOO_LONG);
|
||||
goto err;
|
||||
@@ -2536,7 +2563,7 @@ int ssl3_get_client_key_exchange(SSL *s)
|
||||
if (enc == NULL)
|
||||
goto err;
|
||||
|
||||
memset(iv, 0, sizeof iv); /* per RFC 1510 */
|
||||
memset(iv, 0, sizeof(iv)); /* per RFC 1510 */
|
||||
|
||||
if (!EVP_DecryptInit_ex(&ciph_ctx, enc, NULL, kssl_ctx->key, iv)) {
|
||||
SSLerr(SSL_F_SSL3_GET_CLIENT_KEY_EXCHANGE,
|
||||
@@ -3018,6 +3045,11 @@ int ssl3_get_cert_verify(SSL *s)
|
||||
|
||||
peer = s->session->peer;
|
||||
pkey = X509_get_pubkey(peer);
|
||||
if (pkey == NULL) {
|
||||
al = SSL_AD_INTERNAL_ERROR;
|
||||
goto f_err;
|
||||
}
|
||||
|
||||
type = X509_certificate_type(peer, pkey);
|
||||
|
||||
if (!(type & EVP_PKT_SIGN)) {
|
||||
@@ -3154,7 +3186,9 @@ int ssl3_get_cert_verify(SSL *s)
|
||||
goto f_err;
|
||||
}
|
||||
if (i != 64) {
|
||||
#ifdef SSL_DEBUG
|
||||
fprintf(stderr, "GOST signature length is %d", i);
|
||||
#endif
|
||||
}
|
||||
for (idx = 0; idx < 64; idx++) {
|
||||
signature[63 - idx] = p[idx];
|
||||
@@ -3463,8 +3497,22 @@ int ssl3_send_newsession_ticket(SSL *s)
|
||||
* all the work otherwise use generated values from parent ctx.
|
||||
*/
|
||||
if (tctx->tlsext_ticket_key_cb) {
|
||||
if (tctx->tlsext_ticket_key_cb(s, key_name, iv, &ctx,
|
||||
&hctx, 1) < 0)
|
||||
/* if 0 is returned, write en empty ticket */
|
||||
int ret = tctx->tlsext_ticket_key_cb(s, key_name, iv, &ctx,
|
||||
&hctx, 1);
|
||||
|
||||
if (ret == 0) {
|
||||
l2n(0, p); /* timeout */
|
||||
s2n(0, p); /* length */
|
||||
ssl_set_handshake_header(s, SSL3_MT_NEWSESSION_TICKET,
|
||||
p - ssl_handshake_start(s));
|
||||
s->state = SSL3_ST_SW_SESSION_TICKET_B;
|
||||
OPENSSL_free(senc);
|
||||
EVP_CIPHER_CTX_cleanup(&ctx);
|
||||
HMAC_CTX_cleanup(&hctx);
|
||||
return ssl_do_write(s);
|
||||
}
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
} else {
|
||||
if (RAND_bytes(iv, 16) <= 0)
|
||||
|
||||
Reference in New Issue
Block a user