Skip to content

Commit d3e0e76

Browse files
committed
Added: TLSGroupInfo
Added: New Entrypoint to build Added: New NIDs Added: Provider can be changed
1 parent 912fa3d commit d3e0e76

File tree

6 files changed

+207
-21
lines changed

6 files changed

+207
-21
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "rustls-libssl"
33
version = "0.2.1"
44
edition = "2021"
55
build = "build.rs"
6-
rust-version = "1.77"
6+
rust-version = "1.88"
77

88
[lib]
99
name = "ssl"

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` | | | | |
387+
| `SSL_group_to_name` | | | | :white_check_mark: |
388388
| `SSL_has_matching_session_id` | | | | |
389389
| `SSL_has_pending` | | | | :white_check_mark: |
390390
| `SSL_in_before` | | | | :white_check_mark: |

build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ const ENTRYPOINTS: &[&str] = &[
193193
"SSL_get_verify_result",
194194
"SSL_get_version",
195195
"SSL_get_wbio",
196+
"SSL_group_to_name",
196197
"SSL_has_pending",
197198
"SSL_in_before",
198199
"SSL_in_init",

src/constants.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,17 +123,21 @@ 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;
126129
// See NID_ffhdhe* from obj_mac.h - openssl-sys does not have
127130
// constants for these to import.
128131
const NID_FFDHE2048: c_int = 1126;
129132
const NID_FFDHE3072: c_int = 1127;
130133
const NID_FFDHE4096: c_int = 1128;
131134
const NID_FFDHE6144: c_int = 1129;
132135
const NID_FFDHE8192: c_int = 1130;
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;
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;
137141

138142
match group {
139143
secp256r1 => Some(NID_X9_62_prime256v1),
@@ -146,6 +150,9 @@ pub fn named_group_to_nid(group: NamedGroup) -> Option<c_int> {
146150
FFDHE4096 => Some(NID_FFDHE4096),
147151
FFDHE6144 => Some(NID_FFDHE6144),
148152
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),
149156
other => Some(TLSEXT_NID_UNKNOWN | u16::from(other) as c_int),
150157
}
151158
}

src/entry.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,20 @@ 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+
14781492
entry! {
14791493
pub fn _SSL_version(ssl: *const SSL) -> c_int {
14801494
try_clone_arc!(ssl)

0 commit comments

Comments
 (0)