Skip to content

Commit 0d1cab6

Browse files
committed
Merge rust-bitcoin#2644: Add HKDF to bitcoin_hashes
c9d1ff7 Update hashes API changes (Nick Johnson) 878ab92 Add HMAC Extract-and-Expand Key Derivation Function (Nick Johnson) Pull request description: rustaceanrob and I have been working on a Rust-based BIP324 implementation over at https://github.com/rustaceanrob/bip324. We have been attempting to keep the code pretty clean in hopes of a future "soft landing" in rust-bitcoin. I figured the HKDF implementation is a small, self-contained chunk that might allow us to learn the ropes here first. There was a mention in the [discussion thread on BIP324](rust-bitcoin#1691) that the hashes interface may be changing in the near future. I am not sure the effect that would have on this implementation, but happy to work through any issues. Closes rust-bitcoin#2551 ACKs for top commit: tcharding: ACK c9d1ff7 apoelstra: ACK c9d1ff7 Tree-SHA512: 404d51ca055db4366ec57f1503fcf350aebcd181f36a20a17763ea8c47ade851213fc882acd2785313953a3e768d588c230f737ff93f88121b97c34b37c65127
2 parents 21cd53a + c9d1ff7 commit 0d1cab6

File tree

5 files changed

+277
-0
lines changed

5 files changed

+277
-0
lines changed

