Skip to content

Commit 28be25a

Browse files
authored
Merge pull request #10949 from IngelaAndin/ingela/ssl/pqc-defaults/OTP-20070
Ingela/ssl/pqc defaults/otp 20070
2 parents 8791dde + 3f36c31 commit 28be25a

6 files changed

Lines changed: 109 additions & 120 deletions

File tree

lib/ssl/src/ssl.erl

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -693,8 +693,7 @@ Options common to both client and server side.
693693
Used to limit the size of valid TLS handshake packets to avoid DoS
694694
attacks.
695695

696-
Integer (24 bits, unsigned). Defaults to `256*1024` before OTP-26 or if SLH-DSA algorithms
697-
are configured, otherwise the default is `256*1024`/2.
696+
Integer (24 bits, unsigned). Defaults to `262144` since OTP 29.0
698697

699698
- **`{hibernate_after, HibernateTimeout}`** - Hibernate inactive connection processes.
700699

@@ -751,7 +750,7 @@ Common certificate related options to both client and server.
751750
connection will be selected.
752751

753752
The different signature algorithms are prioritized in the following
754-
order: `eddsa`, `ecdsa`, `rsa_pss_pss`, `rsa`, and `dsa`. If more
753+
order: `mldsa`, `slhdsa`, `eddsa`, `ecdsa`, `rsa_pss_pss`, `rsa`, and `dsa`. If more
755754
than one key is supplied for the same signature algorithm, they will
756755
be prioritized by strength (except for _engine keys_; see the next
757756
paragraph). This offers flexibility to, for instance, configure a
@@ -769,7 +768,7 @@ Common certificate related options to both client and server.
769768

770769
> #### Note {: .info }
771770
>
772-
> `eddsa` certificates are only supported by TLS-1.3 implementations that do not support `dsa`
771+
> `mldsa`, `slhdsa`, `eddsa` certificates are only supported by TLS-1.3 implementations that do not support `dsa`
773772
> certificates. `rsa_pss_pss` (RSA certificates using Probabilistic Signature
774773
> Scheme) are supported in TLS-1.2 and TLS-1.3, but some TLS-1.2 implementations
775774
> do not support `rsa_pss_pss`.
@@ -1392,7 +1391,7 @@ The following options are specific to the client side, or have
13921391
different semantics for the client and server:
13931392

13941393
- **`{psk_groups, Groups}`** - key exchange groups that the client
1395-
will send pre share keys for, defaults to first group in
1394+
will send pre shared keys for, defaults to the first group in
13961395
supported_groups. Must be a subset of supported_groups and will
13971396
be sent in the same order as they appear in supported_groups.
13981397

@@ -1445,7 +1444,7 @@ different semantics for the client and server.
14451444
> #### Change {: .info }
14461445
>
14471446
> The default for `Verify` was changed to `verify_peer` in
1448-
> Erlang/OTP 26.
1447+
> Erlang/OTP 26.0.
14491448
14501449
- **`{cacerts, CACerts}`** - Trusted certificates
14511450

