-
Notifications
You must be signed in to change notification settings - Fork 146
Add set_ticket_key_callback (SSL_CTX_set_tlsext_ticket_key_cb) #330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kornelski
merged 11 commits into
cloudflare:master
from
toidiu:toidiu/ticket_key_callback
Oct 1, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
0e50646
Add set_ticket_key_callback (SSL_CTX_set_tlsext_ticket_key_cb)
toidiu 5285680
pr comments: safety, receive multiple nst, return status refactor
toidiu 776c8ae
add test case for TicketKeyCallbackResult::Noop
toidiu 2e0565d
update documentation
toidiu 6a1b303
simplify tests
toidiu cdeeae6
clippy
toidiu 91c95bb
initialize key_name and iv. mark fn as _unsafe to allow for future ch…
toidiu e395c52
Use MaybeUninit for raw_ticket_key key/iv
kornelski 8c3bca2
Expose a safe Rust interface for the session resumption callback
toidiu 93270a6
Use Ref foreign type instead of forgetting
kornelski 20f91cb
Convert CipherCtx fns into a safe abstraction. Additional testing.
toidiu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| use crate::cvt; | ||
| use crate::error::ErrorStack; | ||
| use crate::foreign_types::ForeignTypeRef; | ||
| use crate::hash::MessageDigest; | ||
|
|
||
| foreign_type_and_impl_send_sync! { | ||
| type CType = ffi::HMAC_CTX; | ||
| fn drop = ffi::HMAC_CTX_free; | ||
|
|
||
| pub struct HmacCtx; | ||
| } | ||
|
|
||
| impl HmacCtxRef { | ||
| /// Configures HmacCtx to use `md` as the hash function and `key` as the key. | ||
| /// | ||
| /// https://commondatastorage.googleapis.com/chromium-boringssl-docs/hmac.h.html#HMAC_Init_ex | ||
| pub fn init(&mut self, key: &[u8], md: &MessageDigest) -> Result<(), ErrorStack> { | ||
| ffi::init(); | ||
|
|
||
| unsafe { | ||
| cvt(ffi::HMAC_Init_ex( | ||
| self.as_ptr(), | ||
| key.as_ptr().cast(), | ||
| key.len(), | ||
| md.as_ptr(), | ||
| // ENGINE api is deprecated | ||
| core::ptr::null_mut(), | ||
| )) | ||
| .map(|_| ()) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirming my understanding: panic on
assertseems appropriate because otherwise we have UB.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
References must never be null, so they can't be made from a null pointer.
This assert isn't strictly necessary as long as the function is always given non-null pointers.
I thought it's better to be extra careful about this, I don't feel strongly about this choice. It could have been a
Result(assuming null is a real possibility), or downgraded todebug_assertif we trust that we'll never get a null pointer in these functions.