forked from aws/s2n-tls
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a new method to enable QUIC-mode for TLS1.3. For now, QUIC-mode does not change any TLS1.3 behavior.
- Loading branch information
Showing
9 changed files
with
271 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
#include "s2n_test.h" | ||
#include "tls/s2n_quic_support.h" | ||
|
||
#include "tls/s2n_connection.h" | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
BEGIN_TEST(); | ||
|
||
/* Test s2n_connection_enable_quic */ | ||
{ | ||
struct s2n_connection *conn = s2n_connection_new(S2N_CLIENT); | ||
EXPECT_NOT_NULL(conn); | ||
EXPECT_FALSE(conn->quic_enabled); | ||
|
||
/* Check error handling */ | ||
{ | ||
EXPECT_SUCCESS(s2n_disable_tls13()); | ||
EXPECT_FAILURE_WITH_ERRNO(s2n_connection_enable_quic(conn), S2N_ERR_PROTOCOL_VERSION_UNSUPPORTED); | ||
EXPECT_FALSE(conn->quic_enabled); | ||
|
||
EXPECT_SUCCESS(s2n_enable_tls13()); | ||
EXPECT_FAILURE_WITH_ERRNO(s2n_connection_enable_quic(NULL), S2N_ERR_NULL); | ||
EXPECT_FALSE(conn->quic_enabled); | ||
} | ||
|
||
/* Check success */ | ||
{ | ||
EXPECT_SUCCESS(s2n_enable_tls13()); | ||
EXPECT_SUCCESS(s2n_connection_enable_quic(conn)); | ||
EXPECT_TRUE(conn->quic_enabled); | ||
|
||
/* Enabling QUIC again still succeeds */ | ||
EXPECT_SUCCESS(s2n_connection_enable_quic(conn)); | ||
EXPECT_TRUE(conn->quic_enabled); | ||
} | ||
|
||
EXPECT_SUCCESS(s2n_connection_free(conn)); | ||
} | ||
|
||
END_TEST(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
#include "tls/s2n_quic_support.h" | ||
|
||
#include "tls/s2n_connection.h" | ||
#include "tls/s2n_tls13.h" | ||
#include "utils/s2n_safety.h" | ||
|
||
int s2n_connection_enable_quic(struct s2n_connection *conn) | ||
{ | ||
/* The QUIC protocol doesn't use pre-1.3 TLS */ | ||
ENSURE_POSIX(s2n_is_tls13_enabled(), S2N_ERR_PROTOCOL_VERSION_UNSUPPORTED); | ||
|
||
notnull_check(conn); | ||
conn->quic_enabled = true; | ||
return S2N_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "api/s2n.h" | ||
|
||
/* | ||
* APIs intended to support an external implementation of the QUIC protocol: | ||
* https://datatracker.ietf.org/wg/quic/about/ | ||
* | ||
* QUIC requires access to parts of S2N not usually surfaced to customers. These APIs change | ||
* the behavior of S2N in potentially dangerous ways and should only be used by implementations | ||
* of the QUIC protocol. | ||
* | ||
* Additionally, the QUIC RFC is not yet finalized, so all QUIC APIs are considered experimental | ||
* and are subject to change without notice. They should only be used for testing purposes. | ||
*/ | ||
|
||
S2N_API int s2n_connection_enable_quic(struct s2n_connection *conn); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters