chacha20poly1305
[openssl.git] / ssl / s3_lib.c
index 3f66235..25b652c 100644 (file)
@@ -161,6 +161,11 @@ const char ssl3_version_str[]="SSLv3" OPENSSL_VERSION_PTEXT;
 
 #define SSL3_NUM_CIPHERS       (sizeof(ssl3_ciphers)/sizeof(SSL_CIPHER))
 
+/* FIXED_NONCE_LEN is a macro that results in the correct value to set the
+ * fixed nonce length in SSL_CIPHER.algorithms2. It's the inverse of
+ * SSL_CIPHER_AEAD_FIXED_NONCE_LEN. */
+#define FIXED_NONCE_LEN(x) ((x/2)<<24)
+
 /* list of available SSLv3 ciphers (sorted by id) */
 OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
 
@@ -1831,7 +1836,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
+       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        128,
        128,
        },
@@ -1847,7 +1854,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
+       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        256,
        256,
        },
@@ -1863,7 +1872,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
+       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        128,
        128,
        },
@@ -1879,7 +1890,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
+       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        256,
        256,
        },
@@ -1895,7 +1908,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
+       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        128,
        128,
        },
@@ -1911,7 +1926,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
+       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        256,
        256,
        },
@@ -1927,7 +1944,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
+       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        128,
        128,
        },
@@ -1943,7 +1962,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
+       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        256,
        256,
        },
@@ -1959,7 +1980,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
+       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        128,
        128,
        },
@@ -1975,7 +1998,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
+       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        256,
        256,
        },
@@ -1991,7 +2016,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
+       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        128,
        128,
        },
@@ -2007,7 +2034,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
+       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        256,
        256,
        },
@@ -2720,7 +2749,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
+       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        128,
        128,
        },
@@ -2736,7 +2767,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
+       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        256,
        256,
        },
@@ -2752,7 +2785,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
+       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        128,
        128,
        },
@@ -2768,7 +2803,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
+       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        256,
        256,
        },
@@ -2784,7 +2821,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
+       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        128,
        128,
        },
@@ -2800,7 +2839,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
+       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        256,
        256,
        },
@@ -2816,7 +2857,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256,
+       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        128,
        128,
        },
@@ -2832,7 +2875,9 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        SSL_AEAD,
        SSL_TLSV1_2,
        SSL_NOT_EXP|SSL_HIGH|SSL_FIPS,
-       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384,
+       SSL_HANDSHAKE_MAC_SHA384|TLS1_PRF_SHA384|SSL_CIPHER_ALGORITHM2_AEAD|
+               FIXED_NONCE_LEN(4)|
+               SSL_CIPHER_ALGORITHM2_VARIABLE_NONCE_INCLUDED_IN_RECORD,
        256,
        256,
        },
@@ -2900,6 +2945,53 @@ OPENSSL_GLOBAL SSL_CIPHER ssl3_ciphers[]={
        },
 #endif
 
+#if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
+       {
+       1,
+       TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305,
+       TLS1_CK_ECDHE_RSA_CHACHA20_POLY1305,
+       SSL_kEECDH,
+       SSL_aRSA,
+       SSL_CHACHA20POLY1305,
+       SSL_AEAD,
+       SSL_TLSV1_2,
+       SSL_NOT_EXP|SSL_HIGH,
+       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(0),
+       256,
+       0,
+       },
+
+       {
+       1,
+       TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
+       TLS1_CK_ECDHE_ECDSA_CHACHA20_POLY1305,
+       SSL_kEECDH,
+       SSL_aECDSA,
+       SSL_CHACHA20POLY1305,
+       SSL_AEAD,
+       SSL_TLSV1_2,
+       SSL_NOT_EXP|SSL_HIGH,
+       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(0),
+       256,
+       0,
+       },
+
+       {
+       1,
+       TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305,
+       TLS1_CK_DHE_RSA_CHACHA20_POLY1305,
+       SSL_kEDH,
+       SSL_aRSA,
+       SSL_CHACHA20POLY1305,
+       SSL_AEAD,
+       SSL_TLSV1_2,
+       SSL_NOT_EXP|SSL_HIGH,
+       SSL_HANDSHAKE_MAC_SHA256|TLS1_PRF_SHA256|SSL_CIPHER_ALGORITHM2_AEAD|FIXED_NONCE_LEN(0),
+       256,
+       0,
+       },
+#endif
+
 /* end of list */
        };