Skip to content

Commit 6578f88

Browse files
authored
docs: add pq to usage guide (#4677)
1 parent 79c0f1b commit 6578f88

File tree

10 files changed

+159
-2
lines changed

10 files changed

+159
-2
lines changed

bin/s2nc.c

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "api/unstable/npn.h"
3434
#include "api/unstable/renegotiate.h"
3535
#include "common.h"
36+
#include "crypto/s2n_libcrypto.h"
3637
#include "error/s2n_errno.h"
3738
#include "tls/s2n_connection.h"
3839

@@ -591,6 +592,7 @@ int main(int argc, char *const *argv)
591592
}
592593

593594
GUARD_EXIT(s2n_init(), "Error running s2n_init()");
595+
printf("libcrypto: %s\n", s2n_libcrypto_get_version_name());
594596

595597
if ((r = getaddrinfo(host, port, &hints, &ai_list)) != 0) {
596598
fprintf(stderr, "error: %s\n", gai_strerror(r));

bin/s2nd.c

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "api/s2n.h"
3535
#include "api/unstable/npn.h"
3636
#include "common.h"
37+
#include "crypto/s2n_libcrypto.h"
3738
#include "utils/s2n_safety.h"
3839

3940
#define MAX_CERTIFICATES 50
@@ -565,6 +566,7 @@ int main(int argc, char *const *argv)
565566
}
566567

567568
GUARD_EXIT(s2n_init(), "Error running s2n_init()");
569+
printf("libcrypto: %s\n", s2n_libcrypto_get_version_name());
568570

569571
printf("Listening on %s:%s\n", host, port);
570572

bindings/rust/s2n-tls/src/security.rs

+5
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,14 @@ pub const DEFAULT_TLS13: Policy = policy!("default_tls13");
8787
#[cfg(feature = "pq")]
8888
pub const TESTING_PQ: Policy = policy!("PQ-TLS-1-0-2021-05-26");
8989

90+
#[cfg(feature = "pq")]
91+
pub const DEFAULT_PQ: Policy = policy!("default_pq");
92+
9093
pub const ALL_POLICIES: &[Policy] = &[
9194
DEFAULT,
9295
DEFAULT_TLS13,
9396
#[cfg(feature = "pq")]
9497
TESTING_PQ,
98+
#[cfg(feature = "pq")]
99+
DEFAULT_PQ,
95100
];

crypto/s2n_libcrypto.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
* symbol OpenSSL_version binded to at link-time. This can be used as
5656
* verification at run-time that s2n linked against the expected libcrypto.
5757
*/
58-
static const char *s2n_libcrypto_get_version_name(void)
58+
const char *s2n_libcrypto_get_version_name(void)
5959
{
6060
return SSLeay_version(SSLEAY_VERSION);
6161
}

crypto/s2n_libcrypto.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818
#include "utils/s2n_result.h"
1919

2020
S2N_RESULT s2n_libcrypto_validate_runtime(void);
21-
21+
const char *s2n_libcrypto_get_version_name(void);
2222
bool s2n_libcrypto_supports_flag_no_check_time();

docs/BUILD.md

+4
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ cmake --install build
6868

6969
Note that we currently do not support building on Windows. See https://github.com/aws/s2n-tls/issues/497 for more information.
7070

71+
Using the commands above, the libraries and headers will be located in the `s2n-tls-install` directory.
72+
73+
The s2nc and s2nd test utilities are not installed by default, but can be found in the `build/bin` directory. To also install s2nc and s2nd, add `-DS2N_INSTALL_S2NC_S2ND=1` to the cmake command.
74+
7175
## Consuming s2n-tls via CMake
7276

7377
s2n-tls ships with modern CMake finder scripts if CMake is used for the build. To take advantage of this from your CMake script, all you need to do to compile and link against s2n-tls in your project is:

