pub struct KeyMethodV2 {
pub pre_master: [u8; 48],
pub random1: [u8; 32],
pub random2: [u8; 32],
pub options: String,
pub username: Option<String>,
pub password: Option<String>,
pub peer_info: Option<String>,
}Expand description
Key method v2 data (exchanged during TLS handshake)
Fields§
§pre_master: [u8; 48]Pre-master secret (48 bytes)
random1: [u8; 32]Random data 1 (32 bytes) - used as EKM context and PRF seed
random2: [u8; 32]Random data 2 (32 bytes) - used as additional PRF seed
options: StringOptions string
username: Option<String>Username (if using auth)
password: Option<String>Password (if using auth)
peer_info: Option<String>Peer info
Implementations§
Source§impl KeyMethodV2
impl KeyMethodV2
Sourcepub fn parse(data: &[u8]) -> Result<Self>
pub fn parse(data: &[u8]) -> Result<Self>
Parse key method v2 data from bytes (received from TLS plaintext)
Format (OpenVPN key_source + metadata):
- 4 bytes: literal 0
- 1 byte: key method (must be 2)
- 48 bytes: pre-master secret
- 32 bytes: random1
- 32 bytes: random2
- 2 bytes + N bytes: options string (length-prefixed, null-terminated)
- 2 bytes + N bytes: username (length-prefixed, optional)
- 2 bytes + N bytes: password (length-prefixed, optional)
- 2 bytes + N bytes: peer_info (length-prefixed, optional)
Sourcepub fn encode(&self, is_server: bool) -> Vec<u8> ⓘ
pub fn encode(&self, is_server: bool) -> Vec<u8> ⓘ
Encode to bytes (OpenVPN key_method_v2 wire format)
When is_server is true (server writing its response), pre_master is
NOT included in the key source material – only random1 and random2.
When is_server is false (client writing), pre_master IS included.
This matches the OpenVPN key_source2_randomize_write asymmetry.
Trait Implementations§
Source§impl Clone for KeyMethodV2
impl Clone for KeyMethodV2
Source§fn clone(&self) -> KeyMethodV2
fn clone(&self) -> KeyMethodV2
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for KeyMethodV2
impl RefUnwindSafe for KeyMethodV2
impl Send for KeyMethodV2
impl Sync for KeyMethodV2
impl Unpin for KeyMethodV2
impl UnwindSafe for KeyMethodV2
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more