@@ -1864,7 +1863,7 @@ Certificate related options for a server.
18641863
`true`, the server fails if the client does not have a certificate to send, that
18651864
is, sends an empty certificate. If set to `false`, it fails only if the client
18661865
sends an invalid certificate (an empty certificate is considered valid).
1867-
Defaults to `true`, the default value was changed in OTP-26.0.
1866+
Defaults to `true`, the default value was changed in OTP 26.0.
18681867
18691868
- **`{certificate_authorities, ServerCertAuth}`** - Inter-operate hint option
18701869
@@ -3047,25 +3046,29 @@ Example:
30473046
30483047
```erlang
30493048
1> ssl:signature_algs(default, 'tlsv1.3').
3050-
[eddsa_ed25519,eddsa_ed448,ecdsa_secp521r1_sha512,
3051-
ecdsa_secp384r1_sha384,ecdsa_secp256r1_sha256,
3052-
ecdsa_brainpoolP512r1tls13_sha512,
3053-
ecdsa_brainpoolP384r1tls13_sha384,
3054-
ecdsa_brainpoolP256r1tls13_sha256,rsa_pss_pss_sha512,
3055-
rsa_pss_pss_sha384,rsa_pss_pss_sha256,rsa_pss_rsae_sha512,
3056-
rsa_pss_rsae_sha384,rsa_pss_rsae_sha256,mldsa44,mldsa65,
3057-
mldsa87,rsa_pkcs1_sha512,rsa_pkcs1_sha384,rsa_pkcs1_sha256,
3049+
[mldsa87,mldsa65,mldsa44,slh_dsa_shake_256f,slh_dsa_shake_256s,
3050+
slh_dsa_sha2_256f,slh_dsa_sha2_256s,slh_dsa_shake_192f,slh_dsa_shake_192s,
3051+
slh_dsa_sha2_192f,slh_dsa_sha2_192s,slh_dsa_shake_128f,slh_dsa_shake_128s,
3052+
slh_dsa_sha2_128f,slh_dsa_sha2_128s,eddsa_ed25519,eddsa_ed448,
3053+
ecdsa_secp521r1_sha512,ecdsa_secp384r1_sha384,ecdsa_secp256r1_sha256,
3054+
ecdsa_brainpoolP512r1tls13_sha512,ecdsa_brainpoolP384r1tls13_sha384,
3055+
ecdsa_brainpoolP256r1tls13_sha256,rsa_pss_pss_sha512,rsa_pss_pss_sha384,
3056+
rsa_pss_pss_sha256,rsa_pss_rsae_sha512,rsa_pss_rsae_sha384,
3057+
rsa_pss_rsae_sha256,rsa_pkcs1_sha512,rsa_pkcs1_sha384,rsa_pkcs1_sha256,
30583058
{sha512,ecdsa},
30593059
{sha384,ecdsa},
3060-
{sha256,ecdsa}]
3060+
{sha256,ecdsa}].
30613061
30623062
2> ssl:signature_algs(all, 'tlsv1.3').
3063-
[eddsa_ed25519,eddsa_ed448,ecdsa_secp521r1_sha512,ecdsa_secp384r1_sha384,
3064-
ecdsa_secp256r1_sha256,ecdsa_brainpoolP512r1tls13_sha512,
3065-
ecdsa_brainpoolP384r1tls13_sha384,ecdsa_brainpoolP256r1tls13_sha256,
3066-
rsa_pss_pss_sha512,rsa_pss_pss_sha384,rsa_pss_pss_sha256,rsa_pss_rsae_sha512,
3067-
rsa_pss_rsae_sha384,rsa_pss_rsae_sha256,mldsa44,mldsa65,mldsa87,
3068-
rsa_pkcs1_sha512,rsa_pkcs1_sha384,rsa_pkcs1_sha256,
3063+
[mldsa87,mldsa65,mldsa44,slh_dsa_shake_256f,slh_dsa_shake_256s,
3064+
slh_dsa_sha2_256f,slh_dsa_sha2_256s,slh_dsa_shake_192f,slh_dsa_shake_192s,
3065+
slh_dsa_sha2_192f,slh_dsa_sha2_192s,slh_dsa_shake_128f,slh_dsa_shake_128s,
3066+
slh_dsa_sha2_128f,slh_dsa_sha2_128s,eddsa_ed25519,eddsa_ed448,
3067+
ecdsa_secp521r1_sha512,ecdsa_secp384r1_sha384,ecdsa_secp256r1_sha256,
3068+
ecdsa_brainpoolP512r1tls13_sha512,ecdsa_brainpoolP384r1tls13_sha384,
3069+
ecdsa_brainpoolP256r1tls13_sha256,rsa_pss_pss_sha512,rsa_pss_pss_sha384,
3070+
rsa_pss_pss_sha256,rsa_pss_rsae_sha512,rsa_pss_rsae_sha384,
3071+
rsa_pss_rsae_sha256,rsa_pkcs1_sha512,rsa_pkcs1_sha384,rsa_pkcs1_sha256,
30693072
{sha512,ecdsa},
30703073
{sha384,ecdsa},
30713074
{sha256,ecdsa},
@@ -3078,15 +3081,15 @@ Example:
30783081
{sha,dsa}]
30793082
30803083
3> [ssl:signature_algs(exclusive, 'tlsv1.3').
3081-
[eddsa_ed25519,eddsa_ed448,ecdsa_secp521r1_sha512,ecdsa_secp384r1_sha384,
3082-
ecdsa_secp256r1_sha256,ecdsa_brainpoolP512r1tls13_sha512,
3083-
ecdsa_brainpoolP384r1tls13_sha384,ecdsa_brainpoolP256r1tls13_sha256,
3084-
rsa_pss_pss_sha512,rsa_pss_pss_sha384,rsa_pss_pss_sha256,rsa_pss_rsae_sha512,
3085-
rsa_pss_rsae_sha384,rsa_pss_rsae_sha256,mldsa44,mldsa65,mldsa87,
3086-
rsa_pkcs1_sha512,rsa_pkcs1_sha384,rsa_pkcs1_sha256,slh_dsa_shake_256f,
3087-
slh_dsa_shake_256s,slh_dsa_sha2_256f,slh_dsa_sha2_256s,slh_dsa_shake_192f,
3088-
slh_dsa_shake_192s,slh_dsa_sha2_192f,slh_dsa_sha2_192s,slh_dsa_shake_128f,
3089-
slh_dsa_shake_128s,slh_dsa_sha2_128f,slh_dsa_sha2_128s]
3084+
[mldsa87,mldsa65,mldsa44,slh_dsa_shake_256f,slh_dsa_shake_256s,
3085+
slh_dsa_sha2_256f,slh_dsa_sha2_256s,slh_dsa_shake_192f,slh_dsa_shake_192s,
3086+
slh_dsa_sha2_192f,slh_dsa_sha2_192s,slh_dsa_shake_128f,slh_dsa_shake_128s,
3087+
slh_dsa_sha2_128f,slh_dsa_sha2_128s,eddsa_ed25519,eddsa_ed448,
3088+
ecdsa_secp521r1_sha512,ecdsa_secp384r1_sha384,ecdsa_secp256r1_sha256,
3089+
ecdsa_brainpoolP512r1tls13_sha512,ecdsa_brainpoolP384r1tls13_sha384,
3090+
ecdsa_brainpoolP256r1tls13_sha256,rsa_pss_pss_sha512,rsa_pss_pss_sha384,
3091+
rsa_pss_pss_sha256,rsa_pss_rsae_sha512,rsa_pss_rsae_sha384,
3092+
rsa_pss_rsae_sha256,rsa_pkcs1_sha512,rsa_pkcs1_sha384,rsa_pkcs1_sha256]
30903093
```
30913094
30923095
> #### Note {: .info }
@@ -3112,15 +3115,13 @@ signature_algs(default, 'tlsv1.2') ->
31123115
signature_algs(all, 'tlsv1.3') ->
31133116
tls_v1:default_signature_algs([tls_record:protocol_version_name('tlsv1.3'),
31143117
tls_record:protocol_version_name('tlsv1.2')]) ++
3115-
tls_v1:slh_dsa_schemes() ++
31163118
[ecdsa_sha1, rsa_pkcs1_sha1 | tls_v1:legacy_signature_algs_pre_13()] --
31173119
[{sha, ecdsa}, {sha, rsa}];
31183120
signature_algs(all, 'tlsv1.2') ->
31193121
tls_v1:default_signature_algs([tls_record:protocol_version_name('tlsv1.2')]) ++
31203122
tls_v1:legacy_signature_algs_pre_13();
31213123
signature_algs(exclusive, 'tlsv1.3') ->
3122-
tls_v1:default_signature_algs([tls_record:protocol_version_name('tlsv1.3')]) ++
3123-
tls_v1:slh_dsa_schemes();
3124+
tls_v1:default_signature_algs([tls_record:protocol_version_name('tlsv1.3')]);
31243125
signature_algs(exclusive, 'tlsv1.2') ->
31253126
Algs = tls_v1:default_signature_algs([tls_record:protocol_version_name('tlsv1.2')]),
31263127
Algs ++ tls_v1:legacy_signature_algs_pre_13();
@@ -3178,7 +3179,7 @@ eccs(Other) ->
31783179
-doc """
31793180
Returns all supported groups in TLS 1.3.
31803181
3181-
Existed since OTP 22.0; documented as of OTP 27.
3182+
Existed since OTP 22.0; documented as of OTP 27.0.
31823183
""".
31833184
-spec groups() -> [group()].
31843185
%%--------------------------------------------------------------------
@@ -3193,7 +3194,7 @@ groups() ->
31933194
-doc """
31943195
Returns default supported groups in TLS 1.3.
31953196
3196-
Existed since OTP 22.0; documented as of OTP 27.
3197+
Existed since OTP 22.0; documented as of OTP 27.0.
31973198
""".
31983199
31993200
%%--------------------------------------------------------------------

