Skip to content

Commit b3521e5

Browse files
committed
Add SslRef::curve_name()
1 parent 4ce1308 commit b3521e5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

boring/src/ssl/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2780,6 +2780,22 @@ impl SslRef {
27802780
Some(curve_id)
27812781
}
27822782

2783+
/// Returns the curve name used for this `SslRef`.
2784+
#[corresponds(SSL_get_curve_name)]
2785+
#[must_use]
2786+
pub fn curve_name(&self) -> Option<&'static str> {
2787+
let curve_id = self.curve()?;
2788+
2789+
unsafe {
2790+
let ptr = ffi::SSL_get_curve_name(curve_id);
2791+
if ptr.is_null() {
2792+
return None;
2793+
}
2794+
2795+
CStr::from_ptr(ptr).to_str().ok()
2796+
}
2797+
}
2798+
27832799
/// Returns an `ErrorCode` value for the most recent operation on this `SslRef`.
27842800
#[corresponds(SSL_get_error)]
27852801
#[must_use]

boring/src/ssl/test/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -958,6 +958,8 @@ fn get_curve() {
958958
let client_stream = client.connect();
959959
let curve = client_stream.ssl().curve();
960960
assert!(curve.is_some());
961+
let curve_name = client_stream.ssl().curve_name();
962+
assert!(curve_name.is_some());
961963
}
962964

963965
#[test]

0 commit comments

Comments
 (0)