Update the key_share tests for HelloRetryRequest
Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/2341)
This commit is contained in:
parent
87d70b63a5
commit
38f5c30b31
2 changed files with 48 additions and 34 deletions
|
@ -69,79 +69,89 @@ my $proxy = TLSProxy::Proxy->new(
|
||||||
#We assume that test_ssl_new and friends will test the happy path for this,
|
#We assume that test_ssl_new and friends will test the happy path for this,
|
||||||
#so we concentrate on the less common scenarios
|
#so we concentrate on the less common scenarios
|
||||||
|
|
||||||
#Test 1: An empty key_shares extension should not succeed
|
#Test 1: An empty key_shares extension should succeed after a HelloRetryRequest
|
||||||
$testtype = EMPTY_EXTENSION;
|
$testtype = EMPTY_EXTENSION;
|
||||||
$direction = CLIENT_TO_SERVER;
|
$direction = CLIENT_TO_SERVER;
|
||||||
$proxy->filter(\&modify_key_shares_filter);
|
$proxy->filter(\&modify_key_shares_filter);
|
||||||
|
$proxy->serverflags("-curves P-256");
|
||||||
$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
|
$proxy->start() or plan skip_all => "Unable to start up Proxy for tests";
|
||||||
plan tests => 19;
|
plan tests => 21;
|
||||||
#TODO(TLS1.3): Actually this should succeed after a HelloRetryRequest - but
|
ok(TLSProxy::Message->success(), "Success after HRR");
|
||||||
#we've not implemented that yet, so for now we look for a fail
|
|
||||||
ok(TLSProxy::Message->fail(), "Empty key_shares");
|
|
||||||
|
|
||||||
#Test 2: A missing key_shares extension should not succeed
|
#Test 2: The server sending an HRR requesting a group the client already sent
|
||||||
|
# should fail
|
||||||
|
$proxy->clear();
|
||||||
|
$proxy->start();
|
||||||
|
ok(TLSProxy::Message->fail(), "Server asks for group already provided");
|
||||||
|
|
||||||
|
#Test 3: A missing key_shares extension should not succeed
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$testtype = MISSING_EXTENSION;
|
$testtype = MISSING_EXTENSION;
|
||||||
$proxy->start();
|
$proxy->start();
|
||||||
#TODO(TLS1.3): As above this should really succeed after a HelloRetryRequest,
|
|
||||||
#but we look for fail for now
|
|
||||||
ok(TLSProxy::Message->fail(), "Missing key_shares extension");
|
ok(TLSProxy::Message->fail(), "Missing key_shares extension");
|
||||||
|
|
||||||
#Test 3: No acceptable key_shares should fail
|
#Test 4: No initial acceptable key_shares should succeed after a
|
||||||
$proxy->clear();
|
# HelloRetryRequest
|
||||||
$testtype = NO_ACCEPTABLE_KEY_SHARES;
|
|
||||||
$proxy->start();
|
|
||||||
#TODO(TLS1.3): Again this should go around the loop of a HelloRetryRequest but
|
|
||||||
#we fail for now
|
|
||||||
ok(TLSProxy::Message->fail(), "No acceptable key_shares");
|
|
||||||
|
|
||||||
#Test 4: A non preferred but acceptable key_share should succeed
|
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$proxy->filter(undef);
|
$proxy->filter(undef);
|
||||||
|
$proxy->serverflags("-curves P-256");
|
||||||
|
$proxy->start();
|
||||||
|
ok(TLSProxy::Message->success(), "No initial acceptable key_shares");
|
||||||
|
|
||||||
|
#Test 5: No acceptable key_shares and no shared groups should fail
|
||||||
|
$proxy->clear();
|
||||||
|
$proxy->filter(undef);
|
||||||
|
$proxy->serverflags("-curves P-256");
|
||||||
|
$proxy->clientflags("-curves P-384");
|
||||||
|
$proxy->start();
|
||||||
|
ok(TLSProxy::Message->fail(), "No acceptable key_shares");
|
||||||
|
|
||||||
|
#Test 6: A non preferred but acceptable key_share should succeed
|
||||||
|
$proxy->clear();
|
||||||
$proxy->clientflags("-curves P-256");
|
$proxy->clientflags("-curves P-256");
|
||||||
$proxy->start();
|
$proxy->start();
|
||||||
ok(TLSProxy::Message->success(), "Non preferred key_share");
|
ok(TLSProxy::Message->success(), "Non preferred key_share");
|
||||||
$proxy->filter(\&modify_key_shares_filter);
|
$proxy->filter(\&modify_key_shares_filter);
|
||||||
|
|
||||||
#Test 5: An acceptable key_share after a list of non-acceptable ones should
|
#Test 7: An acceptable key_share after a list of non-acceptable ones should
|
||||||
#succeed
|
#succeed
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$testtype = ACCEPTABLE_AT_END;
|
$testtype = ACCEPTABLE_AT_END;
|
||||||
$proxy->start();
|
$proxy->start();
|
||||||
ok(TLSProxy::Message->success(), "Acceptable key_share at end of list");
|
ok(TLSProxy::Message->success(), "Acceptable key_share at end of list");
|
||||||
|
|
||||||
#Test 6: An acceptable key_share but for a group not in supported_groups should
|
#Test 8: An acceptable key_share but for a group not in supported_groups should
|
||||||
#fail
|
#fail
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$testtype = NOT_IN_SUPPORTED_GROUPS;
|
$testtype = NOT_IN_SUPPORTED_GROUPS;
|
||||||
$proxy->start();
|
$proxy->start();
|
||||||
ok(TLSProxy::Message->fail(), "Acceptable key_share not in supported_groups");
|
ok(TLSProxy::Message->fail(), "Acceptable key_share not in supported_groups");
|
||||||
|
|
||||||
#Test 7: Too short group_id should fail
|
#Test 9: Too short group_id should fail
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$testtype = GROUP_ID_TOO_SHORT;
|
$testtype = GROUP_ID_TOO_SHORT;
|
||||||
$proxy->start();
|
$proxy->start();
|
||||||
ok(TLSProxy::Message->fail(), "Group id too short");
|
ok(TLSProxy::Message->fail(), "Group id too short");
|
||||||
|
|
||||||
#Test 8: key_exchange length mismatch should fail
|
#Test 10: key_exchange length mismatch should fail
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$testtype = KEX_LEN_MISMATCH;
|
$testtype = KEX_LEN_MISMATCH;
|
||||||
$proxy->start();
|
$proxy->start();
|
||||||
ok(TLSProxy::Message->fail(), "key_exchange length mismatch");
|
ok(TLSProxy::Message->fail(), "key_exchange length mismatch");
|
||||||
|
|
||||||
#Test 9: Zero length key_exchange should fail
|
#Test 11: Zero length key_exchange should fail
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$testtype = ZERO_LEN_KEX_DATA;
|
$testtype = ZERO_LEN_KEX_DATA;
|
||||||
$proxy->start();
|
$proxy->start();
|
||||||
ok(TLSProxy::Message->fail(), "zero length key_exchange data");
|
ok(TLSProxy::Message->fail(), "zero length key_exchange data");
|
||||||
|
|
||||||
#Test 10: Trailing data on key_share list should fail
|
#Test 12: Trailing data on key_share list should fail
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$testtype = TRAILING_DATA;
|
$testtype = TRAILING_DATA;
|
||||||
$proxy->start();
|
$proxy->start();
|
||||||
ok(TLSProxy::Message->fail(), "key_share list trailing data");
|
ok(TLSProxy::Message->fail(), "key_share list trailing data");
|
||||||
|
|
||||||
#Test 11: Multiple acceptable key_shares - we choose the first one
|
#Test 13: Multiple acceptable key_shares - we choose the first one
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$direction = SERVER_TO_CLIENT;
|
$direction = SERVER_TO_CLIENT;
|
||||||
$testtype = LOOK_ONLY;
|
$testtype = LOOK_ONLY;
|
||||||
|
@ -150,45 +160,45 @@ $proxy->start();
|
||||||
ok(TLSProxy::Message->success() && ($selectedgroupid == P_256),
|
ok(TLSProxy::Message->success() && ($selectedgroupid == P_256),
|
||||||
"Multiple acceptable key_shares");
|
"Multiple acceptable key_shares");
|
||||||
|
|
||||||
#Test 12: Multiple acceptable key_shares - we choose the first one (part 2)
|
#Test 14: Multiple acceptable key_shares - we choose the first one (part 2)
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$proxy->clientflags("-curves X25519:P-256");
|
$proxy->clientflags("-curves X25519:P-256");
|
||||||
$proxy->start();
|
$proxy->start();
|
||||||
ok(TLSProxy::Message->success() && ($selectedgroupid == X25519),
|
ok(TLSProxy::Message->success() && ($selectedgroupid == X25519),
|
||||||
"Multiple acceptable key_shares (part 2)");
|
"Multiple acceptable key_shares (part 2)");
|
||||||
|
|
||||||
#Test 13: Server sends key_share that wasn't offerred should fail
|
#Test 15: Server sends key_share that wasn't offerred should fail
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$testtype = SELECT_X25519;
|
$testtype = SELECT_X25519;
|
||||||
$proxy->clientflags("-curves P-256");
|
$proxy->clientflags("-curves P-256");
|
||||||
$proxy->start();
|
$proxy->start();
|
||||||
ok(TLSProxy::Message->fail(), "Non offered key_share");
|
ok(TLSProxy::Message->fail(), "Non offered key_share");
|
||||||
|
|
||||||
#Test 14: Too short group_id in ServerHello should fail
|
#Test 16: Too short group_id in ServerHello should fail
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$testtype = GROUP_ID_TOO_SHORT;
|
$testtype = GROUP_ID_TOO_SHORT;
|
||||||
$proxy->start();
|
$proxy->start();
|
||||||
ok(TLSProxy::Message->fail(), "Group id too short in ServerHello");
|
ok(TLSProxy::Message->fail(), "Group id too short in ServerHello");
|
||||||
|
|
||||||
#Test 15: key_exchange length mismatch in ServerHello should fail
|
#Test 17: key_exchange length mismatch in ServerHello should fail
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$testtype = KEX_LEN_MISMATCH;
|
$testtype = KEX_LEN_MISMATCH;
|
||||||
$proxy->start();
|
$proxy->start();
|
||||||
ok(TLSProxy::Message->fail(), "key_exchange length mismatch in ServerHello");
|
ok(TLSProxy::Message->fail(), "key_exchange length mismatch in ServerHello");
|
||||||
|
|
||||||
#Test 16: Zero length key_exchange in ServerHello should fail
|
#Test 18: Zero length key_exchange in ServerHello should fail
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$testtype = ZERO_LEN_KEX_DATA;
|
$testtype = ZERO_LEN_KEX_DATA;
|
||||||
$proxy->start();
|
$proxy->start();
|
||||||
ok(TLSProxy::Message->fail(), "zero length key_exchange data in ServerHello");
|
ok(TLSProxy::Message->fail(), "zero length key_exchange data in ServerHello");
|
||||||
|
|
||||||
#Test 17: Trailing data on key_share in ServerHello should fail
|
#Test 19: Trailing data on key_share in ServerHello should fail
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$testtype = TRAILING_DATA;
|
$testtype = TRAILING_DATA;
|
||||||
$proxy->start();
|
$proxy->start();
|
||||||
ok(TLSProxy::Message->fail(), "key_share trailing data in ServerHello");
|
ok(TLSProxy::Message->fail(), "key_share trailing data in ServerHello");
|
||||||
|
|
||||||
#Test 18: key_share should not be sent if the client is not capable of
|
#Test 20: key_share should not be sent if the client is not capable of
|
||||||
# negotiating TLSv1.3
|
# negotiating TLSv1.3
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$proxy->filter(undef);
|
$proxy->filter(undef);
|
||||||
|
@ -200,7 +210,7 @@ ok(TLSProxy::Message->success()
|
||||||
"No key_share for TLS<=1.2 client");
|
"No key_share for TLS<=1.2 client");
|
||||||
$proxy->filter(\&modify_key_shares_filter);
|
$proxy->filter(\&modify_key_shares_filter);
|
||||||
|
|
||||||
#Test 19: A server not capable of negotiating TLSv1.3 should not attempt to
|
#Test 21: A server not capable of negotiating TLSv1.3 should not attempt to
|
||||||
# process a key_share
|
# process a key_share
|
||||||
$proxy->clear();
|
$proxy->clear();
|
||||||
$direction = CLIENT_TO_SERVER;
|
$direction = CLIENT_TO_SERVER;
|
||||||
|
@ -288,8 +298,10 @@ sub modify_key_shares_filter
|
||||||
0x00; #Trailing garbage
|
0x00; #Trailing garbage
|
||||||
}
|
}
|
||||||
|
|
||||||
$message->set_extension(
|
if ($testtype != EMPTY_EXTENSION) {
|
||||||
TLSProxy::Message::EXT_SUPPORTED_GROUPS, $suppgroups);
|
$message->set_extension(
|
||||||
|
TLSProxy::Message::EXT_SUPPORTED_GROUPS, $suppgroups);
|
||||||
|
}
|
||||||
|
|
||||||
if ($testtype == MISSING_EXTENSION) {
|
if ($testtype == MISSING_EXTENSION) {
|
||||||
$message->delete_extension(
|
$message->delete_extension(
|
||||||
|
|
|
@ -17,6 +17,7 @@ use constant {
|
||||||
MT_CLIENT_HELLO => 1,
|
MT_CLIENT_HELLO => 1,
|
||||||
MT_SERVER_HELLO => 2,
|
MT_SERVER_HELLO => 2,
|
||||||
MT_NEW_SESSION_TICKET => 4,
|
MT_NEW_SESSION_TICKET => 4,
|
||||||
|
MT_HELLO_RETRY_REQUEST => 6,
|
||||||
MT_ENCRYPTED_EXTENSIONS => 8,
|
MT_ENCRYPTED_EXTENSIONS => 8,
|
||||||
MT_CERTIFICATE => 11,
|
MT_CERTIFICATE => 11,
|
||||||
MT_SERVER_KEY_EXCHANGE => 12,
|
MT_SERVER_KEY_EXCHANGE => 12,
|
||||||
|
@ -47,6 +48,7 @@ my %message_type = (
|
||||||
MT_CLIENT_HELLO, "ClientHello",
|
MT_CLIENT_HELLO, "ClientHello",
|
||||||
MT_SERVER_HELLO, "ServerHello",
|
MT_SERVER_HELLO, "ServerHello",
|
||||||
MT_NEW_SESSION_TICKET, "NewSessionTicket",
|
MT_NEW_SESSION_TICKET, "NewSessionTicket",
|
||||||
|
MT_HELLO_RETRY_REQUEST, "HelloRetryRequest",
|
||||||
MT_ENCRYPTED_EXTENSIONS, "EncryptedExtensions",
|
MT_ENCRYPTED_EXTENSIONS, "EncryptedExtensions",
|
||||||
MT_CERTIFICATE, "Certificate",
|
MT_CERTIFICATE, "Certificate",
|
||||||
MT_SERVER_KEY_EXCHANGE, "ServerKeyExchange",
|
MT_SERVER_KEY_EXCHANGE, "ServerKeyExchange",
|
||||||
|
|
Loading…
Reference in a new issue