lib/ssl/src/ssl_certificate.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ available_cert_key_pairs(CertKeyGroups) ->
361361
%% Create the prioritized list of cert key pairs that
362362
%% are availble for use in the negotiated version
363363
available_cert_key_pairs(CertKeyGroups, ?TLS_1_3) ->
364-
RevAlgos = [slhdsa, mldsa, rsa, rsa_pss_pss, ecdsa, eddsa],
364+
RevAlgos = [rsa, rsa_pss_pss, ecdsa, eddsa, slhdsa, mldsa],
365365
cert_key_group_to_list(RevAlgos, CertKeyGroups, []);
366366
available_cert_key_pairs(CertKeyGroups, ?TLS_1_2) ->
367367
RevAlgos = [dsa, rsa, rsa_pss_pss, ecdsa],

lib/ssl/src/ssl_config.erl

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,10 +1471,10 @@ opt_supported_groups(UserOpts, #{versions := TlsVsns} = Opts, Env) ->
14711471

14721472
opt_psk_groups(undefined, _, _, _) ->
14731473
undefined;
1474-
opt_psk_groups(#supported_groups{supported_groups = SupportedGroups}, UserOpts, Opts, _Env) ->
1474+
opt_psk_groups(#supported_groups{supported_groups = [First| _] = SupportedGroups},
1475+
UserOpts, Opts, _Env) ->
14751476
%% Version dependency already asserted when SupportedGroups is supported
1476-
%% so is psk_groups
1477-
First = hd(SupportedGroups),
1477+
%% hence so is psk_groups
14781478
case get_opt_list(psk_groups, [First], UserOpts, Opts) of
14791479
{default, Default} ->
14801480
Default;
@@ -1497,30 +1497,11 @@ opt_crl(UserOpts, Opts, _Env) ->
14971497
opt_handshake(UserOpts, Opts, _Env) ->
14981498
{_, HS} = get_opt_of(handshake, [hello, full], full, UserOpts, Opts),
14991499

1500-
DefaultMaxHS = default_max_hs(Opts),
1501-
1502-
{_, MHSS} = get_opt_int(max_handshake_size, 1, ?MAX_UNIT24 , DefaultMaxHS,
1500+
{_, MHSS} = get_opt_int(max_handshake_size, 1, ?MAX_UNIT24 , ?DEFAULT_MAX_HANDSHAKE_SIZE,
15031501
UserOpts, Opts),
15041502

15051503
Opts#{handshake => HS, max_handshake_size => MHSS}.
15061504

1507-
default_max_hs(#{signature_algs:= undefined}) ->
1508-
?DEFAULT_MAX_HANDSHAKE_SIZE;
1509-
default_max_hs(#{signature_algs:= Algs}) ->
1510-
%%% In OTP-26 max handshake_size was lowered by half for most
1511-
%%% handshakes would fit that size and OpenSSL had a lower default
1512-
Set = sets:intersection(sets:from_list(Algs, [{version, 2}]),
1513-
sets:from_list(tls_v1:slh_dsa_schemes(),
1514-
[{version, 2}])),
1515-
case sets:is_empty(Set) of
1516-
true ->
1517-
?DEFAULT_MAX_HANDSHAKE_SIZE;
1518-
false ->
1519-
%% SLH_DSA creates fairly big handshake sizes so raise limit back
1520-
%% if these algorithms are supported,
1521-
?DEFAULT_MAX_HANDSHAKE_SIZE * 2
1522-
end.
1523-
15241505
opt_use_srtp(UserOpts, #{protocol := Protocol} = Opts, _Env) ->
15251506
UseSRTP = case get_opt_map(use_srtp, undefined, UserOpts, Opts) of
15261507
{old, UseSRTP0} ->

lib/ssl/src/ssl_handshake.hrl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,10 @@
8787
-define(FINISHED, 20).
8888
-define(MAX_UNIT24, 8388607).
8989

90-
%% Usually the biggest handshake message will be the message conveying the
91-
%% certificate chain. This size should be sufficient for usual certificate
92-
%% chains, certificates without special extensions have a typical size of
93-
%% 1-2kB. By dividing the old default value by 2 we still have a slightly
94-
%% bigger margin than OpenSSL
95-
-define(DEFAULT_MAX_HANDSHAKE_SIZE, ((256*1024) div 2)).
90+
%% As of OTP-29 when PQC-algorithm SLH-DSA is supported by default
91+
%% handshakes need to allowed to be bigger by default to handle
92+
%% normal SLH-DSA keys.
93+
-define(DEFAULT_MAX_HANDSHAKE_SIZE, 256*1024).
9694

9795
-record(random, {
9896
gmt_unix_time, % uint32

lib/ssl/src/tls_v1.erl

Lines changed: 60 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,24 +1045,24 @@ signature_schemes(_, _) ->
10451045
[].
10461046

10471047
default_signature_schemes(Version) ->
1048-
Default = [eddsa_ed25519,
1049-
eddsa_ed448,
1050-
ecdsa_secp521r1_sha512,
1051-
ecdsa_secp384r1_sha384,
1052-
ecdsa_secp256r1_sha256,
1053-
ecdsa_brainpoolP512r1tls13_sha512,
1054-
ecdsa_brainpoolP384r1tls13_sha384,
1055-
ecdsa_brainpoolP256r1tls13_sha256,
1056-
rsa_pss_pss_sha512,
1057-
rsa_pss_pss_sha384,
1058-
rsa_pss_pss_sha256,
1059-
rsa_pss_rsae_sha512,
1060-
rsa_pss_rsae_sha384,
1061-
rsa_pss_rsae_sha256,
1062-
mldsa44,
1048+
Default = [mldsa87,
10631049
mldsa65,
1064-
mldsa87
1065-
],
1050+
mldsa44] ++ slh_dsa_schemes() ++
1051+
[eddsa_ed25519,
1052+
eddsa_ed448,
1053+
ecdsa_secp521r1_sha512,
1054+
ecdsa_secp384r1_sha384,
1055+
ecdsa_secp256r1_sha256,
1056+
ecdsa_brainpoolP512r1tls13_sha512,
1057+
ecdsa_brainpoolP384r1tls13_sha384,
1058+
ecdsa_brainpoolP256r1tls13_sha256,
1059+
rsa_pss_pss_sha512,
1060+
rsa_pss_pss_sha384,
1061+
rsa_pss_pss_sha256,
1062+
rsa_pss_rsae_sha512,
1063+
rsa_pss_rsae_sha384,
1064+
rsa_pss_rsae_sha256
1065+
],
10661066
signature_schemes(Version, Default).
10671067

10681068
legacy_signature_schemes(Version) ->
@@ -1248,48 +1248,37 @@ ecc_curves(Version) when is_tuple(Version) ->
12481248
ecc_curves(TLSCurves);
12491249
ecc_curves(TLSCurves) ->
12501250
[pubkey_cert_records:namedCurves(Curve) || Curve <- TLSCurves].
1251-
1251+
12521252
groups() ->
12531253
TLSGroups = groups(all),
12541254
groups(TLSGroups).
12551255

12561256
-spec groups(all | default | TLSGroups :: list()) -> [ssl:group()].
12571257
groups(all) ->
1258-
[x25519,
1259-
x448,
1260-
secp521r1,
1261-
secp384r1,
1262-
secp256r1,
1263-
brainpoolP256r1tls13,
1264-
brainpoolP384r1tls13,
1265-
brainpoolP512r1tls13,
1266-
mlkem512,
1267-
mlkem768,
1268-
mlkem1024,
1269-
x25519mlkem768,
1270-
secp384r1mlkem1024,
1271-
secp256r1mlkem768,
1272-
ffdhe2048,
1273-
ffdhe3072,
1274-
ffdhe4096,
1275-
ffdhe6144,
1276-
ffdhe8192];
1258+
default_pqc_hybrid_groups() ++
1259+
[x25519,
1260+
x448,
1261+
secp521r1,
1262+
secp384r1,
1263+
secp256r1,
1264+
brainpoolP256r1tls13,
1265+
brainpoolP384r1tls13,
1266+
brainpoolP512r1tls13
1267+
] ++
1268+
other_pqc_hybrid_groups() ++
1269+
pqc_plain_groups() ++
1270+
dhe_groups();
12771271
groups(default) ->
1278-
[x25519,
1279-
x448,
1280-
secp521r1,
1281-
secp384r1,
1282-
secp256r1,
1283-
brainpoolP512r1tls13,
1284-
brainpoolP384r1tls13,
1285-
brainpoolP256r1tls13,
1286-
mlkem512,
1287-
mlkem768,
1288-
mlkem1024,
1289-
x25519mlkem768,
1290-
secp384r1mlkem1024,
1291-
secp256r1mlkem768
1292-
];
1272+
default_pqc_hybrid_groups() ++
1273+
[x25519,
1274+
x448,
1275+
secp521r1,
1276+
secp384r1,
1277+
secp256r1,
1278+
brainpoolP512r1tls13,
1279+
brainpoolP384r1tls13,
1280+
brainpoolP256r1tls13
1281+
];
12931282
groups(TLSGroups) when is_list(TLSGroups) ->
12941283
CryptoGroups = crypto_supported_groups(),
12951284
lists:filter(fun(x25519mlkem768) ->
@@ -1305,6 +1294,25 @@ groups(TLSGroups) when is_list(TLSGroups) ->
13051294
proplists:get_bool(maybe_group_to_curve(Group), CryptoGroups)
13061295
end, TLSGroups).
13071296

1297+
default_pqc_hybrid_groups() ->
1298+
[x25519mlkem768].
1299+
1300+
other_pqc_hybrid_groups()->
1301+
[secp384r1mlkem1024,
1302+
secp256r1mlkem768].
1303+
1304+
pqc_plain_groups() ->
1305+
[mlkem1024,
1306+
mlkem768,
1307+
mlkem512].
1308+
1309+
dhe_groups() ->
1310+
[ffdhe2048,
1311+
ffdhe3072,
1312+
ffdhe4096,
1313+
ffdhe6144,
1314+
ffdhe8192].
1315+
13081316
default_groups() ->
13091317
TLSGroups = groups(default),
13101318
groups(TLSGroups).

lib/ssl/test/ssl_api_SUITE.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,7 +2233,8 @@ customize_defaults(Opts, Role, Host) ->
22332233
end,
22342234
case proplists:get_value(protocol, Opts, tls) of
22352235
dtls ->
2236-
{ok, #config{ssl=DOpts}} = ssl_config:handle_options([{protocol, dtls}|NoVerify], Role, Host),
2236+
{ok, #config{ssl=DOpts}} =
2237+
ssl_config:handle_options([{protocol, dtls}|NoVerify], Role, Host),
22372238
{DOpts, DefOpts ++ Opts};
22382239
tls ->
22392240
{ok, #config{ssl=DOpts}} = ssl_config:handle_options(NoVerify, Role, Host),
@@ -2959,7 +2960,7 @@ options_fallback(_Config) ->
29592960
ok.
29602961

29612962
options_handshake(_Config) -> %% handshake
2962-
?OK(#{handshake := full, max_handshake_size := 131072},
2963+
?OK(#{handshake := full, max_handshake_size := 262144},
29632964
[], client),
29642965
?OK(#{handshake := hello, max_handshake_size := 123800},
29652966
[{handshake, hello}, {max_handshake_size, 123800}], client),

0 commit comments

Comments
 (0)