docs/usage-guide/topics/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
- [Offloading Private Key Operations](./ch12-private-key-ops.md)
1616
- [Pre-shared Keys](./ch13-preshared-keys.md)
1717
- [Early Data](./ch14-early-data.md)
18+
- [Post Quantum Support](./ch15-post-quantum.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Post Quantum (PQ) Support
2+
3+
s2n-tls supports post-quantum key exchange for TLS1.3. Currently, only [Kyber](https://pq-crystals.org/kyber/) is supported. See the draft IETF standard: https://datatracker.ietf.org/doc/html/draft-ietf-tls-hybrid-design
4+
5+
Specifically, s2n-tls supports hybrid key exchange. PQ hybrid key exchange involves performing both classic ECDH key exchange and post-quantum Kyber key exchange, then combining the two resultant secrets. This strategy combines the high assurance of the classical key exchange algorithms with the quantum-resistance of the new post-quantum key exchange algorithms. If one of the two algorithms is compromised, either because advances in quantum computing make the classic algorithms insecure or because cryptographers find a flaw in the relatively new post-quantum algorithms, the secret is still secure. Hybrid post-quantum key exchange is more secure than standard key exchange, but is slower and requires more processing and more network bandwidth.
6+
7+
Careful: if an s2n-tls server is configured to support post-quantum key exchange, the server will require that any client that advertises support ultimately uses post-quantum key exchange. That will result in a retry and an extra round trip if the client does not intially provide a post-quantum key share.
8+
9+
## Requirements
10+
11+
### AWS-LC
12+
13+
s2n-tls must be built with aws-lc to use post-quantum key exchange. See the [s2n-tls build documentation](https://github.com/aws/s2n-tls/blob/main/docs/BUILD.md#building-with-a-specific-libcrypto) for how to build with aws-lc.
14+
15+
If you're unsure what cryptography library s2n-tls is built against, trying running s2nd or s2nc:
16+
```
17+
> s2nd localhost 8000
18+
libcrypto: AWS-LC
19+
Listening on localhost:8000
20+
```
21+
22+
### Security Policy
23+
24+
Post-quantum key exchange is enabled by configuring a security policy (see [Security Policies](./ch06-security-policies.md)) that supports post-quantum key exchange algorithms.
25+
26+
"default_pq" is the equivalent of "default_tls13", but with PQ support. Like the other default policies, "default_pq" may change as a result of library updates. The fixed, numbered equivalent of "default_pq" is currently "20240730". For previous defaults, see the "Default Policy History" section below.
27+
28+
Other available PQ policies are compared in the tables below.
29+
30+
### Chart: Security Policy Version To PQ Hybrid Key Exchange Methods
31+
32+
| Version | secp256r1+kyber768 | x25519+kyber768 | secp384r1+kyber768 | secp521r1+kyber1024 | secp256r1+kyber512 | x25519+kyber512 |
33+
|-----------------------|--------------------|-----------------|--------------------|---------------------|--------------------|-----------------|
34+
| default_pq / 20240730 | X | X | X | X | X | X |
35+
| PQ-TLS-1-2-2023-12-15 | X | | X | X | X | |
36+
| PQ-TLS-1-2-2023-12-14 | X | | X | X | X | |
37+
| PQ-TLS-1-2-2023-12-13 | X | | X | X | X | |
38+
| PQ-TLS-1-2-2023-10-10 | X | X | X | X | X | X |
39+
| PQ-TLS-1-2-2023-10-09 | X | X | X | X | X | X |
40+
| PQ-TLS-1-2-2023-10-08 | X | X | X | X | X | X |
41+
| PQ-TLS-1-2-2023-10-07 | X | X | X | X | X | X |
42+
| PQ-TLS-1-3-2023-06-01 | X | X | X | X | X | X |
43+
44+
### Chart: Security Policy Version To Classic Key Exchange
45+
46+
If the peer doesn't support a PQ hybrid key exchange method, s2n-tls will fall back to a classical option.
47+
48+
| Version | secp256r1 | x25519 | secp384r1 | secp521r1 | DHE | RSA |
49+
|-----------------------|-----------|--------|-----------|-----------|-----|-----|
50+
| default_pq / 20240730 | X | X | X | X | | |
51+
| PQ-TLS-1-2-2023-12-15 | X | | X | X | X | |
52+
| PQ-TLS-1-2-2023-12-14 | X | | X | X | | |
53+
| PQ-TLS-1-2-2023-12-13 | X | | X | X | | X |
54+
| PQ-TLS-1-2-2023-10-10 | X | X | X | | X | X |
55+
| PQ-TLS-1-2-2023-10-09 | X | X | X | | X | |
56+
| PQ-TLS-1-2-2023-10-08 | X | X | X | | X | X |
57+
| PQ-TLS-1-2-2023-10-07 | X | X | X | | | X |
58+
| PQ-TLS-1-3-2023-06-01 | X | | X | X | X | X |
59+
60+
### Chart: Security Policy Version To Ciphers
61+
62+
| Version | AES-CBC | AES-GCM | CHACHAPOLY | 3DES |
63+
|-----------------------|---------|---------|------------|------|
64+
| default_pq / 20240730 | X | X | X | |
65+
| PQ-TLS-1-2-2023-12-15 | X | X | | |
66+
| PQ-TLS-1-2-2023-12-14 | X | X | | |
67+
| PQ-TLS-1-2-2023-12-13 | X | X | | |
68+
| PQ-TLS-1-2-2023-10-10 | X | X | X* | X |
69+
| PQ-TLS-1-2-2023-10-09 | X | X | X* | X |
70+
| PQ-TLS-1-2-2023-10-08 | X | X | X* | X |
71+
| PQ-TLS-1-2-2023-10-07 | X | X | X* | |
72+
| PQ-TLS-1-3-2023-06-01 | X | X | X* | X |
73+
\* only for TLS1.3
74+
75+
### Chart: Security Policy Version To Signature Schemes
76+
77+
| Version | ECDSA | RSA | RSA-PSS | Legacy SHA1 |
78+
|-----------------------|---------|-----|---------|-------------|
79+
| default_pq / 20240730 | X | X | X | |
80+
| PQ-TLS-1-2-2023-12-15 | X | X | X | |
81+
| PQ-TLS-1-2-2023-12-14 | X | X | X | |
82+
| PQ-TLS-1-2-2023-12-13 | X | X | X | |
83+
| PQ-TLS-1-2-2023-10-10 | X | X | X | X |
84+
| PQ-TLS-1-2-2023-10-09 | X | X | X | X |
85+
| PQ-TLS-1-2-2023-10-08 | X | X | X | X |
86+
| PQ-TLS-1-2-2023-10-07 | X | X | X | X |
87+
| PQ-TLS-1-3-2023-06-01 | X | X | X | X |
88+
89+
### Chart: Security Policy Version To TLS Protocol Version
90+
91+
| Version | 1.2 | 1.3 |
92+
|-----------------------|-----|-----|
93+
| default_pq / 20240730 | X | X |
94+
| PQ-TLS-1-2-2023-12-15 | X | X |
95+
| PQ-TLS-1-2-2023-12-14 | X | X |
96+
| PQ-TLS-1-2-2023-12-13 | X | X |
97+
| PQ-TLS-1-2-2023-10-10 | X | X |
98+
| PQ-TLS-1-2-2023-10-09 | X | X |
99+
| PQ-TLS-1-2-2023-10-08 | X | X |
100+
| PQ-TLS-1-2-2023-10-07 | X | X |
101+
| PQ-TLS-1-3-2023-06-01 | X | X |
102+
103+
#### Default Policy History
104+
| Version | "default_pq" |
105+
|------------|--------------|
106+
| v1.5.0 | 20240730 |

tests/unit/s2n_security_policies_test.c

+22
Original file line numberDiff line numberDiff line change
@@ -1090,5 +1090,27 @@ int main(int argc, char **argv)
10901090
};
10911091
};
10921092

1093+
/* Test that default_pq always matches default_tls13 */
1094+
{
1095+
const struct s2n_security_policy *default_pq = NULL;
1096+
EXPECT_SUCCESS(s2n_find_security_policy_from_version("default_pq", &default_pq));
1097+
EXPECT_NOT_EQUAL(default_pq->kem_preferences, &kem_preferences_null);
1098+
1099+
const struct s2n_security_policy *default_tls13 = NULL;
1100+
EXPECT_SUCCESS(s2n_find_security_policy_from_version("default_tls13", &default_tls13));
1101+
EXPECT_EQUAL(default_tls13->kem_preferences, &kem_preferences_null);
1102+
1103+
/* If we ignore kem preferences, the two policies match */
1104+
EXPECT_EQUAL(default_pq->minimum_protocol_version, default_tls13->minimum_protocol_version);
1105+
EXPECT_EQUAL(default_pq->cipher_preferences, default_tls13->cipher_preferences);
1106+
EXPECT_EQUAL(default_pq->signature_preferences, default_tls13->signature_preferences);
1107+
EXPECT_EQUAL(default_pq->certificate_signature_preferences,
1108+
default_tls13->certificate_signature_preferences);
1109+
EXPECT_EQUAL(default_pq->ecc_preferences, default_tls13->ecc_preferences);
1110+
EXPECT_EQUAL(default_pq->certificate_key_preferences, default_tls13->certificate_key_preferences);
1111+
EXPECT_EQUAL(default_pq->certificate_preferences_apply_locally,
1112+
default_tls13->certificate_preferences_apply_locally);
1113+
};
1114+
10931115
END_TEST();
10941116
}

