Skip to content

Commit c785241

Browse files
snhensonandi34
authored andcommitted
Only allow ephemeral RSA keys in export ciphersuites.
OpenSSL clients would tolerate temporary RSA keys in non-export ciphersuites. It also had an option SSL_OP_EPHEMERAL_RSA which enabled this server side. Remove both options as they are a protocol violation. Thanks to Karthikeyan Bhargavan for reporting this issue. (CVE-2015-0204) Reviewed-by: Matt Caswell <matt@openssl.org> Conflicts: CHANGES doc/ssl/SSL_CTX_set_options.pod doc/ssl/SSL_CTX_set_tmp_rsa_callback.pod ssl/s3_srvr.c https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-0204 Change-Id: I034a600962e60a49bddab295ca5b3b0584182b8d
1 parent dd1da36 commit c785241

File tree

4 files changed

+21
-33
lines changed

4 files changed

+21
-33
lines changed

ssl/d1_srvr.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -449,24 +449,15 @@ int dtls1_accept(SSL *s)
449449
case SSL3_ST_SW_KEY_EXCH_B:
450450
alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
451451

452-
/* clear this, it may get reset by
453-
* send_server_key_exchange */
454-
if ((s->options & SSL_OP_EPHEMERAL_RSA)
455-
#ifndef OPENSSL_NO_KRB5
456-
&& !(alg_k & SSL_kKRB5)
457-
#endif /* OPENSSL_NO_KRB5 */
458-
)
459-
/* option SSL_OP_EPHEMERAL_RSA sends temporary RSA key
460-
* even when forbidden by protocol specs
461-
* (handshake may fail as clients are not required to
462-
* be able to handle this) */
463-
s->s3->tmp.use_rsa_tmp=1;
464-
else
465-
s->s3->tmp.use_rsa_tmp=0;
452+
/*
453+
* clear this, it may get reset by
454+
* send_server_key_exchange
455+
*/
456+
s->s3->tmp.use_rsa_tmp=0;
466457

467458
/* only send if a DH key exchange or
468459
* RSA but we have a sign only certificate */
469-
if (s->s3->tmp.use_rsa_tmp
460+
if (
470461
/* PSK: send ServerKeyExchange if PSK identity
471462
* hint if provided */
472463
#ifndef OPENSSL_NO_PSK

ssl/s3_clnt.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,6 +1554,13 @@ int ssl3_get_key_exchange(SSL *s)
15541554
#ifndef OPENSSL_NO_RSA
15551555
if (alg_k & SSL_kRSA)
15561556
{
1557+
/* Temporary RSA keys only allowed in export ciphersuites */
1558+
if (!SSL_C_IS_EXPORT(s->s3->tmp.new_cipher))
1559+
{
1560+
al=SSL_AD_UNEXPECTED_MESSAGE;
1561+
SSLerr(SSL_F_SSL3_GET_SERVER_CERTIFICATE,SSL_R_UNEXPECTED_MESSAGE);
1562+
goto f_err;
1563+
}
15571564
if ((rsa=RSA_new()) == NULL)
15581565
{
15591566
SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE,ERR_R_MALLOC_FAILURE);

ssl/s3_srvr.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -444,20 +444,11 @@ int ssl3_accept(SSL *s)
444444
case SSL3_ST_SW_KEY_EXCH_B:
445445
alg_k = s->s3->tmp.new_cipher->algorithm_mkey;
446446

447-
/* clear this, it may get reset by
448-
* send_server_key_exchange */
449-
if ((s->options & SSL_OP_EPHEMERAL_RSA)
450-
#ifndef OPENSSL_NO_KRB5
451-
&& !(alg_k & SSL_kKRB5)
452-
#endif /* OPENSSL_NO_KRB5 */
453-
)
454-
/* option SSL_OP_EPHEMERAL_RSA sends temporary RSA key
455-
* even when forbidden by protocol specs
456-
* (handshake may fail as clients are not required to
457-
* be able to handle this) */
458-
s->s3->tmp.use_rsa_tmp=1;
459-
else
460-
s->s3->tmp.use_rsa_tmp=0;
447+
/*
448+
* clear this, it may get reset by
449+
* send_server_key_exchange
450+
*/
451+
s->s3->tmp.use_rsa_tmp=0;
461452

462453

463454
/* only send if a DH key exchange, fortezza or
@@ -471,7 +462,7 @@ int ssl3_accept(SSL *s)
471462
* server certificate contains the server's
472463
* public key for key exchange.
473464
*/
474-
if (s->s3->tmp.use_rsa_tmp
465+
if (0
475466
/* PSK: send ServerKeyExchange if PSK identity
476467
* hint if provided */
477468
#ifndef OPENSSL_NO_PSK

ssl/ssl.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,9 +590,8 @@ struct ssl_session_st
590590
#define SSL_OP_SINGLE_ECDH_USE 0x00080000L
591591
/* If set, always create a new key when using tmp_dh parameters */
592592
#define SSL_OP_SINGLE_DH_USE 0x00100000L
593-
/* Set to always use the tmp_rsa key when doing RSA operations,
594-
* even when this violates protocol specs */
595-
#define SSL_OP_EPHEMERAL_RSA 0x00200000L
593+
/* Does nothing: retained for compatibiity */
594+
#define SSL_OP_EPHEMERAL_RSA 0x0
596595
/* Set on servers to choose the cipher according to the server's
597596
* preferences */
598597
#define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000L

0 commit comments

Comments
 (0)