Skip to content

Commit

Permalink
Implement SSL_SESSION_set1_id_context
Browse files Browse the repository at this point in the history
  • Loading branch information
ctz committed May 2, 2024
1 parent d9067b4 commit 2667517
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rustls-libssl/MATRIX.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
| `SSL_SESSION_set1_alpn_selected` | | | |
| `SSL_SESSION_set1_hostname` | | | |
| `SSL_SESSION_set1_id` | | | |
| `SSL_SESSION_set1_id_context` | | | |
| `SSL_SESSION_set1_id_context` | | | :white_check_mark: |
| `SSL_SESSION_set1_master_key` | | | |
| `SSL_SESSION_set1_ticket_appdata` | | | |
| `SSL_SESSION_set_cipher` | | | |
Expand Down
1 change: 1 addition & 0 deletions rustls-libssl/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const ENTRYPOINTS: &[&str] = &[
"SSL_SESSION_get_time",
"SSL_SESSION_get_timeout",
"SSL_session_reused",
"SSL_SESSION_set1_id_context",
"SSL_SESSION_set_time",
"SSL_SESSION_set_timeout",
"SSL_SESSION_up_ref",
Expand Down
12 changes: 12 additions & 0 deletions rustls-libssl/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1579,6 +1579,18 @@ entry! {
}
}

entry! {
pub fn _SSL_SESSION_set1_id_context(
sess: *mut SSL_SESSION,
sid_ctx: *const c_uchar,
sid_ctx_len: c_uint,
) -> c_int {
let slice = try_slice!(sid_ctx, sid_ctx_len);
try_clone_arc!(sess).get_mut().set_context(slice);
C_INT_SUCCESS
}
}

entry! {
pub fn _d2i_SSL_SESSION(
a: *mut *mut SSL_SESSION,
Expand Down
4 changes: 4 additions & 0 deletions rustls-libssl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,10 @@ impl SslSession {
self.time_out = time_out_secs;
}

pub fn set_context(&mut self, new_context: &[u8]) {
self.context = new_context.to_vec();
}

pub fn expired(&self, at_time: cache::TimeBase) -> bool {
cache::ExpiryTime::calculate(self.creation_time, self.time_out).in_past(at_time)
}
Expand Down
1 change: 1 addition & 0 deletions rustls-libssl/tests/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ static int sess_new_callback(SSL *ssl, SSL_SESSION *sess) {
SSL_SESSION_get_id(sess, &id_len);
printf(" SSL_SESSION_get_id len=%u\n", id_len);
TRACE(SSL_SESSION_set_timeout(sess, SSL_SESSION_get_timeout(sess)));
TRACE(SSL_SESSION_set1_id_context(sess, (uint8_t *)"hello", 5));
return 0;
}

Expand Down

0 comments on commit 2667517

Please sign in to comment.