mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-20 15:27:32 +09:00
nss: update to 3.44.1, with vc2013 fix and gyp fix
This commit is contained in:
parent
a2ef5fcde7
commit
d4b834111b
553 changed files with 1515569 additions and 1130 deletions
|
|
@ -36,6 +36,12 @@ CPPSRCS := $(filter-out $(shell grep -l '^TEST_F' $(CPPSRCS)), $(CPPSRCS))
|
|||
CFLAGS += -DNSS_DISABLE_TLS_1_3
|
||||
endif
|
||||
|
||||
ifdef NSS_ALLOW_SSLKEYLOGFILE
|
||||
SSLKEYLOGFILE_FILES = ssl_keylog_unittest.cc
|
||||
else
|
||||
SSLKEYLOGFILE_FILES = $(NULL)
|
||||
endif
|
||||
|
||||
#######################################################################
|
||||
# (5) Execute "global" rules. (OPTIONAL) #
|
||||
#######################################################################
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ CPPSRCS = \
|
|||
ssl_gather_unittest.cc \
|
||||
ssl_gtest.cc \
|
||||
ssl_hrr_unittest.cc \
|
||||
ssl_keylog_unittest.cc \
|
||||
ssl_keyupdate_unittest.cc \
|
||||
ssl_loopback_unittest.cc \
|
||||
ssl_misc_unittest.cc \
|
||||
|
|
@ -55,6 +54,7 @@ CPPSRCS = \
|
|||
tls_filter.cc \
|
||||
tls_protect.cc \
|
||||
tls_esni_unittest.cc \
|
||||
$(SSLKEYLOGFILE_FILES) \
|
||||
$(NULL)
|
||||
|
||||
INCLUDES += -I$(CORE_DEPTH)/gtests/google_test/gtest/include \
|
||||
|
|
|
|||
|
|
@ -649,6 +649,227 @@ TEST_P(TlsConnectTls13, ZeroRttOrdering) {
|
|||
EXPECT_EQ(2U, step);
|
||||
}
|
||||
|
||||
// Early data remains available after the handshake completes for TLS.
|
||||
TEST_F(TlsConnectStreamTls13, ZeroRttLateReadTls) {
|
||||
SetupForZeroRtt();
|
||||
client_->Set0RttEnabled(true);
|
||||
server_->Set0RttEnabled(true);
|
||||
ExpectResumption(RESUME_TICKET);
|
||||
client_->Handshake(); // ClientHello
|
||||
|
||||
// Write some early data.
|
||||
const uint8_t data[] = {1, 2, 3, 4, 5, 6, 7, 8};
|
||||
PRInt32 rv = PR_Write(client_->ssl_fd(), data, sizeof(data));
|
||||
EXPECT_EQ(static_cast<PRInt32>(sizeof(data)), rv);
|
||||
|
||||
// Consume the ClientHello and generate ServerHello..Finished.
|
||||
server_->Handshake();
|
||||
|
||||
// Read some of the data.
|
||||
std::vector<uint8_t> small_buffer(1 + sizeof(data) / 2);
|
||||
rv = PR_Read(server_->ssl_fd(), small_buffer.data(), small_buffer.size());
|
||||
EXPECT_EQ(static_cast<PRInt32>(small_buffer.size()), rv);
|
||||
EXPECT_EQ(0, memcmp(data, small_buffer.data(), small_buffer.size()));
|
||||
|
||||
Handshake(); // Complete the handshake.
|
||||
ExpectEarlyDataAccepted(true);
|
||||
CheckConnected();
|
||||
|
||||
// After the handshake, it should be possible to read the remainder.
|
||||
uint8_t big_buf[100];
|
||||
rv = PR_Read(server_->ssl_fd(), big_buf, sizeof(big_buf));
|
||||
EXPECT_EQ(static_cast<PRInt32>(sizeof(data) - small_buffer.size()), rv);
|
||||
EXPECT_EQ(0, memcmp(&data[small_buffer.size()], big_buf,
|
||||
sizeof(data) - small_buffer.size()));
|
||||
|
||||
// And that's all there is to read.
|
||||
rv = PR_Read(server_->ssl_fd(), big_buf, sizeof(big_buf));
|
||||
EXPECT_GT(0, rv);
|
||||
EXPECT_EQ(PR_WOULD_BLOCK_ERROR, PORT_GetError());
|
||||
}
|
||||
|
||||
// Early data that arrives before the handshake can be read after the handshake
|
||||
// is complete.
|
||||
TEST_F(TlsConnectDatagram13, ZeroRttLateReadDtls) {
|
||||
SetupForZeroRtt();
|
||||
client_->Set0RttEnabled(true);
|
||||
server_->Set0RttEnabled(true);
|
||||
ExpectResumption(RESUME_TICKET);
|
||||
client_->Handshake(); // ClientHello
|
||||
|
||||
// Write some early data.
|
||||
const uint8_t data[] = {1, 2, 3};
|
||||
PRInt32 written = PR_Write(client_->ssl_fd(), data, sizeof(data));
|
||||
EXPECT_EQ(static_cast<PRInt32>(sizeof(data)), written);
|
||||
|
||||
Handshake(); // Complete the handshake.
|
||||
ExpectEarlyDataAccepted(true);
|
||||
CheckConnected();
|
||||
|
||||
// Reading at the server should return the early data, which was buffered.
|
||||
uint8_t buf[sizeof(data) + 1] = {0};
|
||||
PRInt32 read = PR_Read(server_->ssl_fd(), buf, sizeof(buf));
|
||||
EXPECT_EQ(static_cast<PRInt32>(sizeof(data)), read);
|
||||
EXPECT_EQ(0, memcmp(data, buf, sizeof(data)));
|
||||
}
|
||||
|
||||
class PacketHolder : public PacketFilter {
|
||||
public:
|
||||
PacketHolder() = default;
|
||||
|
||||
virtual Action Filter(const DataBuffer& input, DataBuffer* output) {
|
||||
packet_ = input;
|
||||
Disable();
|
||||
return DROP;
|
||||
}
|
||||
|
||||
const DataBuffer& packet() const { return packet_; }
|
||||
|
||||
private:
|
||||
DataBuffer packet_;
|
||||
};
|
||||
|
||||
// Early data that arrives late is discarded for DTLS.
|
||||
TEST_F(TlsConnectDatagram13, ZeroRttLateArrivalDtls) {
|
||||
SetupForZeroRtt();
|
||||
client_->Set0RttEnabled(true);
|
||||
server_->Set0RttEnabled(true);
|
||||
ExpectResumption(RESUME_TICKET);
|
||||
client_->Handshake(); // ClientHello
|
||||
|
||||
// Write some early data. Twice, so that we can read bits of it.
|
||||
const uint8_t data[] = {1, 2, 3};
|
||||
PRInt32 written = PR_Write(client_->ssl_fd(), data, sizeof(data));
|
||||
EXPECT_EQ(static_cast<PRInt32>(sizeof(data)), written);
|
||||
|
||||
// Block and capture the next packet.
|
||||
auto holder = std::make_shared<PacketHolder>();
|
||||
client_->SetFilter(holder);
|
||||
written = PR_Write(client_->ssl_fd(), data, sizeof(data));
|
||||
EXPECT_EQ(static_cast<PRInt32>(sizeof(data)), written);
|
||||
EXPECT_FALSE(holder->enabled()) << "the filter should disable itself";
|
||||
|
||||
// Consume the ClientHello and generate ServerHello..Finished.
|
||||
server_->Handshake();
|
||||
|
||||
// Read some of the data.
|
||||
std::vector<uint8_t> small_buffer(sizeof(data));
|
||||
PRInt32 read =
|
||||
PR_Read(server_->ssl_fd(), small_buffer.data(), small_buffer.size());
|
||||
|
||||
EXPECT_EQ(static_cast<PRInt32>(small_buffer.size()), read);
|
||||
EXPECT_EQ(0, memcmp(data, small_buffer.data(), small_buffer.size()));
|
||||
|
||||
Handshake(); // Complete the handshake.
|
||||
ExpectEarlyDataAccepted(true);
|
||||
CheckConnected();
|
||||
|
||||
server_->SendDirect(holder->packet());
|
||||
|
||||
// Reading now should return nothing, even though a valid packet was
|
||||
// delivered.
|
||||
read = PR_Read(server_->ssl_fd(), small_buffer.data(), small_buffer.size());
|
||||
EXPECT_GT(0, read);
|
||||
EXPECT_EQ(PR_WOULD_BLOCK_ERROR, PORT_GetError());
|
||||
}
|
||||
|
||||
// Early data reads in TLS should be coalesced.
|
||||
TEST_F(TlsConnectStreamTls13, ZeroRttCoalesceReadTls) {
|
||||
SetupForZeroRtt();
|
||||
client_->Set0RttEnabled(true);
|
||||
server_->Set0RttEnabled(true);
|
||||
ExpectResumption(RESUME_TICKET);
|
||||
client_->Handshake(); // ClientHello
|
||||
|
||||
// Write some early data. In two writes.
|
||||
const uint8_t data[] = {1, 2, 3, 4, 5, 6};
|
||||
PRInt32 written = PR_Write(client_->ssl_fd(), data, 1);
|
||||
EXPECT_EQ(1, written);
|
||||
|
||||
written = PR_Write(client_->ssl_fd(), data + 1, sizeof(data) - 1);
|
||||
EXPECT_EQ(static_cast<PRInt32>(sizeof(data) - 1), written);
|
||||
|
||||
// Consume the ClientHello and generate ServerHello..Finished.
|
||||
server_->Handshake();
|
||||
|
||||
// Read all of the data.
|
||||
std::vector<uint8_t> buffer(sizeof(data));
|
||||
PRInt32 read = PR_Read(server_->ssl_fd(), buffer.data(), buffer.size());
|
||||
EXPECT_EQ(static_cast<PRInt32>(sizeof(data)), read);
|
||||
EXPECT_EQ(0, memcmp(data, buffer.data(), sizeof(data)));
|
||||
|
||||
Handshake(); // Complete the handshake.
|
||||
ExpectEarlyDataAccepted(true);
|
||||
CheckConnected();
|
||||
}
|
||||
|
||||
// Early data reads in DTLS should not be coalesced.
|
||||
TEST_F(TlsConnectDatagram13, ZeroRttNoCoalesceReadDtls) {
|
||||
SetupForZeroRtt();
|
||||
client_->Set0RttEnabled(true);
|
||||
server_->Set0RttEnabled(true);
|
||||
ExpectResumption(RESUME_TICKET);
|
||||
client_->Handshake(); // ClientHello
|
||||
|
||||
// Write some early data. In two writes.
|
||||
const uint8_t data[] = {1, 2, 3, 4, 5, 6};
|
||||
PRInt32 written = PR_Write(client_->ssl_fd(), data, 1);
|
||||
EXPECT_EQ(1, written);
|
||||
|
||||
written = PR_Write(client_->ssl_fd(), data + 1, sizeof(data) - 1);
|
||||
EXPECT_EQ(static_cast<PRInt32>(sizeof(data) - 1), written);
|
||||
|
||||
// Consume the ClientHello and generate ServerHello..Finished.
|
||||
server_->Handshake();
|
||||
|
||||
// Try to read all of the data.
|
||||
std::vector<uint8_t> buffer(sizeof(data));
|
||||
PRInt32 read = PR_Read(server_->ssl_fd(), buffer.data(), buffer.size());
|
||||
EXPECT_EQ(1, read);
|
||||
EXPECT_EQ(0, memcmp(data, buffer.data(), 1));
|
||||
|
||||
// Read the remainder.
|
||||
read = PR_Read(server_->ssl_fd(), buffer.data(), buffer.size());
|
||||
EXPECT_EQ(static_cast<PRInt32>(sizeof(data) - 1), read);
|
||||
EXPECT_EQ(0, memcmp(data + 1, buffer.data(), sizeof(data) - 1));
|
||||
|
||||
Handshake(); // Complete the handshake.
|
||||
ExpectEarlyDataAccepted(true);
|
||||
CheckConnected();
|
||||
}
|
||||
|
||||
// Early data reads in DTLS should fail if the buffer is too small.
|
||||
TEST_F(TlsConnectDatagram13, ZeroRttShortReadDtls) {
|
||||
SetupForZeroRtt();
|
||||
client_->Set0RttEnabled(true);
|
||||
server_->Set0RttEnabled(true);
|
||||
ExpectResumption(RESUME_TICKET);
|
||||
client_->Handshake(); // ClientHello
|
||||
|
||||
// Write some early data. In two writes.
|
||||
const uint8_t data[] = {1, 2, 3, 4, 5, 6};
|
||||
PRInt32 written = PR_Write(client_->ssl_fd(), data, sizeof(data));
|
||||
EXPECT_EQ(static_cast<PRInt32>(sizeof(data)), written);
|
||||
|
||||
// Consume the ClientHello and generate ServerHello..Finished.
|
||||
server_->Handshake();
|
||||
|
||||
// Try to read all of the data into a small buffer.
|
||||
std::vector<uint8_t> buffer(sizeof(data));
|
||||
PRInt32 read = PR_Read(server_->ssl_fd(), buffer.data(), 1);
|
||||
EXPECT_GT(0, read);
|
||||
EXPECT_EQ(SSL_ERROR_RX_SHORT_DTLS_READ, PORT_GetError());
|
||||
|
||||
// Read again with more space.
|
||||
read = PR_Read(server_->ssl_fd(), buffer.data(), buffer.size());
|
||||
EXPECT_EQ(static_cast<PRInt32>(sizeof(data)), read);
|
||||
EXPECT_EQ(0, memcmp(data, buffer.data(), sizeof(data)));
|
||||
|
||||
Handshake(); // Complete the handshake.
|
||||
ExpectEarlyDataAccepted(true);
|
||||
CheckConnected();
|
||||
}
|
||||
|
||||
#ifndef NSS_DISABLE_TLS_1_3
|
||||
INSTANTIATE_TEST_CASE_P(Tls13ZeroRttReplayTest, TlsZeroRttReplayTest,
|
||||
TlsConnectTestBase::kTlsVariantsAll);
|
||||
|
|
|
|||
|
|
@ -320,6 +320,46 @@ TEST_F(TlsConnectStreamTls13, PostHandshakeAuthConcurrent) {
|
|||
EXPECT_EQ(PR_WOULD_BLOCK_ERROR, PORT_GetError());
|
||||
}
|
||||
|
||||
TEST_F(TlsConnectStreamTls13, PostHandshakeAuthBeforeKeyUpdate) {
|
||||
client_->SetupClientAuth();
|
||||
EXPECT_EQ(SECSuccess, SSL_OptionSet(client_->ssl_fd(),
|
||||
SSL_ENABLE_POST_HANDSHAKE_AUTH, PR_TRUE));
|
||||
Connect();
|
||||
// Send CertificateRequest.
|
||||
EXPECT_EQ(SECSuccess, SSL_SendCertificateRequest(server_->ssl_fd()))
|
||||
<< "Unexpected error: " << PORT_ErrorToName(PORT_GetError());
|
||||
// Send KeyUpdate.
|
||||
EXPECT_EQ(SECFailure, SSL_KeyUpdate(server_->ssl_fd(), PR_TRUE));
|
||||
EXPECT_EQ(PR_WOULD_BLOCK_ERROR, PORT_GetError());
|
||||
}
|
||||
|
||||
TEST_F(TlsConnectStreamTls13, PostHandshakeAuthDuringClientKeyUpdate) {
|
||||
client_->SetupClientAuth();
|
||||
EXPECT_EQ(SECSuccess, SSL_OptionSet(client_->ssl_fd(),
|
||||
SSL_ENABLE_POST_HANDSHAKE_AUTH, PR_TRUE));
|
||||
Connect();
|
||||
CheckEpochs(3, 3);
|
||||
// Send CertificateRequest from server.
|
||||
EXPECT_EQ(SECSuccess, SSL_SendCertificateRequest(server_->ssl_fd()))
|
||||
<< "Unexpected error: " << PORT_ErrorToName(PORT_GetError());
|
||||
// Send KeyUpdate from client.
|
||||
EXPECT_EQ(SECSuccess, SSL_KeyUpdate(client_->ssl_fd(), PR_TRUE));
|
||||
server_->SendData(50); // server sends CertificateRequest
|
||||
client_->SendData(50); // client sends KeyUpdate
|
||||
server_->ReadBytes(50); // server receives KeyUpdate and defers response
|
||||
CheckEpochs(4, 3);
|
||||
client_->ReadBytes(50); // client receives CertificateRequest
|
||||
client_->SendData(
|
||||
50); // client sends Certificate, CertificateVerify, Finished
|
||||
server_->ReadBytes(
|
||||
50); // server receives Certificate, CertificateVerify, Finished
|
||||
client_->CheckEpochs(3, 4);
|
||||
server_->CheckEpochs(4, 4);
|
||||
server_->SendData(50); // server sends KeyUpdate
|
||||
client_->ReadBytes(50); // client receives KeyUpdate
|
||||
client_->CheckEpochs(4, 4);
|
||||
}
|
||||
|
||||
TEST_F(TlsConnectStreamTls13, PostHandshakeAuthMissingExtension) {
|
||||
client_->SetupClientAuth();
|
||||
Connect();
|
||||
|
|
@ -454,6 +494,9 @@ TEST_F(TlsConnectStreamTls13, PostHandshakeAuthDecline) {
|
|||
client_->SetupClientAuth();
|
||||
EXPECT_EQ(SECSuccess, SSL_OptionSet(client_->ssl_fd(),
|
||||
SSL_ENABLE_POST_HANDSHAKE_AUTH, PR_TRUE));
|
||||
EXPECT_EQ(SECSuccess,
|
||||
SSL_OptionSet(server_->ssl_fd(), SSL_REQUIRE_CERTIFICATE,
|
||||
SSL_REQUIRE_ALWAYS));
|
||||
// Client to decline the certificate request.
|
||||
EXPECT_EQ(SECSuccess,
|
||||
SSL_GetClientAuthDataHook(
|
||||
|
|
@ -472,10 +515,13 @@ TEST_F(TlsConnectStreamTls13, PostHandshakeAuthDecline) {
|
|||
// Send CertificateRequest.
|
||||
EXPECT_EQ(SECSuccess, SSL_SendCertificateRequest(server_->ssl_fd()))
|
||||
<< "Unexpected error: " << PORT_ErrorToName(PORT_GetError());
|
||||
server_->SendData(50);
|
||||
client_->ReadBytes(50);
|
||||
client_->SendData(50);
|
||||
server_->ReadBytes(50);
|
||||
server_->SendData(50); // send Certificate Request
|
||||
client_->ReadBytes(50); // read Certificate Request
|
||||
client_->SendData(50); // send empty Certificate+Finished
|
||||
server_->ExpectSendAlert(kTlsAlertCertificateRequired);
|
||||
server_->ReadBytes(50); // read empty Certificate+Finished
|
||||
server_->ExpectReadWriteError();
|
||||
server_->SendData(50); // send alert
|
||||
// AuthCertificateCallback is not called, because the client sends
|
||||
// an empty certificate_list.
|
||||
EXPECT_EQ(0U, called);
|
||||
|
|
@ -655,6 +701,44 @@ TEST_P(TlsConnectTls12, ClientAuthInconsistentPssSignatureScheme) {
|
|||
ConnectExpectAlert(server_, kTlsAlertIllegalParameter);
|
||||
}
|
||||
|
||||
TEST_P(TlsConnectTls13, ClientAuthPkcs1SignatureScheme) {
|
||||
static const SSLSignatureScheme kSignatureScheme[] = {
|
||||
ssl_sig_rsa_pkcs1_sha256, ssl_sig_rsa_pss_rsae_sha256};
|
||||
|
||||
Reset(TlsAgent::kServerRsa, "rsa");
|
||||
client_->SetSignatureSchemes(kSignatureScheme,
|
||||
PR_ARRAY_SIZE(kSignatureScheme));
|
||||
server_->SetSignatureSchemes(kSignatureScheme,
|
||||
PR_ARRAY_SIZE(kSignatureScheme));
|
||||
client_->SetupClientAuth();
|
||||
server_->RequestClientAuth(true);
|
||||
|
||||
auto capture_cert_verify = MakeTlsFilter<TlsHandshakeRecorder>(
|
||||
client_, kTlsHandshakeCertificateVerify);
|
||||
capture_cert_verify->EnableDecryption();
|
||||
|
||||
Connect();
|
||||
CheckSigScheme(capture_cert_verify, 0, server_, ssl_sig_rsa_pss_rsae_sha256,
|
||||
1024);
|
||||
}
|
||||
|
||||
TEST_P(TlsConnectTls13, ClientAuthPkcs1SignatureSchemeOnly) {
|
||||
static const SSLSignatureScheme kSignatureScheme[] = {
|
||||
ssl_sig_rsa_pkcs1_sha256};
|
||||
|
||||
Reset(TlsAgent::kServerRsa, "rsa");
|
||||
client_->SetSignatureSchemes(kSignatureScheme,
|
||||
PR_ARRAY_SIZE(kSignatureScheme));
|
||||
server_->SetSignatureSchemes(kSignatureScheme,
|
||||
PR_ARRAY_SIZE(kSignatureScheme));
|
||||
client_->SetupClientAuth();
|
||||
server_->RequestClientAuth(true);
|
||||
|
||||
ConnectExpectAlert(server_, kTlsAlertHandshakeFailure);
|
||||
server_->CheckErrorCode(SSL_ERROR_UNSUPPORTED_SIGNATURE_ALGORITHM);
|
||||
client_->CheckErrorCode(SSL_ERROR_NO_CYPHER_OVERLAP);
|
||||
}
|
||||
|
||||
class TlsZeroCertificateRequestSigAlgsFilter : public TlsHandshakeFilter {
|
||||
public:
|
||||
TlsZeroCertificateRequestSigAlgsFilter(const std::shared_ptr<TlsAgent>& a)
|
||||
|
|
@ -887,7 +971,7 @@ TEST_P(TlsConnectTls13, InconsistentSignatureSchemeAlert) {
|
|||
client_->CheckErrorCode(SSL_ERROR_INCORRECT_SIGNATURE_ALGORITHM);
|
||||
}
|
||||
|
||||
TEST_P(TlsConnectTls12Plus, RequestClientAuthWithSha384) {
|
||||
TEST_P(TlsConnectTls12, RequestClientAuthWithSha384) {
|
||||
server_->SetSignatureSchemes(kSignatureSchemeRsaSha384,
|
||||
PR_ARRAY_SIZE(kSignatureSchemeRsaSha384));
|
||||
server_->RequestClientAuth(false);
|
||||
|
|
@ -1349,12 +1433,21 @@ TEST_P(TlsSignatureSchemeConfiguration, SignatureSchemeConfigBoth) {
|
|||
INSTANTIATE_TEST_CASE_P(
|
||||
SignatureSchemeRsa, TlsSignatureSchemeConfiguration,
|
||||
::testing::Combine(
|
||||
TlsConnectTestBase::kTlsVariantsAll, TlsConnectTestBase::kTlsV12Plus,
|
||||
TlsConnectTestBase::kTlsVariantsAll, TlsConnectTestBase::kTlsV12,
|
||||
::testing::Values(TlsAgent::kServerRsaSign),
|
||||
::testing::Values(ssl_auth_rsa_sign),
|
||||
::testing::Values(ssl_sig_rsa_pkcs1_sha256, ssl_sig_rsa_pkcs1_sha384,
|
||||
ssl_sig_rsa_pkcs1_sha512, ssl_sig_rsa_pss_rsae_sha256,
|
||||
ssl_sig_rsa_pss_rsae_sha384)));
|
||||
// RSASSA-PKCS1-v1_5 is not allowed to be used in TLS 1.3
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
SignatureSchemeRsaTls13, TlsSignatureSchemeConfiguration,
|
||||
::testing::Combine(TlsConnectTestBase::kTlsVariantsAll,
|
||||
TlsConnectTestBase::kTlsV13,
|
||||
::testing::Values(TlsAgent::kServerRsaSign),
|
||||
::testing::Values(ssl_auth_rsa_sign),
|
||||
::testing::Values(ssl_sig_rsa_pss_rsae_sha256,
|
||||
ssl_sig_rsa_pss_rsae_sha384)));
|
||||
// PSS with SHA-512 needs a bigger key to work.
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
SignatureSchemeBigRsa, TlsSignatureSchemeConfiguration,
|
||||
|
|
|
|||
|
|
@ -68,12 +68,6 @@ class TlsCipherSuiteTestBase : public TlsConnectTestBase {
|
|||
virtual void SetupCertificate() {
|
||||
if (version_ >= SSL_LIBRARY_VERSION_TLS_1_3) {
|
||||
switch (sig_scheme_) {
|
||||
case ssl_sig_rsa_pkcs1_sha256:
|
||||
case ssl_sig_rsa_pkcs1_sha384:
|
||||
case ssl_sig_rsa_pkcs1_sha512:
|
||||
Reset(TlsAgent::kServerRsaSign);
|
||||
auth_type_ = ssl_auth_rsa_sign;
|
||||
break;
|
||||
case ssl_sig_rsa_pss_rsae_sha256:
|
||||
case ssl_sig_rsa_pss_rsae_sha384:
|
||||
Reset(TlsAgent::kServerRsaSign);
|
||||
|
|
@ -330,6 +324,12 @@ static SSLSignatureScheme kSignatureSchemesParamsArr[] = {
|
|||
ssl_sig_rsa_pss_pss_sha256, ssl_sig_rsa_pss_pss_sha384,
|
||||
ssl_sig_rsa_pss_pss_sha512};
|
||||
|
||||
static SSLSignatureScheme kSignatureSchemesParamsArrTls13[] = {
|
||||
ssl_sig_ecdsa_secp256r1_sha256, ssl_sig_ecdsa_secp384r1_sha384,
|
||||
ssl_sig_rsa_pss_rsae_sha256, ssl_sig_rsa_pss_rsae_sha384,
|
||||
ssl_sig_rsa_pss_rsae_sha512, ssl_sig_rsa_pss_pss_sha256,
|
||||
ssl_sig_rsa_pss_pss_sha384, ssl_sig_rsa_pss_pss_sha512};
|
||||
|
||||
INSTANTIATE_CIPHER_TEST_P(RC4, Stream, V10ToV12, kDummyNamedGroupParams,
|
||||
kDummySignatureSchemesParams,
|
||||
TLS_RSA_WITH_RC4_128_SHA,
|
||||
|
|
@ -394,7 +394,7 @@ INSTANTIATE_CIPHER_TEST_P(
|
|||
#ifndef NSS_DISABLE_TLS_1_3
|
||||
INSTANTIATE_CIPHER_TEST_P(TLS13, All, V13,
|
||||
::testing::ValuesIn(kFasterDHEGroups),
|
||||
::testing::ValuesIn(kSignatureSchemesParamsArr),
|
||||
::testing::ValuesIn(kSignatureSchemesParamsArrTls13),
|
||||
TLS_AES_128_GCM_SHA256, TLS_CHACHA20_POLY1305_SHA256,
|
||||
TLS_AES_256_GCM_SHA384);
|
||||
INSTANTIATE_CIPHER_TEST_P(TLS13AllGroups, All, V13,
|
||||
|
|
|
|||
|
|
@ -1,53 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "gtest_utils.h"
|
||||
#include "tls_connect.h"
|
||||
|
||||
namespace nss_test {
|
||||
|
||||
extern "C" {
|
||||
extern FILE* ssl_trace_iob;
|
||||
|
||||
#ifdef NSS_ALLOW_SSLKEYLOGFILE
|
||||
extern FILE* ssl_keylog_iob;
|
||||
#endif
|
||||
}
|
||||
|
||||
// These tests ensure that when the associated environment variables are unset
|
||||
// that the lazily-initialized defaults are what they are supposed to be.
|
||||
|
||||
#ifdef DEBUG
|
||||
TEST_P(TlsConnectGeneric, DebugEnvTraceFileNotSet) {
|
||||
char* ev = PR_GetEnvSecure("SSLDEBUGFILE");
|
||||
if (ev && ev[0]) {
|
||||
// note: should use GTEST_SKIP when GTest gets updated to support it
|
||||
return;
|
||||
}
|
||||
|
||||
Connect();
|
||||
EXPECT_EQ(stderr, ssl_trace_iob);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NSS_ALLOW_SSLKEYLOGFILE
|
||||
TEST_P(TlsConnectGeneric, DebugEnvKeylogFileNotSet) {
|
||||
char* ev = PR_GetEnvSecure("SSLKEYLOGFILE");
|
||||
if (ev && ev[0]) {
|
||||
// note: should use GTEST_SKIP when GTest gets updated to support it
|
||||
return;
|
||||
}
|
||||
|
||||
Connect();
|
||||
EXPECT_EQ(nullptr, ssl_keylog_iob);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace nss_test
|
||||
|
|
@ -436,14 +436,14 @@ TEST_P(TlsExtensionTest12Plus, SignatureAlgorithmsOddLength) {
|
|||
}
|
||||
|
||||
TEST_F(TlsExtensionTest13Stream, SignatureAlgorithmsPrecedingGarbage) {
|
||||
// 31 unknown signature algorithms followed by sha-256, rsa
|
||||
// 31 unknown signature algorithms followed by sha-256, rsa-pss
|
||||
const uint8_t val[] = {
|
||||
0x00, 0x40, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x04, 0x01};
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x08, 0x04};
|
||||
DataBuffer extension(val, sizeof(val));
|
||||
MakeTlsFilter<TlsExtensionReplacer>(client_, ssl_signature_algorithms_xtn,
|
||||
extension);
|
||||
|
|
@ -482,6 +482,73 @@ TEST_P(TlsExtensionTestGeneric, SupportedCurvesTrailingData) {
|
|||
client_, ssl_elliptic_curves_xtn, extension));
|
||||
}
|
||||
|
||||
TEST_P(TlsExtensionTest12, SupportedCurvesDisableX25519) {
|
||||
// Disable session resumption.
|
||||
ConfigureSessionCache(RESUME_NONE, RESUME_NONE);
|
||||
|
||||
// Ensure that we can enable its use in the key exchange.
|
||||
SECStatus rv =
|
||||
NSS_SetAlgorithmPolicy(SEC_OID_CURVE25519, NSS_USE_ALG_IN_SSL_KX, 0);
|
||||
ASSERT_EQ(SECSuccess, rv);
|
||||
rv = NSS_SetAlgorithmPolicy(SEC_OID_APPLY_SSL_POLICY, NSS_USE_POLICY_IN_SSL,
|
||||
0);
|
||||
ASSERT_EQ(SECSuccess, rv);
|
||||
|
||||
auto capture1 =
|
||||
MakeTlsFilter<TlsExtensionCapture>(client_, ssl_elliptic_curves_xtn);
|
||||
Connect();
|
||||
|
||||
EXPECT_TRUE(capture1->captured());
|
||||
const DataBuffer& ext1 = capture1->extension();
|
||||
|
||||
uint32_t count;
|
||||
ASSERT_TRUE(ext1.Read(0, 2, &count));
|
||||
|
||||
// Whether or not we've seen x25519 offered in this handshake.
|
||||
bool seen1_x25519 = false;
|
||||
for (size_t offset = 2; offset <= count; offset++) {
|
||||
uint32_t val;
|
||||
ASSERT_TRUE(ext1.Read(offset, 2, &val));
|
||||
if (val == ssl_grp_ec_curve25519) {
|
||||
seen1_x25519 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ASSERT_TRUE(seen1_x25519);
|
||||
|
||||
// Ensure that we can disable its use in the key exchange.
|
||||
rv = NSS_SetAlgorithmPolicy(SEC_OID_CURVE25519, 0, NSS_USE_ALG_IN_SSL_KX);
|
||||
ASSERT_EQ(SECSuccess, rv);
|
||||
rv = NSS_SetAlgorithmPolicy(SEC_OID_APPLY_SSL_POLICY, NSS_USE_POLICY_IN_SSL,
|
||||
0);
|
||||
ASSERT_EQ(SECSuccess, rv);
|
||||
|
||||
// Clean up after the last run.
|
||||
Reset();
|
||||
auto capture2 =
|
||||
MakeTlsFilter<TlsExtensionCapture>(client_, ssl_elliptic_curves_xtn);
|
||||
Connect();
|
||||
|
||||
EXPECT_TRUE(capture2->captured());
|
||||
const DataBuffer& ext2 = capture2->extension();
|
||||
|
||||
ASSERT_TRUE(ext2.Read(0, 2, &count));
|
||||
|
||||
// Whether or not we've seen x25519 offered in this handshake.
|
||||
bool seen2_x25519 = false;
|
||||
for (size_t offset = 2; offset <= count; offset++) {
|
||||
uint32_t val;
|
||||
ASSERT_TRUE(ext2.Read(offset, 2, &val));
|
||||
|
||||
if (val == ssl_grp_ec_curve25519) {
|
||||
seen2_x25519 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_FALSE(seen2_x25519);
|
||||
}
|
||||
|
||||
TEST_P(TlsExtensionTestPre13, SupportedPointsEmpty) {
|
||||
const uint8_t val[] = {0x00};
|
||||
DataBuffer extension(val, sizeof(val));
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
'ssl_gather_unittest.cc',
|
||||
'ssl_gtest.cc',
|
||||
'ssl_hrr_unittest.cc',
|
||||
'ssl_keylog_unittest.cc',
|
||||
'ssl_keyupdate_unittest.cc',
|
||||
'ssl_loopback_unittest.cc',
|
||||
'ssl_misc_unittest.cc',
|
||||
|
|
@ -76,7 +75,7 @@
|
|||
'<(DEPTH)/lib/libpkix/libpkix.gyp:libpkix',
|
||||
],
|
||||
'conditions': [
|
||||
[ 'test_build==1', {
|
||||
[ 'static_libs==1', {
|
||||
'dependencies': [
|
||||
'<(DEPTH)/lib/pk11wrap/pk11wrap.gyp:pk11wrap_static',
|
||||
],
|
||||
|
|
@ -93,6 +92,14 @@
|
|||
'<(DEPTH)/lib/dbm/src/src.gyp:dbm',
|
||||
],
|
||||
}],
|
||||
[ 'enable_sslkeylogfile==1 and sanitizer_flags==0', {
|
||||
'sources': [
|
||||
'ssl_keylog_unittest.cc',
|
||||
],
|
||||
'defines': [
|
||||
'NSS_ALLOW_SSLKEYLOGFILE',
|
||||
],
|
||||
}],
|
||||
],
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifdef NSS_ALLOW_SSLKEYLOGFILE
|
||||
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
|
@ -114,5 +112,3 @@ INSTANTIATE_TEST_CASE_P(
|
|||
#endif
|
||||
|
||||
} // namespace nss_test
|
||||
|
||||
#endif // NSS_ALLOW_SSLKEYLOGFILE
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ class AeadTest : public ::testing::Test {
|
|||
static const size_t kMaxSize = 32;
|
||||
|
||||
ASSERT_GE(kMaxSize, ciphertext_len);
|
||||
ASSERT_LT(0U, ciphertext_len);
|
||||
|
||||
uint8_t output[kMaxSize];
|
||||
unsigned int output_len = 0;
|
||||
|
|
@ -191,7 +192,7 @@ TEST_F(AeadTest, AeadAes128Gcm) {
|
|||
}
|
||||
|
||||
TEST_F(AeadTest, AeadAes256Gcm) {
|
||||
SSLAeadContext *ctxInit;
|
||||
SSLAeadContext *ctxInit = nullptr;
|
||||
ASSERT_EQ(SECSuccess,
|
||||
SSL_MakeAead(SSL_LIBRARY_VERSION_TLS_1_3, TLS_AES_256_GCM_SHA384,
|
||||
secret_.get(), kLabel, strlen(kLabel), &ctxInit));
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ class BadPrSocket : public DummyIOLayerMethods {
|
|||
// NSPR method vtable with the ones from this object.
|
||||
dummy_layer_ =
|
||||
PR_GetIdentitiesLayer(agent->ssl_fd(), DummyPrSocket::LayerId());
|
||||
EXPECT_TRUE(dummy_layer_);
|
||||
original_methods_ = dummy_layer_->methods;
|
||||
original_secret_ = dummy_layer_->secret;
|
||||
dummy_layer_->methods = fd_->methods;
|
||||
|
|
@ -442,6 +443,48 @@ TEST_P(TlsConnectStream, ReplaceRecordLayerAsyncLateAuth) {
|
|||
SendForwardReceive(client_, client_stage, server_);
|
||||
}
|
||||
|
||||
TEST_F(TlsConnectStreamTls13, ReplaceRecordLayerAsyncPostHandshake) {
|
||||
StartConnect();
|
||||
client_->SetServerKeyBits(server_->server_key_bits());
|
||||
|
||||
BadPrSocket bad_layer_client(client_);
|
||||
BadPrSocket bad_layer_server(server_);
|
||||
StagedRecords client_stage(client_);
|
||||
StagedRecords server_stage(server_);
|
||||
|
||||
client_->SetAuthCertificateCallback(AuthCompleteBlock);
|
||||
|
||||
server_stage.ForwardAll(client_, TlsAgent::STATE_CONNECTING);
|
||||
client_stage.ForwardAll(server_, TlsAgent::STATE_CONNECTING);
|
||||
server_stage.ForwardAll(client_, TlsAgent::STATE_CONNECTING);
|
||||
|
||||
ASSERT_TRUE(client_stage.empty());
|
||||
client_->Handshake();
|
||||
ASSERT_TRUE(client_stage.empty());
|
||||
EXPECT_EQ(TlsAgent::STATE_CONNECTING, client_->state());
|
||||
|
||||
// Now declare the certificate good.
|
||||
EXPECT_EQ(SECSuccess, SSL_AuthCertificateComplete(client_->ssl_fd(), 0));
|
||||
client_->Handshake();
|
||||
ASSERT_FALSE(client_stage.empty());
|
||||
|
||||
if (version_ >= SSL_LIBRARY_VERSION_TLS_1_3) {
|
||||
EXPECT_EQ(TlsAgent::STATE_CONNECTED, client_->state());
|
||||
client_stage.ForwardAll(server_, TlsAgent::STATE_CONNECTED);
|
||||
} else {
|
||||
client_stage.ForwardAll(server_, TlsAgent::STATE_CONNECTED);
|
||||
server_stage.ForwardAll(client_, TlsAgent::STATE_CONNECTED);
|
||||
}
|
||||
CheckKeys();
|
||||
|
||||
// Reading and writing application data should work.
|
||||
SendForwardReceive(client_, client_stage, server_);
|
||||
|
||||
// Post-handshake messages should work here.
|
||||
EXPECT_EQ(SECSuccess, SSL_SendSessionTicket(server_->ssl_fd(), nullptr, 0));
|
||||
SendForwardReceive(server_, server_stage, client_);
|
||||
}
|
||||
|
||||
// This test ensures that data is correctly forwarded when the handshake is
|
||||
// resumed after asynchronous server certificate authentication, when
|
||||
// SSL_AuthCertificateComplete() is called. The logic for resuming the
|
||||
|
|
|
|||
|
|
@ -33,9 +33,11 @@ class PacketFilter {
|
|||
CHANGE, // change the packet to a different value
|
||||
DROP // drop the packet
|
||||
};
|
||||
PacketFilter(bool enabled = true) : enabled_(enabled) {}
|
||||
explicit PacketFilter(bool on = true) : enabled_(on) {}
|
||||
virtual ~PacketFilter() {}
|
||||
|
||||
bool enabled() const { return enabled_; }
|
||||
|
||||
virtual Action Process(const DataBuffer& input, DataBuffer* output) {
|
||||
if (!enabled_) {
|
||||
return KEEP;
|
||||
|
|
|
|||
|
|
@ -250,6 +250,7 @@ void TlsConnectTestBase::Reset(const std::string& server_name,
|
|||
server_->SkipVersionChecks();
|
||||
}
|
||||
|
||||
std::cerr << "Reset" << std::endl;
|
||||
Init();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -156,7 +156,8 @@ class TlsConnectTestBase : public ::testing::Test {
|
|||
// around test cases. In particular, DSA is checked in
|
||||
// ssl_extension_unittest.cc.
|
||||
const std::vector<SECOidTag> algorithms_ = {SEC_OID_APPLY_SSL_POLICY,
|
||||
SEC_OID_ANSIX9_DSA_SIGNATURE};
|
||||
SEC_OID_ANSIX9_DSA_SIGNATURE,
|
||||
SEC_OID_CURVE25519};
|
||||
std::vector<std::tuple<SECOidTag, uint32_t>> saved_policies_;
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ static void GenerateEsniKey(time_t windowStart, SSLNamedGroup group,
|
|||
ASSERT_NE(nullptr, priv);
|
||||
SECITEM_FreeItem(&ecParams, PR_FALSE);
|
||||
PRUint8 encoded[1024];
|
||||
unsigned int encoded_len;
|
||||
unsigned int encoded_len = 0;
|
||||
|
||||
SECStatus rv = SSL_EncodeESNIKeys(
|
||||
&cipher_suites[0], cipher_suites.size(), group, pub, 100, windowStart,
|
||||
|
|
@ -375,11 +375,13 @@ TEST_P(TlsConnectTls13, ConnectEsniCSMismatch) {
|
|||
GenerateEsniKey(time(nullptr), ssl_grp_ec_curve25519, kDefaultSuites, &record,
|
||||
&pub, &priv);
|
||||
PRUint8 encoded[1024];
|
||||
unsigned int encoded_len;
|
||||
unsigned int encoded_len = 0;
|
||||
|
||||
SECStatus rv = SSL_EncodeESNIKeys(
|
||||
&kChaChaSuite[0], kChaChaSuite.size(), ssl_grp_ec_curve25519, pub.get(),
|
||||
100, time(0), time(0) + 10, encoded, &encoded_len, sizeof(encoded));
|
||||
ASSERT_EQ(SECSuccess, rv);
|
||||
ASSERT_LT(0U, encoded_len);
|
||||
rv = SSL_SetESNIKeyPair(server_->ssl_fd(), priv.get(), encoded, encoded_len);
|
||||
ASSERT_EQ(SECSuccess, rv);
|
||||
rv = SSL_EnableESNI(client_->ssl_fd(), record.data(), record.len(), "");
|
||||
|
|
|
|||
|
|
@ -549,9 +549,9 @@ class SelectiveDropFilter : public PacketFilter {
|
|||
class SelectiveRecordDropFilter : public TlsRecordFilter {
|
||||
public:
|
||||
SelectiveRecordDropFilter(const std::shared_ptr<TlsAgent>& a,
|
||||
uint32_t pattern, bool enabled = true)
|
||||
uint32_t pattern, bool on = true)
|
||||
: TlsRecordFilter(a), pattern_(pattern), counter_(0) {
|
||||
if (!enabled) {
|
||||
if (!on) {
|
||||
Disable();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue