11 unstable releases (3 breaking)
0.6.1 | Nov 2, 2021 |
---|---|
0.6.0 | Nov 1, 2021 |
0.5.0 | Aug 27, 2021 |
0.4.5 | Aug 22, 2021 |
0.2.1 | Jul 20, 2021 |
#2060 in Cryptography
61 downloads per month
Used in 6 crates
(3 directly)
8KB
126 lines
Rust-HMAC-SHA
A pure Rust implementation of the Hash-based Message Authentication Code Algoritm for SHA-{1,2,3}. This project can be seen as an interface/wrapper for the RustCrypto crate,
focusing on user/developer ease of use.
Works in a #![no_std]
environment.
Origins and motivations
This repo is a fork of Rust-HMAC-SHA1 by @pantsman0/Philip Woolford. Unlike the original version, it supports SHA-2 and SHA-3 in addition to SHA-1. In addition this fork uses the implementations of SHA provided by RustCrypto. Has been developed to assist in the development of OOTP.
Usage
To import rust-hmac-sha
add the following to your Cargo.toml:
[dependencies]
hmac-sha = "0.6"
and any other Hash crate that statisfy the Digest
trait, like sha3
[dependencies]
...
sha3 = { version = "0.9", default-features = false }
You can use rust-hmac-sha
in this way:
use hex;
use hmacsha::HmacSha;
use sha3::Sha3_256;
fn main() {
let secret_key = "A very strong secret";
let message = "My secret message";
let mut hasher = HmacSha::from(secret_key, message, Sha3_256::default());
let result = hasher.compute_digest();
println!("{}", hex::encode(result));
}
Contributions
Any contributions are welcome. This was implemented as a learning experience and any advice is appreciated.
License
This crate is licensed under the MIT or Apache licenses, as is its dependancies of the RustCrypto family. The original crate was licensed under the BSD 3-Clause license, as the old dependency sha1
Dependencies
~1MB
~21K SLoC