-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add export_keying_material support to pingora-s2n #744
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // Copyright 2025 Cloudflare, Inc. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| //! Extended functionalities for s2n-tls | ||
|
|
||
| use s2n_tls::connection::Connection; | ||
| use s2n_tls::error::Error; | ||
|
|
||
| /// Export keying material from a TLS connection | ||
| /// | ||
| /// Derives keying material for application use in accordance with RFC 5705. | ||
| /// | ||
| /// Note: Currently only available with TLS 1.3 connections. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As @varunravi98 pointed out, this will return an Error if invoked on a TLS 1.3 connection. It might be worth calling this out explicitly so that any consumers will know what behavior to expect (explicit error vs silently ignored). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file was already deleted and replaced by |
||
| /// | ||
| /// See [tls_exporter](https://docs.rs/s2n-tls/latest/s2n_tls/connection/struct.Connection.html#method.tls_exporter). | ||
| pub fn ssl_export_keying_material( | ||
| conn: &Connection, | ||
| out: &mut [u8], | ||
| label: &str, | ||
| context: Option<&[u8]>, | ||
| ) -> Result<(), Error> { | ||
| let context_bytes = context.unwrap_or(&[]); | ||
| conn.tls_exporter(label.as_bytes(), context_bytes, out) | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| mod tests { | ||
| use super::*; | ||
| use s2n_tls::config::Builder; | ||
| use s2n_tls::enums::Mode; | ||
|
|
||
| #[test] | ||
| fn test_ssl_export_keying_material_exists() { | ||
| // This test verifies that ssl_export_keying_material function exists | ||
| // and has the correct signature. Actual functional testing requires | ||
| // an established TLS connection. | ||
| let config = Builder::new().build().unwrap(); | ||
| let mut conn = s2n_tls::connection::Connection::new(Mode::Client); | ||
| conn.set_config(config).unwrap(); | ||
| let mut out = [0u8; 32]; | ||
|
|
||
| // This will fail since there's no established connection, but verifies | ||
| // the function signature is correct | ||
| let _ = ssl_export_keying_material(&conn, &mut out, "test", None); | ||
| } | ||
| } | ||
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.
Should this get updated to 2026 since it's likely going to get merged in 2026?
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.
I'll take care of this internally