Skip to content

Commit

Permalink
Expose curve details to rust bindings (#3912)
Browse files Browse the repository at this point in the history
  • Loading branch information
shraddha-1508 authored Mar 29, 2023
1 parent 36691b0 commit c87191f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions bindings/rust/s2n-tls-tokio/tests/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ async fn handshake_basic() -> Result<(), Box<dyn std::error::Error>> {
assert!(tls.as_ref().handshake_type()?.contains("NEGOTIATED"));
// Cipher suite may change, so just makes sure we can retrieve it.
assert!(tls.as_ref().cipher_suite().is_ok());
assert!(tls.as_ref().selected_curve().is_ok());
}

Ok(())
Expand Down
8 changes: 8 additions & 0 deletions bindings/rust/s2n-tls/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ impl fmt::Debug for Connection {
if let Ok(version) = self.actual_protocol_version() {
debug.field("actual_protocol_version", &version);
}
if let Ok(curve) = self.selected_curve() {
debug.field("selected_curve", &curve);
}
debug.finish_non_exhaustive()
}
}
Expand Down Expand Up @@ -667,6 +670,11 @@ impl Connection {
static_const_str!(cipher)
}

pub fn selected_curve(&self) -> Result<&str, Error> {
let curve = unsafe { s2n_connection_get_curve(self.connection.as_ptr()).into_result()? };
static_const_str!(curve)
}

pub fn selected_signature_algorithm(&self) -> Result<SignatureAlgorithm, Error> {
let mut sig_alg = s2n_tls_signature_algorithm::ANONYMOUS;
unsafe {
Expand Down

0 comments on commit c87191f

Please sign in to comment.