Skip to content

Commit eddfec5

Browse files
authored
Merge pull request #28 from TheBlueMatt/master
fuzztarget sha -> XOR, crates secp256k1
2 parents 1d1ebbb + f462d8a commit eddfec5

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fuzztarget = ["secp256k1/fuzztarget", "bitcoin/fuzztarget"]
1919
bitcoin = "0.13"
2020
rust-crypto = "0.2"
2121
rand = "0.4"
22-
secp256k1 = { git = "https://github.com/rust-bitcoin/rust-secp256k1", branch = "master" }
22+
secp256k1 = "0.9"
2323

2424
[build-dependencies]
2525
gcc = "0.3"

fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ honggfuzz_fuzz = ["honggfuzz"]
1818
[dependencies]
1919
lightning = { path = "..", features = ["fuzztarget"] }
2020
bitcoin = { version = "0.13", features = ["fuzztarget"] }
21-
secp256k1 = { git = "https://github.com/rust-bitcoin/rust-secp256k1", branch = "master" , features=["fuzztarget"]}
21+
secp256k1 = { version = "0.9", features=["fuzztarget"] }
2222
rust-crypto = "0.2"
2323
honggfuzz = { version = "0.5", optional = true }
2424
afl = { version = "0.3", optional = true }

src/util/sha2.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,31 @@ pub use crypto::sha2::Sha256;
44
#[cfg(feature = "fuzztarget")]
55
mod fuzzy_sha {
66
use crypto::digest::Digest;
7-
use crypto::sha2;
87

9-
#[derive(Clone, Copy)]
108
pub struct Sha256 {
11-
state: sha2::Sha256,
9+
state: u8,
1210
}
1311

1412
impl Sha256 {
1513
pub fn new() -> Sha256 {
1614
Sha256 {
17-
state: sha2::Sha256::new(),
15+
state: 0,
1816
}
1917
}
2018
}
2119

2220
impl Digest for Sha256 {
2321
fn result(&mut self, data: &mut [u8]) {
24-
self.state.result(data);
22+
data[0] = self.state;
2523
for i in 1..32 {
2624
data[i] = 0;
2725
}
2826
}
2927

30-
fn input(&mut self, data: &[u8]) { self.state.input(data); }
31-
fn reset(&mut self) { self.state.reset(); }
32-
fn output_bits(&self) -> usize { self.state.output_bits() }
33-
fn block_size(&self) -> usize { self.state.block_size() }
28+
fn input(&mut self, data: &[u8]) { for i in data { self.state ^= i; } }
29+
fn reset(&mut self) { self.state = 0; }
30+
fn output_bits(&self) -> usize { 256 }
31+
fn block_size(&self) -> usize { 64 }
3432
}
3533
}
3634
#[cfg(feature = "fuzztarget")]

0 commit comments

Comments
 (0)