-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
endpoint: use a consistent quic reset key derived from our private key
- Loading branch information
Showing
3 changed files
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -278,6 +278,14 @@ impl EndpointConfigBuilder { | |
public_key: None, | ||
}; | ||
|
||
// Derive our quic reset key from our private key | ||
let reset_key = { | ||
let mut rng = <rand::rngs::StdRng as rand::SeedableRng>::from_seed(keypair.secret_key); | ||
let mut reset_key = [0; 64]; | ||
rand::RngCore::fill_bytes(&mut rng, &mut reset_key); | ||
reset_key | ||
}; | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bmwill
Author
Owner
|
||
let server_name = self.server_name.unwrap(); | ||
let transport_config = Arc::new(self.transport_config.unwrap_or_default()); | ||
|
||
|
@@ -307,6 +315,7 @@ impl EndpointConfigBuilder { | |
quinn_client_config: client_config, | ||
server_name, | ||
transport_config, | ||
reset_key, | ||
}) | ||
} | ||
|
||
|
@@ -368,6 +377,7 @@ pub(crate) struct EndpointConfig { | |
server_name: String, | ||
|
||
transport_config: Arc<quinn::TransportConfig>, | ||
reset_key: [u8; 64], | ||
} | ||
|
||
impl EndpointConfig { | ||
|
@@ -383,6 +393,13 @@ impl EndpointConfig { | |
&self.server_name | ||
} | ||
|
||
pub fn quinn_endpoint_config(&self) -> quinn::EndpointConfig { | ||
quinn::EndpointConfig::new(Arc::new(ring::hmac::Key::new( | ||
ring::hmac::HMAC_SHA256, | ||
&self.reset_key, | ||
))) | ||
} | ||
|
||
pub fn server_config(&self) -> &quinn::ServerConfig { | ||
&self.quinn_server_config | ||
} | ||
|
This file contains 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 may not be cryptographically safe. Consider using an audited HKDF, as done e.g. in https://www.rfc-editor.org/rfc/rfc9001.html#initial-secrets.