Skip to content

Commit

Permalink
Add support for TLS_FALLBACK_SCSV
Browse files Browse the repository at this point in the history
Includes changes to openssl.config not present in the original
commit.

Bug: 17750026
(cherry-picked from commit 9a68a8f)

Change-Id: I89ed89b87b4f4eeeddb6de0c6ad1d48cb6d0ee7b
  • Loading branch information
Bodo Moeller authored and andi34 committed Jun 7, 2016
1 parent 6b408ee commit ad41f66
Show file tree
Hide file tree
Showing 22 changed files with 662 additions and 32 deletions.
10 changes: 10 additions & 0 deletions apps/s_client.c
Expand Up @@ -335,6 +335,7 @@ static void sc_usage(void)
BIO_printf(bio_err," -tls1_1 - just use TLSv1.1\n");
BIO_printf(bio_err," -tls1 - just use TLSv1\n");
BIO_printf(bio_err," -dtls1 - just use DTLSv1\n");
BIO_printf(bio_err," -fallback_scsv - send TLS_FALLBACK_SCSV\n");
BIO_printf(bio_err," -mtu - set the link layer MTU\n");
BIO_printf(bio_err," -no_tls1_2/-no_tls1_1/-no_tls1/-no_ssl3/-no_ssl2 - turn off that protocol\n");
BIO_printf(bio_err," -bugs - Switch on all SSL implementation bug workarounds\n");
Expand Down Expand Up @@ -619,6 +620,7 @@ int MAIN(int argc, char **argv)
char *sess_out = NULL;
struct sockaddr peer;
int peerlen = sizeof(peer);
int fallback_scsv = 0;
int enable_timeouts = 0 ;
long socket_mtu = 0;
#ifndef OPENSSL_NO_JPAKE
Expand Down Expand Up @@ -825,6 +827,10 @@ int MAIN(int argc, char **argv)
meth=DTLSv1_client_method();
socket_type=SOCK_DGRAM;
}
else if (strcmp(*argv,"-fallback_scsv") == 0)
{
fallback_scsv = 1;
}
else if (strcmp(*argv,"-timeout") == 0)
enable_timeouts=1;
else if (strcmp(*argv,"-mtu") == 0)
Expand Down Expand Up @@ -1267,6 +1273,10 @@ int MAIN(int argc, char **argv)
SSL_set_session(con, sess);
SSL_SESSION_free(sess);
}

if (fallback_scsv)
SSL_set_mode(con, SSL_MODE_SEND_FALLBACK_SCSV);

#ifndef OPENSSL_NO_TLSEXT
if (servername != NULL)
{
Expand Down
1 change: 1 addition & 0 deletions crypto/err/openssl.ec
Expand Up @@ -71,6 +71,7 @@ R SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060
R SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070
R SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071
R SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080
R SSL_R_SSLV3_ALERT_INAPPROPRIATE_FALLBACK 1086
R SSL_R_TLSV1_ALERT_USER_CANCELLED 1090
R SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100
R SSL_R_TLSV1_UNSUPPORTED_EXTENSION 1110
Expand Down
3 changes: 2 additions & 1 deletion include/openssl/dtls1.h
Expand Up @@ -84,6 +84,8 @@ extern "C" {
#endif

#define DTLS1_VERSION 0xFEFF
#define DTLS_MAX_VERSION DTLS1_VERSION

#define DTLS1_BAD_VER 0x0100

#if 0
Expand Down Expand Up @@ -284,4 +286,3 @@ typedef struct dtls1_record_data_st
}
#endif
#endif

10 changes: 10 additions & 0 deletions include/openssl/ssl.h
Expand Up @@ -646,6 +646,11 @@ struct ssl_session_st
* one RTT. */
#define SSL_MODE_HANDSHAKE_CUTTHROUGH 0x00000020L

/* Send TLS_FALLBACK_SCSV in the ClientHello.
* To be set by applications that reconnect with a downgraded protocol
* version; see draft-ietf-tls-downgrade-scsv-00 for details. */
#define SSL_MODE_SEND_FALLBACK_SCSV 0x00000200L

/* Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value,
* they cannot be used to clear bits. */

Expand Down Expand Up @@ -1570,6 +1575,7 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)
#define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE
#define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE
#define SSL_AD_UNKNOWN_PSK_IDENTITY TLS1_AD_UNKNOWN_PSK_IDENTITY /* fatal */
#define SSL_AD_INAPPROPRIATE_FALLBACK TLS1_AD_INAPPROPRIATE_FALLBACK /* fatal */

#define SSL_ERROR_NONE 0
#define SSL_ERROR_SSL 1
Expand Down Expand Up @@ -1683,6 +1689,8 @@ DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION)
#define SSL_CTRL_GET_EXTRA_CHAIN_CERTS 82
#define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS 83

#define SSL_CTRL_CHECK_PROTO_VERSION 119

