Skip to content

Commit fb32e5b

Browse files
committed
Add semi-stubbed-out SSL_{CTX_,}set_security_level
This cannot return errors, so just emit diagnostics.
1 parent 48eab19 commit fb32e5b

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

MATRIX.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
| `SSL_CTX_set_record_padding_callback_arg` | | | | |
179179
| `SSL_CTX_set_recv_max_early_data` | | | | |
180180
| `SSL_CTX_set_security_callback` | | | | |
181-
| `SSL_CTX_set_security_level` | | | | |
181+
| `SSL_CTX_set_security_level` | | | | :white_check_mark: |
182182
| `SSL_CTX_set_session_id_context` | | :white_check_mark: | :white_check_mark: | :white_check_mark: |
183183
| `SSL_CTX_set_session_ticket_cb` | | | | |
184184
| `SSL_CTX_set_srp_cb_arg` [^deprecatedin_3_0] [^srp] | | | | :exclamation: [^stub] |
@@ -459,7 +459,7 @@
459459
| `SSL_set_recv_max_early_data` | | | | |
460460
| `SSL_set_rfd` [^sock] | | | | |
461461
| `SSL_set_security_callback` | | | | |
462-
| `SSL_set_security_level` | | | | |
462+
| `SSL_set_security_level` | | | | :white_check_mark: |
463463
| `SSL_set_session` | :white_check_mark: | :white_check_mark: | :white_check_mark: | :exclamation: [^stub] |
464464
| `SSL_set_session_id_context` | | | | :exclamation: [^stub] |
465465
| `SSL_set_session_secret_cb` | | | | |

build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ const ENTRYPOINTS: &[&str] = &[
132132
"SSL_CTX_set_num_tickets",
133133
"SSL_CTX_set_options",
134134
"SSL_CTX_set_post_handshake_auth",
135+
"SSL_CTX_set_security_level",
135136
"SSL_CTX_set_session_id_context",
136137
"SSL_CTX_set_srp_cb_arg",
137138
"SSL_CTX_set_srp_password",
@@ -239,6 +240,7 @@ const ENTRYPOINTS: &[&str] = &[
239240
"SSL_set_options",
240241
"SSL_set_post_handshake_auth",
241242
"SSL_set_quiet_shutdown",
243+
"SSL_set_security_level",
242244
"SSL_set_session",
243245
"SSL_set_session_id_context",
244246
"SSL_set_shutdown",

src/entry.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,13 @@ entry! {
922922
pub type SSL_client_hello_cb_func =
923923
Option<unsafe extern "C" fn(_ssl: *mut SSL, _al: *mut c_int, _arg: *mut c_void) -> c_int>;
924924

925+
entry! {
926+
pub fn _SSL_CTX_set_security_level(ctx: *mut SSL_CTX, level: c_int) {
927+
let _null_check = try_clone_arc!(ctx);
928+
security_level_diagnostic(level)
929+
}
930+
}
931+
925932
impl Castable for SSL_CTX {
926933
type Ownership = OwnershipArc;
927934
type RustType = NotThreadSafe<Self>;
@@ -1136,6 +1143,27 @@ entry! {
11361143
}
11371144
}
11381145

1146+
entry! {
1147+
pub fn _SSL_set_security_level(ssl: *mut SSL, level: c_int) {
1148+
let _null_check = try_clone_arc!(ssl);
1149+
security_level_diagnostic(level)
1150+
}
1151+
}
1152+
1153+
fn security_level_diagnostic(level: c_int) {
1154+
match level {
1155+
// this is the rustls default
1156+
2 => {}
1157+
// all of these are possible with sufficient CryptoProvider plumbing. the signature verification
1158+
// facets would be the most complex to arrange.
1159+
3 => log::warn!("security level for 128-bit security requested but NYI"),
1160+
4 => log::warn!("security level for 192-bit security requested but NYI"),
1161+
5 => log::warn!("security level for 256-bit security requested but NYI"),
1162+
// others (lower, or negative, or huge are not reasonable)
1163+
_ => log::warn!("security level {level:?} not supported"),
1164+
}
1165+
}
1166+
11391167
entry! {
11401168
pub fn _SSL_set_connect_state(ssl: *mut SSL) {
11411169
try_clone_arc!(ssl).get_mut().set_client_mode()

0 commit comments

Comments
 (0)