Skip to content

Commit b36078b

Browse files
committed
docs: add C / s2n-tls-sys doc references to s2n-tls docs
1 parent 306ec84 commit b36078b

File tree

12 files changed

+297
-21
lines changed

12 files changed

+297
-21
lines changed

bindings/rust/extended/s2n-tls/src/callbacks/pkey.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub enum OperationType {
1717
Sign(SignatureAlgorithm, HashAlgorithm),
1818
}
1919

20+
/// Corresponds to [s2n_async_pkey_op].
2021
pub struct PrivateKeyOperation {
2122
raw: NonNull<s2n_async_pkey_op>,
2223
kind: OperationType,
@@ -66,11 +67,15 @@ impl PrivateKeyOperation {
6667
}
6768

6869
/// Do we need to sign or decrypt with the private key?
70+
///
71+
/// Corresponds to [s2n_async_pkey_op_get_op_type].
6972
pub fn kind(&self) -> Result<&OperationType, Error> {
7073
Ok(&self.kind)
7174
}
7275

7376
/// The size of the slice returned by [`input()`]
77+
///
78+
/// Corresponds to [s2n_async_pkey_op_get_input_size].
7479
pub fn input_size(&self) -> Result<usize, Error> {
7580
let mut size = 0;
7681
unsafe { s2n_async_pkey_op_get_input_size(self.as_ptr(), &mut size) }.into_result()?;
@@ -81,6 +86,8 @@ impl PrivateKeyOperation {
8186
///
8287
/// If this is an [`OperationType::Sign`] operation, then this input has
8388
/// already been hashed and is the resultant digest.
89+
///
90+
/// Corresponds to [s2n_async_pkey_op_get_input].
8491
pub fn input(&self, buf: &mut [u8]) -> Result<(), Error> {
8592
let buf_len: u32 = buf.len().try_into().map_err(|_| Error::INVALID_INPUT)?;
8693
let buf_ptr = buf.as_ptr() as *mut u8;
@@ -89,6 +96,9 @@ impl PrivateKeyOperation {
8996
}
9097

9198
/// Sets the output of the operation
99+
///
100+
/// Corresponds to [s2n_async_pkey_op_set_output],
101+
/// but also automatically calls [s2n_async_pkey_op_apply].
92102
pub fn set_output(self, conn: &mut Connection, buf: &[u8]) -> Result<(), Error> {
93103
let buf_len: u32 = buf.len().try_into().map_err(|_| Error::INVALID_INPUT)?;
94104
let buf_ptr = buf.as_ptr();
@@ -105,6 +115,7 @@ impl PrivateKeyOperation {
105115
}
106116

107117
impl Drop for PrivateKeyOperation {
118+
/// Corresponds to [s2n_async_pkey_op_free].
108119
fn drop(&mut self) {
109120
unsafe {
110121
let _ = s2n_async_pkey_op_free(self.raw.as_ptr());

bindings/rust/extended/s2n-tls/src/callbacks/session_ticket.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ impl SessionTicket {
3131
&self.0 as *const s2n_session_ticket as *mut s2n_session_ticket
3232
}
3333

34+
/// Corresponds to [s2n_session_ticket_get_lifetime].
3435
pub fn lifetime(&self) -> Result<Duration, Error> {
3536
let mut lifetime = 0;
3637
unsafe {
@@ -39,6 +40,7 @@ impl SessionTicket {
3940
Ok(Duration::new(lifetime.into(), 0))
4041
}
4142

43+
/// Corresponds to [s2n_session_ticket_get_data_len].
4244
#[allow(clippy::len_without_is_empty)]
4345
pub fn len(&self) -> Result<usize, Error> {
4446
let mut data_len = 0;
@@ -48,6 +50,7 @@ impl SessionTicket {
4850
Ok(data_len)
4951
}
5052

53+
/// Corresponds to [s2n_session_ticket_get_data].
5154
pub fn data(&self, output: &mut [u8]) -> Result<(), Error> {
5255
unsafe {
5356
s2n_session_ticket_get_data(self.deref_mut_ptr(), output.len(), output.as_mut_ptr())

bindings/rust/extended/s2n-tls/src/cert_chain.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ impl CertificateChainHandle {
4141
}
4242

4343
impl Drop for CertificateChainHandle {
44+
/// Corresponds to [s2n_cert_chain_and_key_free].
4445
fn drop(&mut self) {
4546
// ignore failures since there's not much we can do about it
4647
if self.is_owned {
@@ -140,6 +141,8 @@ pub struct CertificateChain<'a> {
140141

141142
impl CertificateChain<'_> {
142143
/// This allocates a new certificate chain from s2n.
144+
///
145+
/// Corresponds to [s2n_cert_chain_and_key_new].
143146
pub(crate) fn allocate_owned() -> Result<CertificateChain<'static>, Error> {
144147
crate::init::init();
145148
unsafe {
@@ -178,6 +181,8 @@ impl CertificateChain<'_> {
178181
///
179182
/// Note that the underyling API currently traverses a linked list, so this is a relatively
180183
/// expensive API to call.
184+
///
185+
/// Corresponds to [s2n_cert_chain_get_length].
181186
pub fn len(&self) -> usize {
182187
let mut length: u32 = 0;
183188
let res = unsafe { s2n_cert_chain_get_length(self.as_ptr(), &mut length).into_result() };
@@ -219,6 +224,7 @@ pub struct CertificateChainIter<'a> {
219224
impl<'a> Iterator for CertificateChainIter<'a> {
220225
type Item = Result<Certificate<'a>, Error>;
221226

227+
/// Corresponds to [s2n_cert_chain_get_cert].
222228
fn next(&mut self) -> Option<Self::Item> {
223229
let idx = self.idx;
224230
// u32 fits into usize on platforms we support.
@@ -253,6 +259,7 @@ pub struct Certificate<'a> {
253259
}
254260

255261
impl Certificate<'_> {
262+
/// Corresponds to [s2n_cert_get_der].
256263
pub fn der(&self) -> Result<&[u8], Error> {
257264
unsafe {
258265
let mut buffer = ptr::null();

bindings/rust/extended/s2n-tls/src/client_hello.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use std::fmt;
2222
pub struct ClientHello(s2n_client_hello);
2323

2424
impl ClientHello {
25+
/// Corresponds to [s2n_client_hello_parse_message].
2526
pub fn parse_client_hello(hello: &[u8]) -> Result<Box<Self>, crate::error::Error> {
2627
crate::init::init();
2728
let handle = unsafe {
@@ -56,6 +57,8 @@ impl ClientHello {
5657
&self.0 as *const s2n_client_hello as *mut s2n_client_hello
5758
}
5859

60+
/// Corresponds to [s2n_client_hello_get_session_id], but also
61+
/// calls [s2n_client_hello_get_session_id_length].
5962
pub fn session_id(&self) -> Result<Vec<u8>, Error> {
6063
let mut session_id_length = 0;
6164
unsafe {
@@ -77,6 +80,8 @@ impl ClientHello {
7780
Ok(session_id)
7881
}
7982

83+
/// Corresponds to [s2n_client_hello_get_server_name], but also
84+
/// calls [s2n_client_hello_get_server_name_length].
8085
pub fn server_name(&self) -> Result<Vec<u8>, Error> {
8186
let mut server_name_length = 0;
8287
unsafe {
@@ -98,6 +103,8 @@ impl ClientHello {
98103
Ok(server_name)
99104
}
100105

106+
/// Corresponds to [s2n_client_hello_get_raw_message], but also
107+
/// calls [s2n_client_hello_get_raw_message_length].
101108
pub fn raw_message(&self) -> Result<Vec<u8>, Error> {
102109
let message_length =
103110
unsafe { s2n_client_hello_get_raw_message_length(self.deref_mut_ptr()).into_result()? };
@@ -116,6 +123,7 @@ impl ClientHello {
116123
}
117124

118125
impl Drop for ClientHello {
126+
/// Corresponds to [s2n_client_hello_free].
119127
fn drop(&mut self) {
120128
let mut client_hello: *mut s2n_client_hello = &mut self.0;
121129
// ignore failures. There isn't anything to be done to handle them, but

0 commit comments

Comments
 (0)