From: Matt Corallo <649246+TheBlueMatt@users.noreply.github.com> Date: Tue, 5 Jun 2018 00:42:30 +0000 (-0400) Subject: Merge pull request #28 from TheBlueMatt/master X-Git-Tag: v0.0.12~405 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=eddfec5aa563c442872402130d20ceaa945ab9df;hp=1d1ebbb290a26b666f76aa9ca1c8ce922346dcb0;p=rust-lightning Merge pull request #28 from TheBlueMatt/master fuzztarget sha -> XOR, crates secp256k1 --- diff --git a/Cargo.toml b/Cargo.toml index 3b692790..e8570e25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ fuzztarget = ["secp256k1/fuzztarget", "bitcoin/fuzztarget"] bitcoin = "0.13" rust-crypto = "0.2" rand = "0.4" -secp256k1 = { git = "https://github.com/rust-bitcoin/rust-secp256k1", branch = "master" } +secp256k1 = "0.9" [build-dependencies] gcc = "0.3" diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 521e93d3..bcaa2932 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -18,7 +18,7 @@ honggfuzz_fuzz = ["honggfuzz"] [dependencies] lightning = { path = "..", features = ["fuzztarget"] } bitcoin = { version = "0.13", features = ["fuzztarget"] } -secp256k1 = { git = "https://github.com/rust-bitcoin/rust-secp256k1", branch = "master" , features=["fuzztarget"]} +secp256k1 = { version = "0.9", features=["fuzztarget"] } rust-crypto = "0.2" honggfuzz = { version = "0.5", optional = true } afl = { version = "0.3", optional = true } diff --git a/src/util/sha2.rs b/src/util/sha2.rs index 31616f50..2c9eab93 100644 --- a/src/util/sha2.rs +++ b/src/util/sha2.rs @@ -4,33 +4,31 @@ pub use crypto::sha2::Sha256; #[cfg(feature = "fuzztarget")] mod fuzzy_sha { use crypto::digest::Digest; - use crypto::sha2; - #[derive(Clone, Copy)] pub struct Sha256 { - state: sha2::Sha256, + state: u8, } impl Sha256 { pub fn new() -> Sha256 { Sha256 { - state: sha2::Sha256::new(), + state: 0, } } } impl Digest for Sha256 { fn result(&mut self, data: &mut [u8]) { - self.state.result(data); + data[0] = self.state; for i in 1..32 { data[i] = 0; } } - fn input(&mut self, data: &[u8]) { self.state.input(data); } - fn reset(&mut self) { self.state.reset(); } - fn output_bits(&self) -> usize { self.state.output_bits() } - fn block_size(&self) -> usize { self.state.block_size() } + fn input(&mut self, data: &[u8]) { for i in data { self.state ^= i; } } + fn reset(&mut self) { self.state = 0; } + fn output_bits(&self) -> usize { 256 } + fn block_size(&self) -> usize { 64 } } } #[cfg(feature = "fuzztarget")]