summaryrefslogtreecommitdiffstats
path: root/security/nss/gtests/ssl_gtest/ssl_v2_client_hello_unittest.cc
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-01-06 15:14:54 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-01-06 15:14:54 +0100
commitcc6a935ce54b573c1efd7533aff00e7bf0a9959c (patch)
treec8ad266edb7ea1e7b93aaaaa98847cf662373668 /security/nss/gtests/ssl_gtest/ssl_v2_client_hello_unittest.cc
parentd129c900c9f943adb69c1fb20ba1a029fdd95cff (diff)
parent9f4afc2552a67cc675b8b8af2ecb8ebc04a473a7 (diff)
downloadUXP-cc6a935ce54b573c1efd7533aff00e7bf0a9959c.tar
UXP-cc6a935ce54b573c1efd7533aff00e7bf0a9959c.tar.gz
UXP-cc6a935ce54b573c1efd7533aff00e7bf0a9959c.tar.lz
UXP-cc6a935ce54b573c1efd7533aff00e7bf0a9959c.tar.xz
UXP-cc6a935ce54b573c1efd7533aff00e7bf0a9959c.zip
Merge branch 'master' into Pale_Moon-release
# Conflicts: # application/palemoon/components/feeds/FeedWriter.js # application/palemoon/config/version.txt # security/manager/ssl/nsSTSPreloadList.errors # security/manager/ssl/nsSTSPreloadList.inc
Diffstat (limited to 'security/nss/gtests/ssl_gtest/ssl_v2_client_hello_unittest.cc')
-rw-r--r--security/nss/gtests/ssl_gtest/ssl_v2_client_hello_unittest.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/security/nss/gtests/ssl_gtest/ssl_v2_client_hello_unittest.cc b/security/nss/gtests/ssl_gtest/ssl_v2_client_hello_unittest.cc
index 100595732..cafbcce68 100644
--- a/security/nss/gtests/ssl_gtest/ssl_v2_client_hello_unittest.cc
+++ b/security/nss/gtests/ssl_gtest/ssl_v2_client_hello_unittest.cc
@@ -151,6 +151,7 @@ class SSLv2ClientHelloTestF : public TlsConnectTestBase {
void SetUp() override {
TlsConnectTestBase::SetUp();
filter_ = MakeTlsFilter<SSLv2ClientHelloFilter>(client_, version_);
+ server_->SetOption(SSL_ENABLE_V2_COMPATIBLE_HELLO, PR_TRUE);
}
void SetExpectedVersion(uint16_t version) {
@@ -197,6 +198,27 @@ TEST_P(SSLv2ClientHelloTest, Connect) {
Connect();
}
+TEST_P(SSLv2ClientHelloTest, ConnectDisabled) {
+ server_->SetOption(SSL_ENABLE_V2_COMPATIBLE_HELLO, PR_FALSE);
+ SetAvailableCipherSuite(TLS_DHE_RSA_WITH_AES_128_CBC_SHA);
+
+ StartConnect();
+ client_->Handshake(); // Send the modified ClientHello.
+ server_->Handshake(); // Read some.
+ // The problem here is that the v2 ClientHello puts the version where the v3
+ // ClientHello puts a version number. So the version number (0x0301+) appears
+ // to be a length and server blocks waiting for that much data.
+ EXPECT_EQ(PR_WOULD_BLOCK_ERROR, PORT_GetError());
+
+ // This is usually what happens with v2-compatible: the server hangs.
+ // But to be certain, feed in more data to see if an error comes out.
+ uint8_t zeros[SSL_LIBRARY_VERSION_TLS_1_2] = {0};
+ client_->SendDirect(DataBuffer(zeros, sizeof(zeros)));
+ ExpectAlert(server_, kTlsAlertIllegalParameter);
+ server_->Handshake();
+ client_->Handshake();
+}
+
// Sending a v2 ClientHello after a no-op v3 record must fail.
TEST_P(SSLv2ClientHelloTest, ConnectAfterEmptyV3Record) {
DataBuffer buffer;
@@ -328,6 +350,30 @@ TEST_P(SSLv2ClientHelloTest, RequireSafeRenegotiationWithSCSV) {
Connect();
}
+TEST_P(SSLv2ClientHelloTest, CheckServerRandom) {
+ ConfigureSessionCache(RESUME_NONE, RESUME_NONE);
+ SetAvailableCipherSuite(TLS_DHE_RSA_WITH_AES_128_CBC_SHA);
+
+ static const size_t random_len = 32;
+ uint8_t srandom1[random_len];
+ uint8_t z[random_len] = {0};
+
+ auto sh = MakeTlsFilter<TlsHandshakeRecorder>(server_, ssl_hs_server_hello);
+ Connect();
+ ASSERT_TRUE(sh->buffer().len() > (random_len + 2));
+ memcpy(srandom1, sh->buffer().data() + 2, random_len);
+ EXPECT_NE(0, memcmp(srandom1, z, random_len));
+
+ Reset();
+ sh = MakeTlsFilter<TlsHandshakeRecorder>(server_, ssl_hs_server_hello);
+ Connect();
+ ASSERT_TRUE(sh->buffer().len() > (random_len + 2));
+ const uint8_t* srandom2 = sh->buffer().data() + 2;
+
+ EXPECT_NE(0, memcmp(srandom2, z, random_len));
+ EXPECT_NE(0, memcmp(srandom1, srandom2, random_len));
+}
+
// Connect to the server with TLS 1.1, signalling that this is a fallback from
// a higher version. As the server doesn't support anything higher than TLS 1.1
// it must accept the connection.