Expand description
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 standardRustCryptomode crates work out of the box:
# Cargo.toml
[dependencies]
gost-crypto = "0.2"
cbc = "0.1"
cfb-mode = "0.8"
ofb = "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)
gost-crypto = { version = "0.2", features = ["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)
gost-crypto = { version = "0.2", features = ["streebog"] }ⓘ
use gost_crypto::streebog::{Streebog256, Streebog512};
use digest::Digest;
let hash = Streebog256::digest(b"hello");§Example
use gost_crypto::{Gost341194, SBOX_CRYPTOPRO};
use digest::Update;
let mut h = Gost341194::new_with_sbox(&SBOX_CRYPTOPRO);
Update::update(&mut h, b"hello");
let result = h.finalize_bytes();
assert_eq!(result.len(), 32);Structs§
- Gost28147
- GOST 28147-89 block cipher.
- Gost341194
- GOST R 34.11-94 hash function.
Constants§
- SBOX_
CRYPTOPRO - S-box for id-GostR3411-94-CryptoProParamSet (RFC 4357 §11.2).
Used by
КриптоПроCSP for GOST R 34.11-94 hashing. - SBOX_
TEST - S-box for id-GostR3411-94-TestParamSet (RFC 5831 test vectors).
Type Aliases§
- Sbox
- S-box type: 8 rows × 16 columns.