tls/s2n_security_policies.c

+15
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ const struct s2n_security_policy security_policy_20240503 = {
5959
},
6060
};
6161

62+
/* PQ default as of 07/24 */
63+
const struct s2n_security_policy security_policy_20240730 = {
64+
.minimum_protocol_version = S2N_TLS12,
65+
.cipher_preferences = &cipher_preferences_cloudfront_tls_1_2_2019,
66+
.kem_preferences = &kem_preferences_pq_tls_1_3_2023_06,
67+
.signature_preferences = &s2n_signature_preferences_20240501,
68+
.certificate_signature_preferences = &s2n_certificate_signature_preferences_20201110,
69+
.ecc_preferences = &s2n_ecc_preferences_20240501,
70+
.rules = {
71+
[S2N_PERFECT_FORWARD_SECRECY] = true,
72+
},
73+
};
74+
6275
const struct s2n_security_policy security_policy_20240603 = {
6376
.minimum_protocol_version = S2N_TLS12,
6477
.cipher_preferences = &cipher_preferences_20240603,
@@ -1124,13 +1137,15 @@ struct s2n_security_policy_selection security_policy_selection[] = {
11241137
{ .version = "default", .security_policy = &security_policy_20240501, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
11251138
{ .version = "default_tls13", .security_policy = &security_policy_20240503, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
11261139
{ .version = "default_fips", .security_policy = &security_policy_20240502, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
1140+
{ .version = "default_pq", .security_policy = &security_policy_20240730, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
11271141
{ .version = "20240501", .security_policy = &security_policy_20240501, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
11281142
{ .version = "20240502", .security_policy = &security_policy_20240502, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
11291143
{ .version = "20240503", .security_policy = &security_policy_20240503, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
11301144
{ .version = "20230317", .security_policy = &security_policy_20230317, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
11311145
{ .version = "20240331", .security_policy = &security_policy_20240331, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
11321146
{ .version = "20240417", .security_policy = &security_policy_20240417, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
11331147
{ .version = "20240416", .security_policy = &security_policy_20240416, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
1148+
{ .version = "20240730", .security_policy = &security_policy_20240730, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
11341149
{ .version = "ELBSecurityPolicy-TLS-1-0-2015-04", .security_policy = &security_policy_elb_2015_04, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },
11351150
/* Not a mistake. TLS-1-0-2015-05 and 2016-08 are equivalent */
11361151
{ .version = "ELBSecurityPolicy-TLS-1-0-2015-05", .security_policy = &security_policy_elb_2016_08, .ecc_extension_required = 0, .pq_kem_extension_required = 0 },

0 commit comments

Comments
 (0)