pub struct Encryption {
pub key_size: KeySize,
pub passphrase: Option<Passphrase>,
pub km_refresh: KeyMaterialRefresh,
}
Fields§
§key_size: KeySize
SRTO_PBKEYLEN
Encryption key length.
Possible values:
0 = PBKEYLEN (default value) 16 = AES-128 (effective value) 24 = AES-192 32 = AES-256
The use is slightly different in 1.2.0 (HSv4), and since 1.3.0 (HSv5):
HSv4: This is set on the sender and enables encryption, if not 0. The receiver shall not set it and will agree on the length as defined by the sender.
HSv5: The “default value” for PBKEYLEN is 0, which means that the PBKEYLEN won’t be advertised. The “effective value” for PBKEYLEN is 16, but this applies only when neither party has set the value explicitly (i.e. when both are initially at the default value of 0). If any party has set an explicit value (16, 24, 32) it will be advertised in the handshake. If the other party remains at the default 0, it will accept the peer’s value. The situation where both parties set a value should be treated carefully. Actually there are three intended methods of defining it, and all other uses are considered undefined behavior:
Unidirectional: the sender shall set PBKEYLEN and the receiver shall not alter the default value 0. The effective PBKEYLEN will be the one set on the sender. The receiver need not know the sender’s PBKEYLEN, just the passphrase, PBKEYLEN will be correctly passed.
Bidirectional in Caller-Listener arrangement: it is recommended to use a rule whereby you will be setting the PBKEYLEN exclusively either on the Listener or on the Caller. The value set on the Listener will win, if set on both parties.
Bidirectional in Rendezvous arrangement: you have to know the passphrases for both parties, as well as PBKEYLEN. Set PBKEYLEN to the same value on both parties (or leave the default value on both parties, which will result in 16)
Unwanted behavior cases: if both parties set PBKEYLEN and the value on both sides is different, the effective PBKEYLEN will be the one that is set on the Responder party, which may also override the PBKEYLEN 32 set by the sender to value 16 if such value was used by the receiver. The Responder party is the Listener in a Caller-Listener arrangement. In Rendezvous it’s a matter of luck which party becomes the Responder.
passphrase: Option<Passphrase>
SRTO_PASSPHRASE Sets the passphrase for encryption. This enables encryption on this party (or disables it, if an empty passphrase is passed). The password must be minimum 10 and maximum 79 characters long.
The passphrase is the shared secret between the sender and the receiver. It is used to generate the Key Encrypting Key using PBKDF2 (Password-Based Key Derivation Function 2).
When a socket with configured passphrase is being connected, the peer must have the same password set, or the connection is rejected. This behavior can be changed by SRTO_ENFORCEDENCRYPTION.
Note that since the introduction of bidirectional support, there’s only one initial encryption key to encrypt the stream (new keys after refreshing will be updated independently), and there’s no distinction between “service party that defines the password” and “client party that is required to set matching password” - both parties are equivalent, and in order to have a working encrypted connection, they have to simply set the same passphrase.
km_refresh: KeyMaterialRefresh
Trait Implementations§
Source§impl Clone for Encryption
impl Clone for Encryption
Source§fn clone(&self) -> Encryption
fn clone(&self) -> Encryption
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Encryption
impl Debug for Encryption
Source§impl Default for Encryption
impl Default for Encryption
Source§fn default() -> Encryption
fn default() -> Encryption
Source§impl OptionsOf<Encryption> for CallerOptions
impl OptionsOf<Encryption> for CallerOptions
fn set_options(&mut self, value: Encryption)
Source§impl OptionsOf<Encryption> for ListenerOptions
impl OptionsOf<Encryption> for ListenerOptions
fn set_options(&mut self, value: Encryption)
Source§impl OptionsOf<Encryption> for RendezvousOptions
impl OptionsOf<Encryption> for RendezvousOptions
fn set_options(&mut self, value: Encryption)
Source§impl OptionsOf<Encryption> for SocketOptions
impl OptionsOf<Encryption> for SocketOptions
fn set_options(&mut self, value: Encryption)
Source§impl PartialEq for Encryption
impl PartialEq for Encryption
Source§impl Validation for Encryption
impl Validation for Encryption
impl Eq for Encryption
impl StructuralPartialEq for Encryption
Auto Trait Implementations§
impl Freeze for Encryption
impl RefUnwindSafe for Encryption
impl Send for Encryption
impl Sync for Encryption
impl Unpin for Encryption
impl UnwindSafe for Encryption
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.