X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=fuzz%2Fsrc%2Fpeer_crypt.rs;h=de0443ebd5b2bd3eea3e4b117442620eae57f46d;hb=3b3a4ba0a6e60e90792bf78d2c5d9cd5c59a5ddb;hp=8e61644644ec4a474f3e6c76184c0cd7a7f36967;hpb=e28fd78e67b92de9f42dae3636c5dbea5e9b1f86;p=rust-lightning diff --git a/fuzz/src/peer_crypt.rs b/fuzz/src/peer_crypt.rs index 8e616446..de0443eb 100644 --- a/fuzz/src/peer_crypt.rs +++ b/fuzz/src/peer_crypt.rs @@ -1,6 +1,17 @@ +// This file is Copyright its original authors, visible in version control +// history. +// +// This file is licensed under the Apache License, Version 2.0 or the MIT license +// , at your option. +// You may not use this file except in accordance with one or both of these +// licenses. + use lightning::ln::peer_channel_encryptor::PeerChannelEncryptor; -use secp256k1::key::{PublicKey,SecretKey}; +use bitcoin::secp256k1::{Secp256k1, PublicKey, SecretKey}; + +use utils::test_logger; #[inline] fn slice_to_be16(v: &[u8]) -> u16 { @@ -24,6 +35,8 @@ pub fn do_test(data: &[u8]) { } } + let secp_ctx = Secp256k1::signing_only(); + let our_network_key = match SecretKey::from_slice(get_slice!(32)) { Ok(key) => key, Err(_) => return, @@ -39,16 +52,16 @@ pub fn do_test(data: &[u8]) { Err(_) => return, }; let mut crypter = PeerChannelEncryptor::new_outbound(their_pubkey, ephemeral_key); - crypter.get_act_one(); - match crypter.process_act_two(get_slice!(50), &our_network_key) { + crypter.get_act_one(&secp_ctx); + match crypter.process_act_two(get_slice!(50), &our_network_key, &secp_ctx) { Ok(_) => {}, Err(_) => return, } assert!(crypter.is_ready_for_encryption()); crypter } else { - let mut crypter = PeerChannelEncryptor::new_inbound(&our_network_key); - match crypter.process_act_one_with_keys(get_slice!(50), &our_network_key, ephemeral_key) { + let mut crypter = PeerChannelEncryptor::new_inbound(&our_network_key, &secp_ctx); + match crypter.process_act_one_with_keys(get_slice!(50), &our_network_key, ephemeral_key, &secp_ctx) { Ok(_) => {}, Err(_) => return, } @@ -75,15 +88,11 @@ pub fn do_test(data: &[u8]) { } } +pub fn peer_crypt_test(data: &[u8], _out: Out) { + do_test(data); +} + #[no_mangle] pub extern "C" fn peer_crypt_run(data: *const u8, datalen: usize) { do_test(unsafe { std::slice::from_raw_parts(data, datalen) }); } - -#[cfg(test)] -mod tests { - #[test] - fn duplicate_crash() { - super::do_test(&::hex::decode("01").unwrap()); - } -}