Pure-Rust GOST cryptography, compatible with the RustCrypto ecosystem.
Algorithms
| Algorithm | Type | Feature |
|---|---|---|
| GOST 28147-89 | Block cipher (64-bit block, 256-bit key) | always |
| GOST R 34.11-94 | Hash (256-bit, CryptoPro / Test param sets) | always |
| CMAC / OMAC | MAC over GOST 28147-89 | mac |
| GOST R 34.11-2012 (Streebog) | Hash 256 / 512-bit | streebog |
Block cipher modes
[Gost28147] implements [cipher::BlockCipherEncrypt] + [cipher::BlockCipherDecrypt]
- [
cipher::KeyInit], so standard RustCrypto mode crates work out of the box:
# Cargo.toml
[]
= "0.2"
= "0.1"
= "0.8"
= "0.6"
use gost_crypto::Gost28147;
use cbc::Encryptor;
use cipher::{KeyIvInit, BlockEncryptMut, block_padding::Pkcs7};
let enc = Encryptor::<Gost28147>::new(&key.into(), &iv.into());
let ct = enc.encrypt_padded_vec_mut::<Pkcs7>(plaintext);
CMAC (feature mac)
= { = "0.2", = ["mac"] }
use gost_crypto::mac::Gost28147Mac;
use digest::Mac;
let mut mac = Gost28147Mac::new(&key.into());
mac.update(b"message");
let tag = mac.finalize().into_bytes();
Streebog (feature streebog)
= { = "0.2", = ["streebog"] }
use gost_crypto::streebog::{Streebog256, Streebog512};
use digest::Digest;
let hash = Streebog256::digest(b"hello");
Example
use ;
use Update;
let mut h = new_with_sbox;
update;
let result = h.finalize_bytes;
assert_eq!;