use secp256k1;
use crypto::digest::Digest;
-use crypto::sha2::Sha256;
use crypto::ripemd160::Ripemd160;
+use util::sha2::Sha256;
+
// Various functions for key derivation and transaction creation for use within channels. Primarily
// used in Channel and ChannelMonitor.
use crypto::digest::Digest;
use crypto::hkdf::{hkdf_extract,hkdf_expand};
-use crypto::sha2::Sha256;
use ln::msgs;
use ln::msgs::{HandleError, MsgEncodable};
use ln::chan_utils;
use chain::chaininterface::{FeeEstimator,ConfirmationTarget};
use util::{transaction_utils,rng};
+use util::sha2::Sha256;
use std::default::Default;
use std::cmp;
use ln::msgs;
use ln::msgs::{HandleError,ChannelMessageHandler,MsgEncodable,MsgDecodable};
use util::{byte_utils, events, internal_traits, rng};
+use util::sha2::Sha256;
use crypto::mac::{Mac,MacResult};
use crypto::hmac::Hmac;
use crypto::digest::Digest;
-use crypto::sha2::Sha256;
use crypto::symmetriccipher::SynchronousStreamCipher;
use crypto::chacha20::ChaCha20;
use bitcoin::util::hash::Sha256dHash;
use bitcoin::util::bip143;
-use crypto::sha2::Sha256;
use crypto::digest::Digest;
use secp256k1::{Secp256k1,Message,Signature};
use ln::chan_utils;
use ln::chan_utils::HTLCOutputInCommitment;
use chain::chaininterface::{ChainListener, ChainWatchInterface, BroadcasterInterface};
+use util::sha2::Sha256;
use std::collections::HashMap;
use std::sync::{Arc,Mutex};
use crypto::digest::Digest;
use crypto::hkdf::{hkdf_extract,hkdf_expand};
-use crypto::sha2::Sha256;
use crypto::aead::{AeadEncryptor, AeadDecryptor};
use util::chacha20poly1305rfc::ChaCha20Poly1305RFC;
use util::{byte_utils,rng};
+use util::sha2::Sha256;
// Sha256("Noise_XK_secp256k1_ChaChaPoly_SHA256")
const NOISE_CK: [u8; 32] = [0x26, 0x40, 0xf5, 0x2e, 0xeb, 0xcd, 0x9e, 0x88, 0x29, 0x58, 0x95, 0x1c, 0x79, 0x42, 0x50, 0xee, 0xdb, 0x28, 0x00, 0x2c, 0x05, 0xd7, 0xdc, 0x2e, 0xa0, 0xf1, 0x95, 0x40, 0x60, 0x42, 0xca, 0xf1];
pub(crate) mod chacha20poly1305rfc;
pub(crate) mod internal_traits;
pub(crate) mod rng;
+pub(crate) mod sha2;
#[cfg(test)]
pub(crate) mod test_utils;
--- /dev/null
+#[cfg(not(feature = "fuzztarget"))]
+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,
+ }
+
+ impl Sha256 {
+ pub fn new() -> Sha256 {
+ Sha256 {
+ state: sha2::Sha256::new(),
+ }
+ }
+ }
+
+ impl Digest for Sha256 {
+ fn result(&mut self, data: &mut [u8]) {
+ self.state.result(data);
+ 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() }
+ }
+}
+#[cfg(feature = "fuzztarget")]
+pub use self::fuzzy_sha::Sha256;