Crates.io | rs_shake256 |
lib.rs | rs_shake256 |
version | 0.1.2 |
source | src |
created_at | 2023-05-30 11:35:42.393806 |
updated_at | 2023-06-12 16:47:39.043641 |
description | `rs_shake256` is a Rust implementation of the SHAKE256 cryptographic hash algorithm, part of the larger `rs_shield` project. This package provides SHAKE256 hashing functionality in a standalone manner, ideal for when only SHAKE256 is required. Alternatively, for those seeking a comprehensive set of cryptographic functions, this same algorithm is included within the broader `rs_shield` library bundle. The focus of `rs_shake256` and the larger project is on performance, safety, and openness, with a commitment to ongoing maintenance and enhancement. |
homepage | https://docs.rs/rs_shield/latest/rs_shield/ |
repository | https://github.com/Azgrom/RustyShield |
max_upload_size | |
id | 877818 |
size | 36,063 |
rs_shake256
rs_shake256
is a Rust crate implementing the SHAKE256 Extendable-Output Function (XOF). This permutation-based function is designed for compatibility with Rust's libcore in a #![no_std]
context, allowing it to operate as a standalone crate for specialized use cases and also function within a #![no_std]
, #![no_alloc]
environment, rendering it suitable for systems where dynamic memory allocation is not feasible.
This implementation of SHAKE256 is compliant with the Federal Information Processing Standards (FIPS) Publication 2021. As per the National Institute of Standards and Technology (NIST) guidelines, SHAKE256 is recommended for various use cases:
"SHAKE128 and SHAKE256 are extendable-output functions (XOFs), which can output a hash of variable length, are approved for all applications using hash functions that can benefit from variable-length output."
Given this advice, NIST recommendations imply that SHAKE256 is suitable for the following contexts:
Beyond these specific recommendations, SHAKE256 could also find application in:
These points should be carefully considered, given your overall security objectives and risk tolerance.
For access to a comprehensive range of cryptographic functions, rs_shake256
can be utilized as part of the rs_shield
library bundle.
Below are steps to use the rs_shake256
crate in your Rust projects:
Add the following line to your Cargo.toml
under the [dependencies]
section:
rs_shake256 = "0.1.*"
Use the functions provided by the rs_shake256
module in your code. Here's an example of how to create a SHAKE256 hash from a string:
use rs_shake256::{HasherContext, Shake256Hasher};
let mut sha512_256hasher = Shake256Hasher::<20>::default();
sha512_256hasher.write(b"your string here");
let u64result = sha512_256hasher.finish();
let bytes_result = HasherContext::finish(&mut sha512_256hasher);
assert_eq!(u64result, 0x97E1C052B5574F11);
assert_eq!(format!("{bytes_result:02x}"), "97e1c052b5574f117b3fb13f26865fb4eec4a473");
assert_eq!(format!("{bytes_result:02X}"), "97E1C052B5574F117B3FB13F26865FB4EEC4A473");
assert_eq!(
bytes_result,
[
0x97, 0xE1, 0xC0, 0x52, 0xB5, 0x57, 0x4F, 0x11, 0x7B, 0x3F, 0xB1, 0x3F, 0x26, 0x86, 0x5F, 0xB4, 0xEE, 0xC4,
0xA4, 0x73
]
)
For a more detailed exploration of rs_shake256
, an overview of other available cryptographic functions, and an introduction to the broader rs_shield
project, please consult the RustyShield project page on crates.io.
Potential contributors are encouraged to consult the contribution guidelines on our GitHub page.
This project is licensed under GPL-2.0-only.
Note: The references have been provided as per the best knowledge as of May 17, 2023.
National Institute of Standards and Technology. (2015). SHA-3 Standard: Permutation-Based Hash and Extendable-Output Functions. FIPS PUB 202 ↩
Linus Torvalds. (2005). Git: A distributed version control system. Software: Practice and Experience, 41(1), 79-88. DOI:10.1002/spe.1006 ↩
Merkle, R. C. (1988). A Digital Signature Based on a Conventional Encryption Function. Link ↩
Krawczyk, H., Bellare, M., & Canetti, R. (1997). HMAC: Keyed-Hashing for Message Authentication. RFC 2104 ↩
National Institute of Standards and Technology. (2012). Recommendation for Key Derivation through Extraction-then-Expansion. SP 800-56C ↩