Skip to content

Commit a667dd9

Browse files
authored
skein: fix implementation for output sizes not multiple of 8 (#682)
1 parent 62b6ff1 commit a667dd9

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

skein/CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## 0.1.0 (2023-06-09)
8+
## 0.1.1 (2025-04-23)
9+
### Fixed
10+
- Implementation for output sizes not multiple of 8 ([#682])
11+
12+
[#682]: https://github.com/RustCrypto/hashes/pull/682
13+
14+
## 0.1.0 (2023-06-09) [YANKED]
915
- Initial release ([#483])
1016

1117
[#483]: https://github.com/RustCrypto/hashes/pull/483

skein/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "skein"
3-
version = "0.1.0"
3+
version = "0.1.1"
44
description = "Skein hash functions"
55
authors = ["RustCrypto Developers"]
66
license = "MIT OR Apache-2.0"

skein/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ macro_rules! define_hasher {
156156
block[..8].copy_from_slice(&(i as u64).to_le_bytes());
157157
Self::process_block(&mut ctr, &block, 8);
158158

159-
for (src, dst) in ctr.x.iter().zip(chunk.chunks_exact_mut(8)) {
160-
dst.copy_from_slice(&src.to_le_bytes());
159+
for (src, dst) in ctr.x.iter().zip(chunk.chunks_mut(8)) {
160+
dst.copy_from_slice(&src.to_le_bytes()[..dst.len()]);
161161
}
162162
}
163163
}

skein/tests/lib.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
use hex_literal::hex;
12
use skein::{
2-
consts::{U128, U32, U64},
3+
consts::{U128, U32, U64, U7},
34
digest::{dev::fixed_test, new_test},
4-
Skein1024, Skein256, Skein512,
5+
Digest, Skein1024, Skein256, Skein512,
56
};
67

78
new_test!(skein256_32, "skein256_32", Skein256<U32>, fixed_test);
@@ -11,3 +12,15 @@ new_test!(skein512_64, "skein512_64", Skein512<U64>, fixed_test);
1112
new_test!(skein1024_32, "skein1024_32", Skein1024<U32>, fixed_test);
1213
new_test!(skein1024_64, "skein1024_64", Skein1024<U64>, fixed_test);
1314
new_test!(skein1024_128, "skein1024_128", Skein1024<U128>, fixed_test);
15+
16+
/// Regression tests for https://github.com/RustCrypto/hashes/issues/681
17+
#[test]
18+
fn skein_uncommon_sizes() {
19+
let s = "hello world";
20+
let h = Skein256::<U7>::digest(s);
21+
assert_eq!(h[..], hex!("31bffb70f5dafe")[..]);
22+
let h = Skein512::<U7>::digest(s);
23+
assert_eq!(h[..], hex!("ee6004efedd69c")[..]);
24+
let h = Skein1024::<U7>::digest(s);
25+
assert_eq!(h[..], hex!("a2808b638681c6")[..]);
26+
}

0 commit comments

Comments
 (0)