Skip to content

Commit

Permalink
Bug 1304832 - TLS 1.3: Implement draft-15 cipher suite negotiation. r=mt
Browse files Browse the repository at this point in the history
  • Loading branch information
ekr committed Sep 22, 2016
1 parent c58af85 commit e272467
Show file tree
Hide file tree
Showing 30 changed files with 1,420 additions and 752 deletions.
18 changes: 15 additions & 3 deletions external_tests/ssl_gtest/libssl_internals.c
Expand Up @@ -26,9 +26,10 @@ SECStatus SSLInt_IncrementClientHandshakeVersion(PRFileDesc *fd) {

// This function guesses what key exchange strength libssl will choose.
PRUint32 SSLInt_DetermineKEABits(PRUint16 serverKeyBits,
const SSLCipherSuiteInfo *info) {
SSLAuthType authAlgorithm,
PRUint32 symKeyBits) {
PRUint32 authBits;
SSLAuthType authAlgorithm = info->authType;

if (authAlgorithm == ssl_auth_ecdsa || authAlgorithm == ssl_auth_ecdh_rsa ||
authAlgorithm == ssl_auth_ecdh_ecdsa) {
authBits = serverKeyBits;
Expand All @@ -40,7 +41,7 @@ PRUint32 SSLInt_DetermineKEABits(PRUint16 serverKeyBits,

// We expect a curve for key exchange to be selected based on the symmetric
// key strength (times 2) or the server key size, whichever is smaller.
PRUint32 targetKeaBits = PR_MIN(info->symKeyBits * 2, authBits);
PRUint32 targetKeaBits = PR_MIN(symKeyBits * 2, authBits);

// P-256 is the preferred curve of minimum size.
return PR_MAX(256U, targetKeaBits);
Expand Down Expand Up @@ -283,3 +284,14 @@ SECStatus SSLInt_AdvanceWriteSeqByAWindow(PRFileDesc *fd, PRInt32 extra) {
ssl_ReleaseSpecReadLock(ss);
return SSLInt_AdvanceWriteSeqNum(fd, to & RECORD_SEQ_MAX);
}

SSLKEAType SSLInt_GetKEAType(SSLNamedGroup group) {
const namedGroupDef* groupDef = ssl_LookupNamedGroup(group);
if (!groupDef)
return ssl_kea_null;

if (groupDef->type == group_type_ec)
return ssl_kea_ecdh;

return ssl_kea_dh;
}
5 changes: 3 additions & 2 deletions external_tests/ssl_gtest/libssl_internals.h
Expand Up @@ -16,8 +16,8 @@
SECStatus SSLInt_IncrementClientHandshakeVersion(PRFileDesc *fd);

PRUint32 SSLInt_DetermineKEABits(PRUint16 serverKeyBits,
const SSLCipherSuiteInfo *info);

SSLAuthType authAlgorithm,
PRUint32 symKeyBits);
SECStatus SSLInt_UpdateSSLv2ClientRandom(PRFileDesc *fd, uint8_t *rnd,
size_t rnd_len, uint8_t *msg,
size_t msg_len);
Expand All @@ -36,5 +36,6 @@ PRBool SSLInt_SendAlert(PRFileDesc *fd, uint8_t level, uint8_t type);
SECStatus SSLInt_AdvanceWriteSeqNum(PRFileDesc *fd, PRUint64 to);
SECStatus SSLInt_AdvanceReadSeqNum(PRFileDesc *fd, PRUint64 to);
SECStatus SSLInt_AdvanceWriteSeqByAWindow(PRFileDesc *fd, PRInt32 extra);
SSLKEAType SSLInt_GetKEAType(SSLNamedGroup group);

#endif // ndef libssl_internals_h_
29 changes: 17 additions & 12 deletions external_tests/ssl_gtest/ssl_agent_unittest.cc
Expand Up @@ -24,7 +24,7 @@ const static uint8_t kCannedTls13ClientHello[] = {
0x63, 0x98, 0xfa, 0x68, 0xfb, 0x01, 0x39, 0xff, 0x7c, 0x1a, 0x51, 0xa7,
0x92, 0xda, 0x97, 0xf5, 0x15, 0x78, 0xb3, 0xbb, 0x26, 0xa7, 0xed, 0x6f,
0x69, 0x71, 0x00, 0x00, 0x2a, 0xc0, 0x2b, 0xc0, 0x2f, 0xcc, 0xa9, 0xcc,
0xa8, 0xc0, 0x0a, 0xc0, 0x09, 0xc0, 0x13, 0xc0, 0x14, 0x00, 0x9e, 0xcc,
0xa8, 0xd1, 0x01, 0xc0, 0x09, 0xc0, 0x13, 0xc0, 0x14, 0x00, 0x9e, 0xcc,
0xaa, 0x00, 0x33, 0x00, 0x32, 0x00, 0x39, 0x00, 0x38, 0x00, 0x16, 0x00,
0x13, 0x00, 0x2f, 0x00, 0x35, 0x00, 0x0a, 0x00, 0x05, 0x00, 0x04, 0x01,
0x00, 0x01, 0xa9, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x09, 0x00, 0x00, 0x06,
Expand Down Expand Up @@ -65,17 +65,22 @@ const static uint8_t kCannedTls13ClientHello[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

const static uint8_t kCannedTls13ServerHello[] = {
0x03, 0x04, 0xe9, 0x01, 0xa0, 0x81, 0x37, 0x97, 0xaa, 0x8c, 0x7e, 0x21,
0x1c, 0x66, 0x3f, 0xa4, 0x0f, 0x4d, 0x74, 0x7a, 0xcd, 0x4b, 0xe1, 0x7f,
0x37, 0x85, 0x14, 0xb5, 0x7e, 0x30, 0x15, 0x91, 0xdf, 0x18, 0xc0, 0x2f,
0x00, 0x49, 0x00, 0x28, 0x00, 0x45, 0x00, 0x17, 0x00, 0x41, 0x04, 0x1a,
0x53, 0x9b, 0x39, 0xe6, 0xda, 0x66, 0xfc, 0x8a, 0x75, 0x68, 0xb7, 0x73,
0xc7, 0x21, 0x1f, 0x01, 0x04, 0x54, 0xb4, 0x99, 0x1f, 0x0b, 0x7e, 0xea,
0x95, 0xec, 0x78, 0x5c, 0x37, 0x7c, 0x31, 0x56, 0x04, 0xc8, 0xbf, 0x79,
0x47, 0x56, 0xb9, 0x87, 0x06, 0xc1, 0xfc, 0x63, 0x09, 0x5d, 0xfc, 0x1a,
0x9e, 0x2b, 0xb9, 0xca, 0xdb, 0x0e, 0x10, 0xec, 0xd5, 0x95, 0x0d, 0x0a,
0x5e, 0x3c, 0xf7};

0x03, 0x04, 0x21, 0x12, 0xa7, 0xa7, 0x0d, 0x85,
0x8b, 0xb8, 0x0c, 0xbb, 0xdc, 0xa6, 0xfd, 0x97,
0xfe, 0x31, 0x26, 0x49, 0x2d, 0xa8, 0x6c, 0x7b,
0x65, 0x30, 0x71, 0x00, 0x31, 0x03, 0x2b, 0x94,
0xe2, 0x16, 0xd1, 0x01, 0x00, 0x4d, 0x00, 0x0d,
0x00, 0x00, 0x00, 0x28, 0x00, 0x45, 0x00, 0x17,
0x00, 0x41, 0x04, 0x10, 0x97, 0x3d, 0x7a, 0xcf,
0xa2, 0x34, 0xe3, 0x69, 0xc4, 0xdd, 0x1e, 0xf2,
0xd6, 0xc0, 0x9a, 0x3e, 0xf5, 0x41, 0xf3, 0x03,
0x23, 0x94, 0xd2, 0x31, 0x85, 0xb7, 0xae, 0x5d,
0xfa, 0xc6, 0x9a, 0xd0, 0xa5, 0x44, 0xa3, 0x3a,
0xe0, 0xbb, 0x61, 0xaa, 0x0a, 0x6f, 0xe8, 0xaf,
0xdf, 0x86, 0xd8, 0x48, 0x36, 0x9c, 0x19, 0x70,
0x55, 0x84, 0xb0, 0x1c, 0x8d, 0xfc, 0x6e, 0xd8,
0x86, 0xc3, 0x95
};
static const char *k0RttData = "ABCDEF";

TEST_P(TlsAgentTest, EarlyFinished) {
Expand Down

0 comments on commit e272467

Please sign in to comment.