Crate gost_modes[−][src]
This crate contains generic implementation of block cipher modes of operation defined in GOST R 34.13-2015.
CTR, CFB and OFB modes are implemented in terms of traits from the cipher
crate.
MAC function defined in the GOST is implemented in the cmac
crate.
Examples
use gost_modes::{GostCbc, GostPadding, BlockMode, consts::U2}; use kuznyechik::Kuznyechik; use hex_literal::hex; let key = hex!(" 8899aabbccddeeff0011223344556677 fedcba98765432100123456789abcdef "); let iv = hex!(" 1234567890abcef0a1b2c3d4e5f00112 23344556677889901213141516171819 "); let pt = b"my secret message"; type Cipher = GostCbc<Kuznyechik, GostPadding, U2>; let cipher = Cipher::new_from_slices(&key, &iv).unwrap(); let ct = cipher.encrypt_vec(pt); let cipher = Cipher::new_from_slices(&key, &iv).unwrap(); let buf = cipher.decrypt_vec(&ct).unwrap(); assert_eq!(buf, &pt[..]); // OFB mode example use gost_modes::{GostOfb, StreamCipher, NewCipher}; let mut cipher = GostOfb::<Kuznyechik, U2>::new_from_slices(&key, &iv).unwrap(); let mut buf = pt.to_vec(); cipher.apply_keystream(&mut buf); assert_eq!(buf, hex!("fddb196e81812e4174d1c9f741a3457a88"));
Re-exports
pub use block_modes; | |
pub use block_modes::block_padding; | |
pub use cipher; | |
pub use generic_array; |
Modules
consts | Type aliases for many constants. |
Structs
Ecb | Electronic Codebook (ECB) block cipher mode instance. |
GostCbc | Cipher Block Chaining (CBC) mode of operation as defined in GOST R 34.13-2015 |
GostCfb | Cipher feedback (CFB) mode of operation as defined in GOST R 34.13-2015 |
GostCtr64 | Counter (CTR) mode of operation for 64-bit block ciphers as defined in GOST R 34.13-2015 |
GostCtr128 | Counter (CTR) mode of operation for 128-bit block ciphers as defined in GOST R 34.13-2015 |
GostOfb | Output feedback (OFB) mode of operation as defined in GOST R 34.13-2015 |
Traits
AsyncStreamCipher | Asynchronous stream cipher core trait. |
BlockMode | Trait for a block cipher mode of operation that is used to apply a block cipher operation to input data to transform it into a variable-length output message. |
NewCipher | Cipher creation trait. |
StreamCipher | Synchronous stream cipher core trait. |
StreamCipherSeek | Trait for seekable stream ciphers. |
Type Definitions
GostPadding | Block padding procedure number 2 as defined in GOST R 34.13-2015 |