Skip to content

Commit 9201a4f

Browse files
committed
Refactored: Moved TLSGroups to new branch feature/named_group
1 parent d3e0e76 commit 9201a4f

File tree

6 files changed

+6
-190
lines changed

6 files changed

+6
-190
lines changed

.github/workflows/libssl.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ jobs:
261261
make package-${{ matrix.package }} PROFILE=release
262262
263263
- name: Archive package
264-
uses: actions/upload-artifact@v4
264+
uses: actions/upload-artifact@v5
265265
with:
266266
name: ${{ matrix.package }} package built on ${{ matrix.container }} ${{ matrix.version }}
267267
path: target/dist/*.${{ matrix.package }}

MATRIX.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@
384384
| `SSL_get_version` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
385385
| `SSL_get_wbio` | | :white_check_mark: | :white_check_mark: | :white_check_mark: |
386386
| `SSL_get_wfd` | | | | |
387-
| `SSL_group_to_name` | | | | :white_check_mark: |
387+
| `SSL_group_to_name` | | | | |
388388
| `SSL_has_matching_session_id` | | | | |
389389
| `SSL_has_pending` | | | | :white_check_mark: |
390390
| `SSL_in_before` | | | | :white_check_mark: |

build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ const ENTRYPOINTS: &[&str] = &[
193193
"SSL_get_verify_result",
194194
"SSL_get_version",
195195
"SSL_get_wbio",
196-
"SSL_group_to_name",
197196
"SSL_has_pending",
198197
"SSL_in_before",
199198
"SSL_in_init",

src/constants.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,21 +123,17 @@ pub fn sig_scheme_to_type_nid(scheme: SignatureScheme) -> Option<c_int> {
123123
pub fn named_group_to_nid(group: NamedGroup) -> Option<c_int> {
124124
use NamedGroup::*;
125125

126-
// See TLSEXT_nid_unknown from tls1.h - openssl-sys does not
127-
// have a constant for this to import.
128-
const TLSEXT_NID_UNKNOWN: c_int = 0x1000000;
129126
// See NID_ffhdhe* from obj_mac.h - openssl-sys does not have
130127
// constants for these to import.
131128
const NID_FFDHE2048: c_int = 1126;
132129
const NID_FFDHE3072: c_int = 1127;
133130
const NID_FFDHE4096: c_int = 1128;
134131
const NID_FFDHE6144: c_int = 1129;
135132
const NID_FFDHE8192: c_int = 1130;
136-
// See NID_ML_KEM_* from obj_mac.h - openssl-sys does not have
137-
// constants for these to import.
138-
const NID_ML_KEM_512: c_int = 1454;
139-
const NID_ML_KEM_768: c_int = 1455;
140-
const NID_ML_KEM_1024: c_int = 1456;
133+
134+
// See TLSEXT_nid_unknown from tls1.h - openssl-sys does not
135+
// have a constant for this to import.
136+
const TLSEXT_NID_UNKNOWN: c_int = 0x1000000;
141137

142138
match group {
143139
secp256r1 => Some(NID_X9_62_prime256v1),
@@ -150,9 +146,6 @@ pub fn named_group_to_nid(group: NamedGroup) -> Option<c_int> {
150146
FFDHE4096 => Some(NID_FFDHE4096),
151147
FFDHE6144 => Some(NID_FFDHE6144),
152148
FFDHE8192 => Some(NID_FFDHE8192),
153-
MLKEM512 => Some(NID_ML_KEM_512),
154-
MLKEM768 => Some(NID_ML_KEM_768),
155-
MLKEM1024 => Some(NID_ML_KEM_1024),
156149
other => Some(TLSEXT_NID_UNKNOWN | u16::from(other) as c_int),
157150
}
158151
}

src/entry.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,20 +1475,6 @@ entry! {
14751475
}
14761476
}
14771477

1478-
entry! {
1479-
pub fn _SSL_group_to_name(ssl: *const SSL, id: c_int) -> *const c_char {
1480-
try_clone_arc!(ssl)
1481-
.get()
1482-
.get_groups()
1483-
.iter()
1484-
.find(|group| named_group_to_nid(group.name()) == Some(id))
1485-
.map(|group| group.name())
1486-
.and_then(crate::TlsGroupInfo::find_by_id)
1487-
.map(|group| group.tls_name.as_ptr())
1488-
.unwrap_or_else(ptr::null)
1489-
}
1490-
}
1491-
14921478
entry! {
14931479
pub fn _SSL_version(ssl: *const SSL) -> c_int {
14941480
try_clone_arc!(ssl)

src/lib.rs

Lines changed: 0 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -242,158 +242,6 @@ static TLS13_CHACHA20_POLY1305_SHA256: SslCipher = SslCipher {
242242
rustls: CipherSuite::TLS13_CHACHA20_POLY1305_SHA256,
243243
};
244244

245-
#[allow(dead_code)]
246-
struct TlsGroupInfo {
247-
pub tls_name: &'static CStr,
248-
pub standard_name: &'static CStr,
249-
pub algorithm: &'static CStr,
250-
pub secbits: usize,
251-
pub group_id: NamedGroup,
252-
}
253-
254-
impl TlsGroupInfo {
255-
pub fn find_by_id(id: NamedGroup) -> Option<&'static Self> {
256-
match id {
257-
NamedGroup::secp256r1 => Some(&SECP256R1),
258-
NamedGroup::secp384r1 => Some(&SECP384R1),
259-
NamedGroup::secp521r1 => Some(&SECP521R1),
260-
NamedGroup::X25519 => Some(&X25519),
261-
NamedGroup::X448 => Some(&X448),
262-
NamedGroup::FFDHE2048 => Some(&FFDHE2048),
263-
NamedGroup::FFDHE3072 => Some(&FFDHE3072),
264-
NamedGroup::FFDHE4096 => Some(&FFDHE4096),
265-
NamedGroup::FFDHE6144 => Some(&FFDHE6144),
266-
NamedGroup::FFDHE8192 => Some(&FFDHE8192),
267-
NamedGroup::MLKEM512 => Some(&MLKEM512),
268-
NamedGroup::MLKEM768 => Some(&MLKEM768),
269-
NamedGroup::MLKEM1024 => Some(&MLKEM1024),
270-
NamedGroup::X25519MLKEM768 => Some(&X25519MLKEM768),
271-
NamedGroup::secp256r1MLKEM768 => Some(&SECP256R1_MLKEM768),
272-
_ => None,
273-
}
274-
}
275-
}
276-
277-
static SECP256R1: TlsGroupInfo = TlsGroupInfo {
278-
tls_name: c"secp256r1",
279-
standard_name: c"prime256v1",
280-
algorithm: c"EC",
281-
secbits: 128,
282-
group_id: NamedGroup::secp256r1,
283-
};
284-
285-
static SECP384R1: TlsGroupInfo = TlsGroupInfo {
286-
tls_name: c"secp384r1",
287-
standard_name: c"secp384r1",
288-
algorithm: c"EC",
289-
secbits: 192,
290-
group_id: NamedGroup::secp384r1,
291-
};
292-
293-
static SECP521R1: TlsGroupInfo = TlsGroupInfo {
294-
tls_name: c"secp521r1",
295-
standard_name: c"secp521r1",
296-
algorithm: c"EC",
297-
secbits: 256,
298-
group_id: NamedGroup::secp521r1,
299-
};
300-
301-
static X25519: TlsGroupInfo = TlsGroupInfo {
302-
tls_name: c"x25519",
303-
standard_name: c"X25519",
304-
algorithm: c"X25519",
305-
secbits: 128,
306-
group_id: NamedGroup::X25519,
307-
};
308-
309-
static X448: TlsGroupInfo = TlsGroupInfo {
310-
tls_name: c"x448",
311-
standard_name: c"X448",
312-
algorithm: c"X448",
313-
secbits: 224,
314-
group_id: NamedGroup::X448,
315-
};
316-
317-
static FFDHE2048: TlsGroupInfo = TlsGroupInfo {
318-
tls_name: c"ffdhe2048",
319-
standard_name: c"ffdhe2048",
320-
algorithm: c"DH",
321-
secbits: 112,
322-
group_id: NamedGroup::FFDHE2048,
323-
};
324-
325-
static FFDHE3072: TlsGroupInfo = TlsGroupInfo {
326-
tls_name: c"ffdhe3072",
327-
standard_name: c"ffdhe3072",
328-
algorithm: c"DH",
329-
secbits: 128,
330-
group_id: NamedGroup::FFDHE3072,
331-
};
332-
333-
static FFDHE4096: TlsGroupInfo = TlsGroupInfo {
334-
tls_name: c"ffdhe4096",
335-
standard_name: c"ffdhe4096",
336-
algorithm: c"DH",
337-
secbits: 128,
338-
group_id: NamedGroup::FFDHE4096,
339-
};
340-
341-
static FFDHE6144: TlsGroupInfo = TlsGroupInfo {
342-
tls_name: c"ffdhe6144",
343-
standard_name: c"ffdhe6144",
344-
algorithm: c"DH",
345-
secbits: 128,
346-
group_id: NamedGroup::FFDHE6144,
347-
};
348-
349-
static FFDHE8192: TlsGroupInfo = TlsGroupInfo {
350-
tls_name: c"ffdhe8192",
351-
standard_name: c"ffdhe8192",
352-
algorithm: c"DH",
353-
secbits: 192,
354-
group_id: NamedGroup::FFDHE8192,
355-
};
356-
357-
static MLKEM512: TlsGroupInfo = TlsGroupInfo {
358-
tls_name: c"MLKEM512",
359-
standard_name: c"",
360-
algorithm: c"ML-KEM-512",
361-
secbits: 128,
362-
group_id: NamedGroup::MLKEM512,
363-
};
364-
365-
static MLKEM768: TlsGroupInfo = TlsGroupInfo {
366-
tls_name: c"MLKEM768",
367-
standard_name: c"",
368-
algorithm: c"ML-KEM-768",
369-
secbits: 192,
370-
group_id: NamedGroup::MLKEM768,
371-
};
372-
373-
static MLKEM1024: TlsGroupInfo = TlsGroupInfo {
374-
tls_name: c"MLKEM1024",
375-
standard_name: c"",
376-
algorithm: c"ML-KEM-1024",
377-
secbits: 256,
378-
group_id: NamedGroup::MLKEM1024,
379-
};
380-
381-
static X25519MLKEM768: TlsGroupInfo = TlsGroupInfo {
382-
tls_name: c"X25519MLKEM768",
383-
standard_name: c"",
384-
algorithm: c"X25519MLKEM768",
385-
secbits: 192,
386-
group_id: NamedGroup::X25519MLKEM768,
387-
};
388-
389-
static SECP256R1_MLKEM768: TlsGroupInfo = TlsGroupInfo {
390-
tls_name: c"SecP256r1MLKEM768",
391-
standard_name: c"",
392-
algorithm: c"SecP256r1MLKEM768",
393-
secbits: 192,
394-
group_id: NamedGroup::secp256r1MLKEM768,
395-
};
396-
397245
/// Backs a server-side SSL_SESSION object
398246
///
399247
/// Note that this has equality and ordering entirely based on the `id` field.
@@ -614,7 +462,6 @@ pub struct SslContext {
614462
info_callback: callbacks::InfoCallbackConfig,
615463
client_hello_callback: callbacks::ClientHelloCallbackConfig,
616464
auth_keys: sign::CertifiedKeySet,
617-
groups: Vec<&'static dyn SupportedKxGroup>,
618465
max_early_data: u32,
619466
}
620467

@@ -647,7 +494,6 @@ impl SslContext {
647494
info_callback: callbacks::InfoCallbackConfig::default(),
648495
client_hello_callback: callbacks::ClientHelloCallbackConfig::default(),
649496
auth_keys: sign::CertifiedKeySet::default(),
650-
groups: provider::default_provider().kx_groups.clone(),
651497
max_early_data: 0,
652498
}
653499
}
@@ -678,10 +524,6 @@ impl SslContext {
678524
self.raw_options
679525
}
680526

681-
fn get_groups(&self) -> &Vec<&'static dyn SupportedKxGroup> {
682-
&self.groups
683-
}
684-
685527
fn get_num_tickets(&self) -> usize {
686528
self.num_tickets
687529
}
@@ -1041,10 +883,6 @@ impl Ssl {
1041883
self.raw_options
1042884
}
1043885

1044-
fn get_groups(&self) -> &Vec<&'static dyn SupportedKxGroup> {
1045-
self.ctx.get().get_groups()
1046-
}
1047-
1048886
fn get_num_tickets(&self) -> usize {
1049887
self.num_tickets
1050888
}

0 commit comments

Comments
 (0)