Enum hls_m3u8::types::InitializationVector [−][src]
Expand description
An initialization vector (IV) is a fixed size input that can be used along with a secret key for data encryption.
The use of an IV prevents repetition in encrypted data, making it more difficult for a hacker using a dictionary attack to find patterns and break a cipher. For example, a sequence might appear twice or more within the body of a message. If there are repeated sequences in encrypted data, an attacker could assume that the corresponding sequences in the message were also identical. The IV prevents the appearance of corresponding duplicate character sequences in the ciphertext.
Variants (Non-exhaustive)
This enum is marked as non-exhaustive
An IV for use with Aes128.
An ExtXKey
tag with KeyFormat::Identity
that does not have an IV
field indicates that the MediaSegment::number
is to be used as the
IV when decrypting a MediaSegment
.
Tuple Fields of Number
0: u128
Signals that an IV is missing.
Implementations
Returns the IV as an u128
. None
is returned for
InitializationVector::Missing
.
Example
assert_eq!( InitializationVector::Aes128([ 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12 ]) .to_u128(), Some(0x12345678901234567890123456789012) ); assert_eq!(InitializationVector::Number(0x10).to_u128(), Some(0x10)); assert_eq!(InitializationVector::Missing.to_u128(), None);
Returns the IV as a slice, which can be used to for example decrypt
a MediaSegment
. None
is returned for
InitializationVector::Missing
.
Example
assert_eq!( InitializationVector::Aes128([ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, ]) .to_slice(), Some([ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, ]) ); assert_eq!( InitializationVector::Number(0x12345678901234567890123456789012).to_slice(), Some([ 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12 ]) ); assert_eq!(InitializationVector::Missing.to_slice(), None);
Returns true
if the initialization vector is not missing.
Example
assert_eq!( InitializationVector::Aes128([ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, ]) .is_some(), true ); assert_eq!(InitializationVector::Number(4).is_some(), true); assert_eq!(InitializationVector::Missing.is_some(), false);
Returns true
if the initialization vector is missing.
Example
assert_eq!( InitializationVector::Aes128([ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, ]) .is_none(), false ); assert_eq!(InitializationVector::Number(4).is_none(), false); assert_eq!(InitializationVector::Missing.is_none(), true);
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for InitializationVector
impl Send for InitializationVector
impl Sync for InitializationVector
impl Unpin for InitializationVector
impl UnwindSafe for InitializationVector
Blanket Implementations
Mutably borrows from an owned value. Read more