pub struct MagmaStream {
pub core: Magma,
/* private fields */
}
Expand description
Magma stream ciphering operations
Fields§
§core: Magma
The core block-cipher
Implementations§
Source§impl MagmaStream
impl MagmaStream
Sourcepub fn new<T>(key: T, cipher_mode: CipherMode) -> Self
pub fn new<T>(key: T, cipher_mode: CipherMode) -> Self
Returns a new MagmaStream
initialized with given cipher key and cipher mode
Uses RFC7836 based substitution box
§Arguments
key
- array[u32;8]
or[u8;32]
cipher_mode
- a `CipherMode’ value
§Example
use cipher_magma::{MagmaStream, CipherMode};
let key: [u32;8] = [
0xffeeddcc, 0xbbaa9988, 0x77665544, 0x33221100, 0xf0f1f2f3, 0xf4f5f6f7, 0xf8f9fafb, 0xfcfdfeff
];
let magma = MagmaStream::new(key, CipherMode::CBC);
Or
use cipher_magma::{MagmaStream, CipherMode};
let key: [u8;32] = [
0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11,
0x00, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd,
0xfe, 0xff,
];
let magma = MagmaStream::new(key, CipherMode::CBC);
Sourcepub fn set_mode(&mut self, cipher_mode: CipherMode)
pub fn set_mode(&mut self, cipher_mode: CipherMode)
Sourcepub fn set_substitution_box(&mut self, substitution_box: &[u8; 128])
pub fn set_substitution_box(&mut self, substitution_box: &[u8; 128])
Sourcepub fn set_iv(&mut self, iv: &[u64])
pub fn set_iv(&mut self, iv: &[u64])
Sets the Initialization Vector (IV)
§Arguments
iv
- A slice to&[u64]
array
Attention: CTR
Mode uses only the MSB(32) part of IV
Sourcepub fn reset_context(&mut self)
pub fn reset_context(&mut self)
Resets the context of stream ciphering
Sourcepub fn reset_feedback(&mut self)
pub fn reset_feedback(&mut self)
Resets the feedback state of stream ciphering
Sourcepub fn get_mode(&self) -> CipherMode
pub fn get_mode(&self) -> CipherMode
Returns current CipherMode
Auto Trait Implementations§
impl Freeze for MagmaStream
impl RefUnwindSafe for MagmaStream
impl Send for MagmaStream
impl Sync for MagmaStream
impl Unpin for MagmaStream
impl UnwindSafe for MagmaStream
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