Suite B support for DTLS 1.2
authorDr. Stephen Henson <steve@openssl.org>
Tue, 9 Apr 2013 14:57:39 +0000 (15:57 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Tue, 9 Apr 2013 15:49:13 +0000 (16:49 +0100)
Check for Suite B support using method flags instead of version numbers:
anything supporting TLS 1.2 cipher suites will also support Suite B.

Return an error if an attempt to use DTLS 1.0 is made in Suite B mode.

ssl/d1_srvr.c
ssl/s3_clnt.c
ssl/s3_srvr.c
ssl/ssl.h
ssl/ssl_ciph.c
ssl/ssl_err.c
ssl/ssl_locl.h

index 27f31b6762c81da83994e51ce2552c4309cd0bf8..c628db56ef89102b4235b33520bc1a515dfd3edb 100644 (file)
@@ -667,7 +667,7 @@ int dtls1_accept(SSL *s)
                                 */
                                if (!s->s3->handshake_buffer)
                                        {
                                 */
                                if (!s->s3->handshake_buffer)
                                        {
-                                       SSLerr(SSL_F_SSL3_ACCEPT,ERR_R_INTERNAL_ERROR);
+                                       SSLerr(SSL_F_DTLS1_ACCEPT,ERR_R_INTERNAL_ERROR);
                                        return -1;
                                        }
                                s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE;
                                        return -1;
                                        }
                                s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE;
index 44ff247db2d92beb6f781337c80bb4fafa4fc58c..018a9f590ce87eab3c24c722f0fb5f83609948ef 100644 (file)
@@ -701,6 +701,11 @@ int ssl3_client_hello(SSL *s)
                        /* If DTLS 1.2 disabled correct the version number */
                        if (options & SSL_OP_NO_DTLSv1_2)
                                {
                        /* If DTLS 1.2 disabled correct the version number */
                        if (options & SSL_OP_NO_DTLSv1_2)
                                {
+                               if (tls1_suiteb(s))
+                                       {
+                                       SSLerr(SSL_F_SSL3_CLIENT_HELLO, SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE);
+                                       goto err;
+                                       }
                                /* Disabling all versions is silly: return an
                                 * error.
                                 */
                                /* Disabling all versions is silly: return an
                                 * error.
                                 */
@@ -954,11 +959,23 @@ int ssl3_get_server_hello(SSL *s)
                if (hversion == DTLS1_2_VERSION
                        && !(options & SSL_OP_NO_DTLSv1_2))
                        s->method = DTLSv1_2_client_method();
                if (hversion == DTLS1_2_VERSION
                        && !(options & SSL_OP_NO_DTLSv1_2))
                        s->method = DTLSv1_2_client_method();
+               else if (tls1_suiteb(s))
+                       {
+                       SSLerr(SSL_F_SSL3_GET_SERVER_HELLO, SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE);
+                       s->version = hversion;
+                       al = SSL_AD_PROTOCOL_VERSION;
+                       goto f_err;
+                       }
                else if (hversion == DTLS1_VERSION
                        && !(options & SSL_OP_NO_DTLSv1))
                        s->method = DTLSv1_client_method();
                else
                else if (hversion == DTLS1_VERSION
                        && !(options & SSL_OP_NO_DTLSv1))
                        s->method = DTLSv1_client_method();
                else
+                       {
                        SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_SSL_VERSION);
                        SSLerr(SSL_F_SSL3_GET_SERVER_HELLO,SSL_R_WRONG_SSL_VERSION);
+                       s->version = hversion;
+                       al = SSL_AD_PROTOCOL_VERSION;
+                       goto f_err;
+                       }
                s->version = s->client_version = s->method->version;
                }
 
                s->version = s->client_version = s->method->version;
                }
 
index d915155e15f8a2e01037dce0ee4ad3c22dcb322a..ea4e132d979ca254c4dae3415948b4a951190bdb 100644 (file)
@@ -1096,6 +1096,13 @@ int ssl3_get_client_hello(SSL *s)
                                s->version = DTLS1_2_VERSION;
                                s->method = DTLSv1_2_server_method();
                                }
                                s->version = DTLS1_2_VERSION;
                                s->method = DTLSv1_2_server_method();
                                }