api/hashes/all-features.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl core::borrow::Borrow<[u8]> for bitcoin_hashes::sha512_256::Hash
6666
impl core::borrow::Borrow<[u8]> for bitcoin_hashes::siphash24::Hash
6767
impl core::clone::Clone for bitcoin_hashes::FromSliceError
6868
impl core::clone::Clone for bitcoin_hashes::hash160::Hash
69+
impl core::clone::Clone for bitcoin_hashes::hkdf::MaxLengthError
6970
impl core::clone::Clone for bitcoin_hashes::ripemd160::Hash
7071
impl core::clone::Clone for bitcoin_hashes::ripemd160::HashEngine
7172
impl core::clone::Clone for bitcoin_hashes::sha1::Hash
@@ -85,6 +86,7 @@ impl core::clone::Clone for bitcoin_hashes::siphash24::HashEngine
8586
impl core::clone::Clone for bitcoin_hashes::siphash24::State
8687
impl core::cmp::Eq for bitcoin_hashes::FromSliceError
8788
impl core::cmp::Eq for bitcoin_hashes::hash160::Hash
89+
impl core::cmp::Eq for bitcoin_hashes::hkdf::MaxLengthError
8890
impl core::cmp::Eq for bitcoin_hashes::ripemd160::Hash
8991
impl core::cmp::Eq for bitcoin_hashes::sha1::Hash
9092
impl core::cmp::Eq for bitcoin_hashes::sha256::Hash
@@ -106,6 +108,7 @@ impl core::cmp::Ord for bitcoin_hashes::sha512_256::Hash
106108
impl core::cmp::Ord for bitcoin_hashes::siphash24::Hash
107109
impl core::cmp::PartialEq for bitcoin_hashes::FromSliceError
108110
impl core::cmp::PartialEq for bitcoin_hashes::hash160::Hash
111+
impl core::cmp::PartialEq for bitcoin_hashes::hkdf::MaxLengthError
109112
impl core::cmp::PartialEq for bitcoin_hashes::ripemd160::Hash
110113
impl core::cmp::PartialEq for bitcoin_hashes::sha1::Hash
111114
impl core::cmp::PartialEq for bitcoin_hashes::sha256::Hash
@@ -153,8 +156,10 @@ impl core::default::Default for bitcoin_hashes::sha512::HashEngine
153156
impl core::default::Default for bitcoin_hashes::sha512_256::HashEngine
154157
impl core::default::Default for bitcoin_hashes::siphash24::HashEngine
155158
impl core::error::Error for bitcoin_hashes::FromSliceError
159+
impl core::error::Error for bitcoin_hashes::hkdf::MaxLengthError
156160
impl core::fmt::Debug for bitcoin_hashes::FromSliceError
157161
impl core::fmt::Debug for bitcoin_hashes::hash160::Hash
162+
impl core::fmt::Debug for bitcoin_hashes::hkdf::MaxLengthError
158163
impl core::fmt::Debug for bitcoin_hashes::ripemd160::Hash
159164
impl core::fmt::Debug for bitcoin_hashes::sha1::Hash
160165
impl core::fmt::Debug for bitcoin_hashes::sha256::Hash
@@ -168,6 +173,7 @@ impl core::fmt::Debug for bitcoin_hashes::siphash24::HashEngine
168173
impl core::fmt::Debug for bitcoin_hashes::siphash24::State
169174
impl core::fmt::Display for bitcoin_hashes::FromSliceError
170175
impl core::fmt::Display for bitcoin_hashes::hash160::Hash
176+
impl core::fmt::Display for bitcoin_hashes::hkdf::MaxLengthError
171177
impl core::fmt::Display for bitcoin_hashes::ripemd160::Hash
172178
impl core::fmt::Display for bitcoin_hashes::sha1::Hash
173179
impl core::fmt::Display for bitcoin_hashes::sha256::Hash
@@ -208,6 +214,7 @@ impl core::hash::Hash for bitcoin_hashes::sha512::Hash
208214
impl core::hash::Hash for bitcoin_hashes::sha512_256::Hash
209215
impl core::hash::Hash for bitcoin_hashes::siphash24::Hash
210216
impl core::marker::Copy for bitcoin_hashes::hash160::Hash
217+
impl core::marker::Copy for bitcoin_hashes::hkdf::MaxLengthError
211218
impl core::marker::Copy for bitcoin_hashes::ripemd160::Hash
212219
impl core::marker::Copy for bitcoin_hashes::sha1::Hash
213220
impl core::marker::Copy for bitcoin_hashes::sha256::Hash
@@ -219,6 +226,7 @@ impl core::marker::Copy for bitcoin_hashes::sha512_256::Hash
219226
impl core::marker::Copy for bitcoin_hashes::siphash24::Hash
220227
impl core::marker::Freeze for bitcoin_hashes::FromSliceError
221228
impl core::marker::Freeze for bitcoin_hashes::hash160::Hash
229+
impl core::marker::Freeze for bitcoin_hashes::hkdf::MaxLengthError
222230
impl core::marker::Freeze for bitcoin_hashes::ripemd160::Hash
223231
impl core::marker::Freeze for bitcoin_hashes::ripemd160::HashEngine
224232
impl core::marker::Freeze for bitcoin_hashes::sha1::Hash
@@ -238,6 +246,7 @@ impl core::marker::Freeze for bitcoin_hashes::siphash24::HashEngine
238246
impl core::marker::Freeze for bitcoin_hashes::siphash24::State
239247
impl core::marker::Send for bitcoin_hashes::FromSliceError
240248
impl core::marker::Send for bitcoin_hashes::hash160::Hash
249+
impl core::marker::Send for bitcoin_hashes::hkdf::MaxLengthError
241250
impl core::marker::Send for bitcoin_hashes::ripemd160::Hash
242251
impl core::marker::Send for bitcoin_hashes::ripemd160::HashEngine
243252
impl core::marker::Send for bitcoin_hashes::sha1::Hash
@@ -257,6 +266,7 @@ impl core::marker::Send for bitcoin_hashes::siphash24::HashEngine
257266
impl core::marker::Send for bitcoin_hashes::siphash24::State
258267
impl core::marker::StructuralPartialEq for bitcoin_hashes::FromSliceError
259268
impl core::marker::StructuralPartialEq for bitcoin_hashes::hash160::Hash
269+
impl core::marker::StructuralPartialEq for bitcoin_hashes::hkdf::MaxLengthError
260270
impl core::marker::StructuralPartialEq for bitcoin_hashes::ripemd160::Hash
261271
impl core::marker::StructuralPartialEq for bitcoin_hashes::sha1::Hash
262272
impl core::marker::StructuralPartialEq for bitcoin_hashes::sha256::Hash
@@ -268,6 +278,7 @@ impl core::marker::StructuralPartialEq for bitcoin_hashes::sha512_256::Hash
268278
impl core::marker::StructuralPartialEq for bitcoin_hashes::siphash24::Hash
269279
impl core::marker::Sync for bitcoin_hashes::FromSliceError
270280
impl core::marker::Sync for bitcoin_hashes::hash160::Hash
281+
impl core::marker::Sync for bitcoin_hashes::hkdf::MaxLengthError
271282
impl core::marker::Sync for bitcoin_hashes::ripemd160::Hash
272283
impl core::marker::Sync for bitcoin_hashes::ripemd160::HashEngine
273284
impl core::marker::Sync for bitcoin_hashes::sha1::Hash
@@ -287,6 +298,7 @@ impl core::marker::Sync for bitcoin_hashes::siphash24::HashEngine
287298
impl core::marker::Sync for bitcoin_hashes::siphash24::State
288299
impl core::marker::Unpin for bitcoin_hashes::FromSliceError
289300
impl core::marker::Unpin for bitcoin_hashes::hash160::Hash
301+
impl core::marker::Unpin for bitcoin_hashes::hkdf::MaxLengthError
290302
impl core::marker::Unpin for bitcoin_hashes::ripemd160::Hash
291303
impl core::marker::Unpin for bitcoin_hashes::ripemd160::HashEngine
292304
impl core::marker::Unpin for bitcoin_hashes::sha1::Hash
@@ -306,6 +318,7 @@ impl core::marker::Unpin for bitcoin_hashes::siphash24::HashEngine
306318
impl core::marker::Unpin for bitcoin_hashes::siphash24::State
307319
impl core::panic::unwind_safe::RefUnwindSafe for bitcoin_hashes::FromSliceError
308320
impl core::panic::unwind_safe::RefUnwindSafe for bitcoin_hashes::hash160::Hash
321+
impl core::panic::unwind_safe::RefUnwindSafe for bitcoin_hashes::hkdf::MaxLengthError
309322
impl core::panic::unwind_safe::RefUnwindSafe for bitcoin_hashes::ripemd160::Hash
310323
impl core::panic::unwind_safe::RefUnwindSafe for bitcoin_hashes::ripemd160::HashEngine
311324
impl core::panic::unwind_safe::RefUnwindSafe for bitcoin_hashes::sha1::Hash
@@ -325,6 +338,7 @@ impl core::panic::unwind_safe::RefUnwindSafe for bitcoin_hashes::siphash24::Hash
325338
impl core::panic::unwind_safe::RefUnwindSafe for bitcoin_hashes::siphash24::State
326339
impl core::panic::unwind_safe::UnwindSafe for bitcoin_hashes::FromSliceError
327340
impl core::panic::unwind_safe::UnwindSafe for bitcoin_hashes::hash160::Hash
341+
impl core::panic::unwind_safe::UnwindSafe for bitcoin_hashes::hkdf::MaxLengthError
328342
impl core::panic::unwind_safe::UnwindSafe for bitcoin_hashes::ripemd160::Hash
329343
impl core::panic::unwind_safe::UnwindSafe for bitcoin_hashes::ripemd160::HashEngine
330344
impl core::panic::unwind_safe::UnwindSafe for bitcoin_hashes::sha1::Hash
@@ -405,6 +419,7 @@ impl<T: bitcoin_hashes::Hash + schemars::JsonSchema> schemars::JsonSchema for bi
405419
impl<T: bitcoin_hashes::Hash + serde::ser::Serialize> serde::ser::Serialize for bitcoin_hashes::hmac::Hmac<T>
406420
impl<T: bitcoin_hashes::Hash> bitcoin_hashes::Hash for bitcoin_hashes::hmac::Hmac<T>
407421
impl<T: bitcoin_hashes::Hash> bitcoin_hashes::HashEngine for bitcoin_hashes::hmac::HmacEngine<T>
422+
impl<T: bitcoin_hashes::Hash> bitcoin_hashes::hkdf::Hkdf<T>
408423
impl<T: bitcoin_hashes::Hash> bitcoin_hashes::hmac::HmacEngine<T>
409424
impl<T: bitcoin_hashes::Hash> bitcoin_io::Write for bitcoin_hashes::hmac::HmacEngine<T>
410425
impl<T: bitcoin_hashes::Hash> core::convert::AsRef<[u8]> for bitcoin_hashes::hmac::Hmac<T>
@@ -443,26 +458,32 @@ impl<T: core::cmp::PartialEq + bitcoin_hashes::Hash> core::cmp::PartialEq for bi
443458
impl<T: core::cmp::PartialOrd + bitcoin_hashes::Hash> core::cmp::PartialOrd for bitcoin_hashes::hmac::Hmac<T>
444459
impl<T: core::hash::Hash + bitcoin_hashes::Hash> core::hash::Hash for bitcoin_hashes::hmac::Hmac<T>
445460
impl<T: core::marker::Copy + bitcoin_hashes::Hash> core::marker::Copy for bitcoin_hashes::hmac::Hmac<T>
461+
impl<T> core::marker::Freeze for bitcoin_hashes::hkdf::Hkdf<T> where T: core::marker::Freeze
446462
impl<T> core::marker::Freeze for bitcoin_hashes::hmac::Hmac<T> where T: core::marker::Freeze
447463
impl<T> core::marker::Freeze for bitcoin_hashes::hmac::HmacEngine<T> where <T as bitcoin_hashes::Hash>::Engine: core::marker::Freeze
448464
impl<T> core::marker::Freeze for bitcoin_hashes::hmac::HmacMidState<T> where <<T as bitcoin_hashes::Hash>::Engine as bitcoin_hashes::HashEngine>::MidState: core::marker::Freeze
449465
impl<T> core::marker::Freeze for bitcoin_hashes::sha256t::Hash<T>
466+
impl<T> core::marker::Send for bitcoin_hashes::hkdf::Hkdf<T> where T: core::marker::Send
450467
impl<T> core::marker::Send for bitcoin_hashes::hmac::Hmac<T> where T: core::marker::Send
451468
impl<T> core::marker::Send for bitcoin_hashes::hmac::HmacEngine<T> where <T as bitcoin_hashes::Hash>::Engine: core::marker::Send
452469
impl<T> core::marker::Send for bitcoin_hashes::hmac::HmacMidState<T> where <<T as bitcoin_hashes::Hash>::Engine as bitcoin_hashes::HashEngine>::MidState: core::marker::Send
453470
impl<T> core::marker::Send for bitcoin_hashes::sha256t::Hash<T> where T: core::marker::Send
471+
impl<T> core::marker::Sync for bitcoin_hashes::hkdf::Hkdf<T> where T: core::marker::Sync
454472
impl<T> core::marker::Sync for bitcoin_hashes::hmac::Hmac<T> where T: core::marker::Sync
455473
impl<T> core::marker::Sync for bitcoin_hashes::hmac::HmacEngine<T> where <T as bitcoin_hashes::Hash>::Engine: core::marker::Sync
456474
impl<T> core::marker::Sync for bitcoin_hashes::hmac::HmacMidState<T> where <<T as bitcoin_hashes::Hash>::Engine as bitcoin_hashes::HashEngine>::MidState: core::marker::Sync
457475
impl<T> core::marker::Sync for bitcoin_hashes::sha256t::Hash<T> where T: core::marker::Sync
476+
impl<T> core::marker::Unpin for bitcoin_hashes::hkdf::Hkdf<T> where T: core::marker::Unpin
458477
impl<T> core::marker::Unpin for bitcoin_hashes::hmac::Hmac<T> where T: core::marker::Unpin
459478
impl<T> core::marker::Unpin for bitcoin_hashes::hmac::HmacEngine<T> where <T as bitcoin_hashes::Hash>::Engine: core::marker::Unpin
460479
impl<T> core::marker::Unpin for bitcoin_hashes::hmac::HmacMidState<T> where <<T as bitcoin_hashes::Hash>::Engine as bitcoin_hashes::HashEngine>::MidState: core::marker::Unpin
461480
impl<T> core::marker::Unpin for bitcoin_hashes::sha256t::Hash<T> where T: core::marker::Unpin
481+
impl<T> core::panic::unwind_safe::RefUnwindSafe for bitcoin_hashes::hkdf::Hkdf<T> where T: core::panic::unwind_safe::RefUnwindSafe
462482
impl<T> core::panic::unwind_safe::RefUnwindSafe for bitcoin_hashes::hmac::Hmac<T> where T: core::panic::unwind_safe::RefUnwindSafe
463483
impl<T> core::panic::unwind_safe::RefUnwindSafe for bitcoin_hashes::hmac::HmacEngine<T> where <T as bitcoin_hashes::Hash>::Engine: core::panic::unwind_safe::RefUnwindSafe
464484
impl<T> core::panic::unwind_safe::RefUnwindSafe for bitcoin_hashes::hmac::HmacMidState<T> where <<T as bitcoin_hashes::Hash>::Engine as bitcoin_hashes::HashEngine>::MidState: core::panic::unwind_safe::RefUnwindSafe
465485
impl<T> core::panic::unwind_safe::RefUnwindSafe for bitcoin_hashes::sha256t::Hash<T> where T: core::panic::unwind_safe::RefUnwindSafe
486+
impl<T> core::panic::unwind_safe::UnwindSafe for bitcoin_hashes::hkdf::Hkdf<T> where T: core::panic::unwind_safe::UnwindSafe
466487
impl<T> core::panic::unwind_safe::UnwindSafe for bitcoin_hashes::hmac::Hmac<T> where T: core::panic::unwind_safe::UnwindSafe
467488
impl<T> core::panic::unwind_safe::UnwindSafe for bitcoin_hashes::hmac::HmacEngine<T> where <T as bitcoin_hashes::Hash>::Engine: core::panic::unwind_safe::UnwindSafe
468489
impl<T> core::panic::unwind_safe::UnwindSafe for bitcoin_hashes::hmac::HmacMidState<T> where <<T as bitcoin_hashes::Hash>::Engine as bitcoin_hashes::HashEngine>::MidState: core::panic::unwind_safe::UnwindSafe
@@ -563,6 +584,12 @@ pub fn bitcoin_hashes::hash160::Hash::partial_cmp(&self, other: &bitcoin_hashes:
563584
pub fn bitcoin_hashes::hash160::Hash::schema_name() -> alloc::string::String
564585
pub fn bitcoin_hashes::hash160::Hash::serialize<S: serde::ser::Serializer>(&self, s: S) -> core::result::Result<<S as serde::ser::Serializer>::Ok, <S as serde::ser::Serializer>::Error>
565586
pub fn bitcoin_hashes::hash160::Hash::to_byte_array(self) -> Self::Bytes
587+
pub fn bitcoin_hashes::hkdf::Hkdf<T>::expand(&self, info: &[u8], okm: &mut [u8]) -> core::result::Result<(), bitcoin_hashes::hkdf::MaxLengthError>
588+
pub fn bitcoin_hashes::hkdf::Hkdf<T>::expand_to_len(&self, info: &[u8], len: usize) -> core::result::Result<alloc::vec::Vec<u8>, bitcoin_hashes::hkdf::MaxLengthError>
589+
pub fn bitcoin_hashes::hkdf::Hkdf<T>::new(salt: &[u8], ikm: &[u8]) -> Self
590+
pub fn bitcoin_hashes::hkdf::MaxLengthError::clone(&self) -> bitcoin_hashes::hkdf::MaxLengthError
591+
pub fn bitcoin_hashes::hkdf::MaxLengthError::eq(&self, other: &bitcoin_hashes::hkdf::MaxLengthError) -> bool
592+
pub fn bitcoin_hashes::hkdf::MaxLengthError::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
566593
pub fn bitcoin_hashes::hmac::Hmac<T>::all_zeros() -> Self
567594
pub fn bitcoin_hashes::hmac::Hmac<T>::as_byte_array(&self) -> &Self::Bytes
568595
pub fn bitcoin_hashes::hmac::Hmac<T>::as_ref(&self) -> &[u8]
@@ -914,6 +941,7 @@ pub macro bitcoin_hashes::sha256t_hash_newtype!
914941
pub mod bitcoin_hashes
915942
pub mod bitcoin_hashes::cmp
916943
pub mod bitcoin_hashes::hash160
944+
pub mod bitcoin_hashes::hkdf
917945
pub mod bitcoin_hashes::hmac
918946
pub mod bitcoin_hashes::ripemd160
919947
pub mod bitcoin_hashes::serde_macros
@@ -928,6 +956,8 @@ pub mod bitcoin_hashes::sha512_256
928956
pub mod bitcoin_hashes::siphash24
929957
pub struct bitcoin_hashes::FromSliceError
930958
pub struct bitcoin_hashes::HmacEngine<T: bitcoin_hashes::Hash>
959+
pub struct bitcoin_hashes::hkdf::Hkdf<T: bitcoin_hashes::Hash>
960+
pub struct bitcoin_hashes::hkdf::MaxLengthError
931961
pub struct bitcoin_hashes::hmac::HmacEngine<T: bitcoin_hashes::Hash>
932962
pub struct bitcoin_hashes::hmac::HmacMidState<T: bitcoin_hashes::Hash>
933963
pub struct bitcoin_hashes::ripemd160::HashEngine

0 commit comments

Comments
 (0)