#define DTLSv1_get_timeout(ssl, arg) \
SSL_ctrl(ssl,DTLS_CTRL_GET_TIMEOUT,0, (void *)arg)
#define DTLSv1_handle_timeout(ssl) \
Expand Down Expand Up @@ -2472,6 +2480,7 @@ void ERR_load_SSL_strings(void);
#define SSL_R_HTTPS_PROXY_REQUEST 155
#define SSL_R_HTTP_REQUEST 156
#define SSL_R_ILLEGAL_PADDING 283
#define SSL_R_INAPPROPRIATE_FALLBACK 380
#define SSL_R_INCONSISTENT_COMPRESSION 340
#define SSL_R_INVALID_CHALLENGE_LENGTH 158
#define SSL_R_INVALID_COMMAND 280
Expand Down Expand Up @@ -2621,6 +2630,7 @@ void ERR_load_SSL_strings(void);
#define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021
#define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051
#define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060
#define SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK 1086
#define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071
#define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080
#define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100
Expand Down
7 changes: 6 additions & 1 deletion include/openssl/ssl3.h
Expand Up @@ -128,9 +128,14 @@
extern "C" {
#endif

/* Signalling cipher suite value: from draft-ietf-tls-renegotiation-03.txt */
/* Signalling cipher suite value from RFC 5746
* (TLS_EMPTY_RENEGOTIATION_INFO_SCSV) */
#define SSL3_CK_SCSV 0x030000FF

/* Signalling cipher suite value from draft-ietf-tls-downgrade-scsv-00
* (TLS_FALLBACK_SCSV) */
#define SSL3_CK_FALLBACK_SCSV 0x03005600

#define SSL3_CK_RSA_NULL_MD5 0x03000001
#define SSL3_CK_RSA_NULL_SHA 0x03000002
#define SSL3_CK_RSA_RC4_40_MD5 0x03000003
Expand Down
15 changes: 9 additions & 6 deletions include/openssl/tls1.h
Expand Up @@ -159,17 +159,19 @@ extern "C" {

#define TLS1_ALLOW_EXPERIMENTAL_CIPHERSUITES 0

#define TLS1_VERSION 0x0301
#define TLS1_1_VERSION 0x0302
#define TLS1_2_VERSION 0x0303
#define TLS1_2_VERSION_MAJOR 0x03
#define TLS1_2_VERSION_MINOR 0x03
#define TLS_MAX_VERSION TLS1_2_VERSION

#define TLS1_VERSION_MAJOR 0x03
#define TLS1_VERSION_MINOR 0x01

#define TLS1_1_VERSION 0x0302
#define TLS1_1_VERSION_MAJOR 0x03
#define TLS1_1_VERSION_MINOR 0x02

#define TLS1_VERSION 0x0301
#define TLS1_VERSION_MAJOR 0x03
#define TLS1_VERSION_MINOR 0x01
#define TLS1_2_VERSION_MAJOR 0x03
#define TLS1_2_VERSION_MINOR 0x03

#define TLS1_get_version(s) \
((s->version >> 8) == TLS1_VERSION_MAJOR ? s->version : 0)
Expand All @@ -187,6 +189,7 @@ extern "C" {
#define TLS1_AD_PROTOCOL_VERSION 70 /* fatal */
#define TLS1_AD_INSUFFICIENT_SECURITY 71 /* fatal */
#define TLS1_AD_INTERNAL_ERROR 80 /* fatal */
#define TLS1_AD_INAPPROPRIATE_FALLBACK 86 /* fatal */
#define TLS1_AD_USER_CANCELLED 90
#define TLS1_AD_NO_RENEGOTIATION 100
/* codes 110-114 are from RFC3546 */
Expand Down
22 changes: 22 additions & 0 deletions openssl.config
Expand Up @@ -994,6 +994,7 @@ fix_clang_build.patch \
tls12_digests.patch \
alpn.patch \
early_ccs.patch \
0018-tls_fallback_scsv.patch \
"

OPENSSL_PATCHES_progs_SOURCES="\
Expand Down Expand Up @@ -1077,3 +1078,24 @@ ssl/ssl.h \
ssl/ssl3.h \
ssl/ssl_err.c \
"

OPENSSL_PATCHES_fallback_scsv_SOURCES="\
crypto/err/openssl.ec \
include/openssl/dtls1.h \
include/openssl/ssl.h \
include/openssl/ssl3.h \
include/openssl/tls1.h \
ssl/d1_lib.c \
ssl/dtls1.h \
ssl/s23_clnt.c \
ssl/s23_srvr.c \
ssl/s2_lib.c \
ssl/s3_enc.c \
ssl/s3_lib.c \
ssl/ssl.h \
ssl/ssl3.h \
ssl/ssl_err.c \
ssl/ssl_lib.c \
ssl/t1_enc.c \
ssl/tls1.h \
"

0 comments on commit ad41f66

Please sign in to comment.