+                       else if (tls1_suiteb(s))
+                               {
+                               SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE);
+                               s->version = s->client_version;
+                               al = SSL_AD_PROTOCOL_VERSION;
+                               goto f_err;
+                               }
                        else if (s->client_version <= DTLS1_VERSION &&
                                !(s->options & SSL_OP_NO_DTLSv1))
                                {
                        else if (s->client_version <= DTLS1_VERSION &&
                                !(s->options & SSL_OP_NO_DTLSv1))
                                {
index cba5f4d748f9e85831dc15ba894a25e63f0fdda9..e14a8d4fdb373be3c794e2fa13d24742ecee37d1 100644 (file)
--- a/ssl/ssl.h
+++ b/ssl/ssl.h
@@ -2724,6 +2724,7 @@ void ERR_load_SSL_strings(void);
 #define SSL_R_NULL_SSL_METHOD_PASSED                    196
 #define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED           197
 #define SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED 344
 #define SSL_R_NULL_SSL_METHOD_PASSED                    196
 #define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED           197
 #define SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED 344
+#define SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE      387
 #define SSL_R_ONLY_TLS_1_2_ALLOWED_IN_SUITEB_MODE       379
 #define SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE             297
 #define SSL_R_OPAQUE_PRF_INPUT_TOO_LONG                         327
 #define SSL_R_ONLY_TLS_1_2_ALLOWED_IN_SUITEB_MODE       379
 #define SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE             297
 #define SSL_R_OPAQUE_PRF_INPUT_TOO_LONG                         327
index 4d87d2dbc4bf7f4b0b8a8f13c39e9cf41fe79e9b..1683f7bb1f3895c5d5db49ed647cf8777cc6fcde 100644 (file)
@@ -1377,11 +1377,15 @@ static int check_suiteb_cipher_list(const SSL_METHOD *meth, CERT *c,
 
        if (!suiteb_flags)
                return 1;
 
        if (!suiteb_flags)
                return 1;
-       /* Check version */
+       /* Check version: if TLS 1.2 ciphers allowed we can use Suite B */
 
 
-       if (meth->version != TLS1_2_VERSION)
+       if (!(meth->ssl3_enc->enc_flags & SSL_ENC_FLAG_TLS1_2_CIPHERS))
                {
                {
-               SSLerr(SSL_F_CHECK_SUITEB_CIPHER_LIST,
+               if (meth->ssl3_enc->enc_flags & SSL_ENC_FLAG_DTLS)
+                       SSLerr(SSL_F_CHECK_SUITEB_CIPHER_LIST,
+                               SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE);
+               else
+                       SSLerr(SSL_F_CHECK_SUITEB_CIPHER_LIST,
                                SSL_R_ONLY_TLS_1_2_ALLOWED_IN_SUITEB_MODE);
                return 0;
                }
                                SSL_R_ONLY_TLS_1_2_ALLOWED_IN_SUITEB_MODE);
                return 0;
                }
index b978177ac409adf3cb7dee7be23519ab3a83d3b6..7642758ef118deca57616c5043bab6a36f87fa8d 100644 (file)
@@ -1,6 +1,6 @@
 /* ssl/ssl_err.c */
 /* ====================================================================
 /* ssl/ssl_err.c */
 /* ====================================================================
- * Copyright (c) 1999-2012 The OpenSSL Project.  All rights reserved.
+ * Copyright (c) 1999-2013 The OpenSSL Project.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -479,6 +479,7 @@ static ERR_STRING_DATA SSL_str_reasons[]=
 {ERR_REASON(SSL_R_NULL_SSL_METHOD_PASSED),"null ssl method passed"},
 {ERR_REASON(SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED),"old session cipher not returned"},
 {ERR_REASON(SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED),"old session compression algorithm not returned"},
 {ERR_REASON(SSL_R_NULL_SSL_METHOD_PASSED),"null ssl method passed"},
 {ERR_REASON(SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED),"old session cipher not returned"},
 {ERR_REASON(SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED),"old session compression algorithm not returned"},
+{ERR_REASON(SSL_R_ONLY_DTLS_1_2_ALLOWED_IN_SUITEB_MODE),"only DTLS 1 2 allowed in suiteb mode"},
 {ERR_REASON(SSL_R_ONLY_TLS_1_2_ALLOWED_IN_SUITEB_MODE),"only TLS 1.2 allowed in Suite B mode"},
 {ERR_REASON(SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE),"only tls allowed in fips mode"},
 {ERR_REASON(SSL_R_OPAQUE_PRF_INPUT_TOO_LONG),"opaque PRF input too long"},
 {ERR_REASON(SSL_R_ONLY_TLS_1_2_ALLOWED_IN_SUITEB_MODE),"only TLS 1.2 allowed in Suite B mode"},
 {ERR_REASON(SSL_R_ONLY_TLS_ALLOWED_IN_FIPS_MODE),"only tls allowed in fips mode"},
 {ERR_REASON(SSL_R_OPAQUE_PRF_INPUT_TOO_LONG),"opaque PRF input too long"},
index f1cbc6f2ebbd19fc88b9fbe1bc3cd9834c4a4f9b..d06f9123433de769d3348cfebe669706f91ee910 100644 (file)
@@ -871,7 +871,7 @@ const SSL_METHOD *func_name(void)  \
        ssl23_get_cipher, \
        s_get_meth, \
        ssl23_default_timeout, \
        ssl23_get_cipher, \
        s_get_meth, \
        ssl23_default_timeout, \
-       &ssl3_undef_enc_method, \
+       &TLSv1_2_enc_data, \
        ssl_undefined_void_function, \
        ssl3_callback_ctrl, \
        ssl3_ctx_callback_ctrl, \
        ssl_undefined_void_function, \
        ssl3_callback_ctrl, \
        ssl3_ctx_callback_ctrl, \