1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! 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:
//!
//! ```toml
//! # Cargo.toml
//! [dependencies]
//! gost-crypto = "0.2"
//! cbc = "0.1"
//! cfb-mode = "0.8"
//! ofb = "0.6"
//! ```
//!
//! ```ignore
//! 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`)
//!
//! ```toml
//! gost-crypto = { version = "0.2", features = ["mac"] }
//! ```
//!
//! ```ignore
//! 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`)
//!
//! ```toml
//! gost-crypto = { version = "0.2", features = ["streebog"] }
//! ```
//!
//! ```ignore
//! use gost_crypto::streebog::{Streebog256, Streebog512};
//! use digest::Digest;
//! let hash = Streebog256::digest(b"hello");
//! ```
//!
//! # Example
//! ```rust
//! 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);
//! ```
pub
pub
pub
pub use Gost28147;
pub use Gost341194;
pub use ;
/// CMAC/OMAC MAC over GOST 28147-89.
///
/// Enabled with feature `mac`.
/// GOST R 34.11-2012 (Streebog) hash, 256-bit and 512-bit variants.
///
/// Enabled with feature `streebog`. Re-exports the `streebog` crate.
pub use streebog;
/// GOST R 34.12-2015 Kuznyechik (Grasshopper) block cipher, 128-bit block, 256-bit key.
///
/// Enabled with feature `kuznyechik`. Re-exports the `kuznyechik` crate.
/// Implements `cipher::BlockCipherEncrypt + BlockCipherDecrypt + KeyInit`.
pub use kuznyechik;
/// HMAC over Streebog-256 and Streebog-512 (RFC 7836 §A.1).
///
/// Enabled with feature `hmac-streebog`.