Expand description
§RustyShield: Advanced Cryptographic Library for Modern Applications
This library provides comprehensive cryptographic functions inspired by OpenSSL, within the Rust ecosystem. The vision behind RustyShield is to establish a solid foundation within the Rust language by seamlessly integrating with its core library. As a result, RustyShield furnishes a reliable, user-friendly, standards-compliant, and platform-agnostic suite of encryption tools.
§Usage
This create delivers its functionality via an API that seamlessly integrates with Rust’s core library. By adhering
to the Hash, Hasher, and BuildHasher design pattern from Rust’s core library design pattern from Rust’s core library, the API enables users to
effortlessly employ any algorithm, provided they possess a basic understanding of these traits.
§Examples
The following example demonstrate how to use some of the functionalities provided by RustyShield.
Although only the SHA-1 example is demonstrated, this pattern for extracting an u64, or [u8; N], or a String
will be consistent with all implementations below.
§SHA-1
let mut sha1hasher = Sha1State::default().build_hasher();
sha1hasher.write(b"hello");
let u64result = sha1hasher.finish();
let bytes_result = HasherContext::finish(&mut sha1hasher);
assert_eq!(u64result, 0xAAF4C61DDCC5E8A2);
assert_eq!(
bytes_result,
[
0xAA, 0xF4, 0xC6, 0x1D, 0xDC, 0xC5, 0xE8, 0xA2, 0xDA, 0xBE,
0xDE, 0x0F, 0x3B, 0x48, 0x2C, 0xD9, 0xAE, 0xA9, 0x43, 0x4D
]
);
assert_eq!(format!("{bytes_result:02x}"), "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d")For examples on a specific algorithm click on it below:
§Current algorithms
| Ciphers | Hashing Functions | Public-key |
|---|---|---|
AES - coming soon | SHA-1 - rs_sha1 | RSA - coming soon |
Blowfish - coming soon | SHA-224 - rs_sha224 | DSA - coming soon |
Camellia - coming soon | SHA-256 - rs_sha256 | Diffie-Hellman key exchange - coming soon |
Chacha20 - coming soon | SHA-384 - rs_sha384 | Elliptic curve - coming soon |
Poly1305 - coming soon | SHA-512 - rs_sha512 | X25519 - coming soon |
SEED - coming soon | SHA-512/224 - rs_sha512_224 | Ed25519 - coming soon |
CAST-128 - coming soon | SHA-512/256 - rs_sha512_256 | X448 - coming soon |
DES - coming soon | SHA3-224 - rs_sha3_224 | Ed448 - coming soon |
IDEA - coming soon | SHA3-256 - rs_sha3_256 | GOST R 34.10-2001 - coming soon |
RC2 - coming soon | SHA3-384 - rs_sha3_384 | SM2 - coming soon |
RC4 - coming soon | SHA3-512 - rs_sha3_512 | |
RC5 - coming soon | SHAKE128 - rs_shake128 | |
Triple DES - coming soon | SHAKE256 - rs_shake256 | |
GOST 28147-89 - coming soon | HMAC - rs_hmac | |
SM4 - coming soon | Generic Keccak {200, 400, 800, 1600} - rs_keccak_nbits | |
BLAKE2 - coming soon | ||
GOST R 34.11-94 - coming soon | ||
MD2 - coming soon | ||
MD4 - coming soon | ||
MD5 - coming soon | ||
MDC-2 - coming soon | ||
RIPEMD-160 - coming soon | ||
SM3 - coming soon | ||
Whirlpool - coming soon |
§On Hash Trait and Trailing Byte
The Rust Hash trait includes a mechanism to guard against prefix collision attacks that appends a
trailing byte 0xFF if to the data fed is of type &str and is passed through the hash function.
This behavior can have implications when using the Hash trait for data processing. If you pass data to the hash
function through the Hash trait, it will include this additional 0xFF byte at the end. While this does not
affect the general usage of the hash function, it does modify the input data.
Therefore, if you need to get a hash of exact input data (without a trailing 0xFF), you should not use the Hash
trait. Instead, directly use the provided hashing algorithm API.
It’s worth noting that this 0xFF trailing byte is not a part of the original algorithm specification, but a part
of the Rust Hash trait’s design to prevent prefix collision attacks. Thus, when comparing hash values generated
from this library with values generated by different implementations, ensure the input data includes the 0xFF
trailing byte or pass the input data as a byte slice to the Hasher::write() on this API.
Structs§
- Hmac
Hmac<H: Default + HashAlgorithm, const OUTPUT_SIZE: usize>is a generic struct that provides the HMAC (Hash-based Message Authentication Code) in Rust.- NBit
Keccak Hasher NBitKeccakHasheris a type that provides the Keccak-nBits hashing algorithm in RustyShield.- NBit
Keccak State NBitKeccakStaterepresents the state of a Keccak-nBits hashing process.- Sha1
Hasher Sha1Hasheris a type that provides the SHA-1 hashing algorithm in RustyShield.- Sha1
State Sha1Staterepresents the state of a SHA-1 hashing process.- Sha3_
224Hasher Sha3_224Hasheris a type that provides the SHA3-224 hashing algorithm in Rust.- Sha3_
224State Sha3_224Staterepresents the state of a SHA3-224 hashing process.- Sha3_
256Hasher Sha3_256Hasheris a type that implements the SHA3-256 hashing algorithm in Rust.- Sha3_
256State Sha3_256Stateembodies the state of a SHA3-256 hashing operation.- Sha3_
384Hasher Sha3_384Hasheris a type that provides the SHA3-384 hashing algorithm in Rust.- Sha3_
384State Sha3_384Staterepresents the state of a SHA3-384 hashing process.- Sha3_
512Hasher Sha3_512Hasheris a type that provides the SHA3-512 hashing algorithm in Rust.- Sha3_
512State Sha3_512Staterepresents the state of a SHA3-512 hashing process.- Sha224
Hasher Sha224Hasheris a type that provides the SHA-224 hashing algorithm in RustyShield.- Sha224
State Sha224Staterepresents the state of a SHA-1 hashing process.- Sha256
Hasher Sha256Hasheris a type in RustyShield that facilitates the SHA-256 hashing algorithm.- Sha256
State Sha256Statesignifies the state of a SHA-256 hashing operation.- Sha384
Hasher Sha384Hasheris a type that provides the SHA-384 hashing algorithm in RustyShield.- Sha384
State Sha384Staterepresents the state of a SHA-384 hashing process.- Sha512
Hasher Sha512Hasheris a type that provides the SHA-512 hashing algorithm in RustyShield.- Sha512
State Sha512Staterepresents the state of a SHA-512 hashing process.- Sha512_
224Hasher Sha512_224Hasheris a type that provides the SHA-512/224 hashing algorithm in RustyShield.- Sha512_
224State Sha512_224Staterepresents the state of a SHA-512/224 hashing process.- Sha512_
256Hasher Sha512_256Hasheris a type that provides the SHA-512/256 hashing algorithm in RustyShield.- Sha512_
256State Sha512_256Staterepresents the state of a SHA-512/256 hashing process.- Shake128
Hasher Shake128Hasheris a type that provides the SHAKE128 hashing algorithm in Rust.- Shake128
State Shake128Staterepresents the state of a SHAKE128 hashing process.- Shake256
Hasher Shake256Hasheris a type that provides the SHAKE256 hashing algorithm in Rust.- Shake256
State Shake256Staterepresents the state of a SHAKE256 hashing process.
Traits§
- Hasher
Context - Overloads the finish Hasher method for a version that mutates itself