#keccak #sha-3 #hash #kangarootwelve #crypto

无std tiny-keccak

Keccak导出函数的实现

28个版本 (稳定)

2.0.2 2020年4月1日
2.0.1 2019年11月11日
1.5.0 2019年6月25日
1.4.2 2018年5月20日
0.3.0 2015年11月27日

#16 in 密码学

Download history 440292/week @ 2024-03-14 429217/week @ 2024-03-21 422217/week @ 2024-03-28 431319/week @ 2024-04-04 470005/week @ 2024-04-11 503511/week @ 2024-04-18 464737/week @ 2024-04-25 473264/week @ 2024-05-02 482488/week @ 2024-05-09 512272/week @ 2024-05-16 507794/week @ 2024-05-23 602103/week @ 2024-05-30 600496/week @ 2024-06-06 588297/week @ 2024-06-13 603589/week @ 2024-06-20 521052/week @ 2024-06-27

2,439,616 每月下载量
用于 3,509 个crate(283个直接使用)

CC0 许可

47KB
874

tiny-keccak

根据FIPS-202SP800-185KangarooTwelve指定的Keccak导出函数的实现。

Build Status

文档

Keccak-f[1600]排列完全展开;它的速度几乎与Keccak团队优化的排列一样快。

用法

在您的Cargo.toml中指定要使用哪些功能(哈希函数)。可用选项包括:cshakefips202k12keccakkmacparallel_hashsha3shakesp800tuple_hash

[dependencies]
tiny-keccak = { version = "2.0", features = ["sha3"] }

示例

use tiny_keccak::Sha3;

fn main() {
    let mut sha3 = Sha3::v256();
    let mut output = [0u8; 32];
    let expected = b"\
        \x64\x4b\xcc\x7e\x56\x43\x73\x04\x09\x99\xaa\xc8\x9e\x76\x22\xf3\
        \xca\x71\xfb\xa1\xd9\x72\xfd\x94\xa3\x1c\x3b\xfb\xf2\x4e\x39\x38\
    ";

    sha3.update(b"hello");
    sha3.update(b" ");
    sha3.update(b"world");
    sha3.finalize(&mut output);

    assert_eq!(expected, &output);
}

基准测试

rust-crypto的sha3基准测试

MacBook Pro (Retina, 15-inch, Mid 2015)
2,5 GHz Intel Core i7
16 GB 1600 MHz DDR3
Intel Iris Pro 1536 MB

基准测试代码在此处可用here

running 4 tests
test rust_crypto_sha3_256_input_32_bytes   ... bench:         677 ns/iter (+/- 113) = 47 MB/s
test rust_crypto_sha3_256_input_4096_bytes ... bench:      17,619 ns/iter (+/- 4,174) = 232 MB/s
test tiny_keccak_sha3_256_input_32_bytes   ... bench:         569 ns/iter (+/- 204) = 56 MB/s
test tiny_keccak_sha3_256_input_4096_bytes ... bench:      17,185 ns/iter (+/- 4,575) = 238 MB/s

依赖关系