Skip to content

Commit 204771c

Browse files
committed
ssl: Make PQC groups most preferred
1 parent 8e99e81 commit 204771c

3 files changed

Lines changed: 37 additions & 39 deletions

File tree

lib/ssl/src/ssl.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,7 @@ The following options are specific to the client side, or have
13921392
different semantics for the client and server:
13931393

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

lib/ssl/src/ssl_config.erl

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

14701470
opt_psk_groups(undefined, _, _, _) ->
14711471
undefined;
1472-
opt_psk_groups(#supported_groups{supported_groups = SupportedGroups}, UserOpts, Opts, _Env) ->
1472+
opt_psk_groups(#supported_groups{supported_groups = [First| _] = SupportedGroups},
1473+
UserOpts, Opts, _Env) ->
14731474
%% Version dependency already asserted when SupportedGroups is supported
1474-
%% so is psk_groups
1475-
First = hd(SupportedGroups),
1475+
%% hence so is psk_groups
14761476
case get_opt_list(psk_groups, [First], UserOpts, Opts) of
14771477
{default, Default} ->
14781478
Default;

lib/ssl/src/tls_v1.erl

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
rsa_schemes/0,
6969
groups/0,
7070
groups/1,
71+
pqc_groups/0,
7172
group_to_enum/1,
7273
enum_to_group/1,
7374
default_groups/0,
@@ -1251,48 +1252,38 @@ ecc_curves(Version) when is_tuple(Version) ->
12511252
ecc_curves(TLSCurves);
12521253
ecc_curves(TLSCurves) ->
12531254
[pubkey_cert_records:namedCurves(Curve) || Curve <- TLSCurves].
1254-
1255+
12551256
groups() ->
12561257
TLSGroups = groups(all),
12571258
groups(TLSGroups).
12581259

12591260
-spec groups(all | default | TLSGroups :: list()) -> [ssl:group()].
12601261
groups(all) ->
1261-
[x25519,
1262-
x448,
1263-
secp521r1,
1264-
secp384r1,
1265-
secp256r1,
1266-
brainpoolP256r1tls13,
1267-
brainpoolP384r1tls13,
1268-
brainpoolP512r1tls13,
1269-
mlkem512,
1270-
mlkem768,
1271-
mlkem1024,
1272-
x25519mlkem768,
1273-
secp384r1mlkem1024,
1274-
secp256r1mlkem768,
1275-
ffdhe2048,
1276-
ffdhe3072,
1277-
ffdhe4096,
1278-
ffdhe6144,
1279-
ffdhe8192];
1262+
pqc_groups() ++
1263+
[x25519,
1264+
x448,
1265+
secp521r1,
1266+
secp384r1,
1267+
secp256r1,
1268+
brainpoolP256r1tls13,
1269+
brainpoolP384r1tls13,
1270+
brainpoolP512r1tls13,
1271+
ffdhe2048,
1272+
ffdhe3072,
1273+
ffdhe4096,
1274+
ffdhe6144,
1275+
ffdhe8192];
12801276
groups(default) ->
1281-
[x25519,
1282-
x448,
1283-
secp521r1,
1284-
secp384r1,
1285-
secp256r1,
1286-
brainpoolP512r1tls13,
1287-
brainpoolP384r1tls13,
1288-
brainpoolP256r1tls13,
1289-
mlkem512,
1290-
mlkem768,
1291-
mlkem1024,
1292-
x25519mlkem768,
1293-
secp384r1mlkem1024,
1294-
secp256r1mlkem768
1295-
];
1277+
pqc_groups() ++
1278+
[x25519,
1279+
x448,
1280+
secp521r1,
1281+
secp384r1,
1282+
secp256r1,
1283+
brainpoolP512r1tls13,
1284+
brainpoolP384r1tls13,
1285+
brainpoolP256r1tls13
1286+
];
12961287
groups(TLSGroups) when is_list(TLSGroups) ->
12971288
CryptoGroups = crypto_supported_groups(),
12981289
lists:filter(fun(x25519mlkem768) ->
@@ -1307,6 +1298,13 @@ groups(TLSGroups) when is_list(TLSGroups) ->
13071298
(Group) ->
13081299
proplists:get_bool(maybe_group_to_curve(Group), CryptoGroups)
13091300
end, TLSGroups).
1301+
pqc_groups() ->
1302+
[x25519mlkem768,
1303+
mlkem1024,
1304+
mlkem768,
1305+
mlkem512,
1306+
secp384r1mlkem1024,
1307+
secp256r1mlkem768].
13101308

13111309
default_groups() ->
13121310
TLSGroups = groups(default),

0 commit comments

Comments
 (0)