Skip to content

Conversation

@newpavlov
Copy link
Member

@newpavlov newpavlov commented Aug 30, 2022

The ugly bounds on the HMAC functions can be improved by resolving RustCrypto/MACs#104.

Closes #335.

@newpavlov newpavlov requested a review from tarcieri August 30, 2022 22:20
@newpavlov newpavlov changed the title hmac: add new wrapper functions pbkdf2: add new wrapper functions Aug 30, 2022
/// use sha2::Sha256;
///
/// let res = pbkdf2_array::<Hmac<Sha256>, 20>(b"password", b"salt", 4096)
/// .expect("HMAC can be initialized with any key length");
Copy link
Member

@tarcieri tarcieri Sep 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I've been trying to eliminate the usages of expect in documentation going forward, although the boilerplate to do so is a bit onerous:

#![cfg_attr(feature = "std", doc = "```")]
#![cfg_attr(not(feature = "std"), doc = "```ignore")]
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let res = pbkdf2_array::<Hmac<Sha256>, 20>(b"password", b"salt", 4096)?;
//! # Ok(())
//! # }
//! ```

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think expect in this case is preferred to the error bubbling since the panic never will be triggered.

@tarcieri
Copy link
Member

tarcieri commented Sep 6, 2022

Looks like Cargo.lock needs updated but otherwise this seems really helpful!

@newpavlov newpavlov merged commit bf90bb7 into master Sep 13, 2022
@newpavlov newpavlov deleted the hmac_new_api branch September 13, 2022 04:13
@tarcieri tarcieri mentioned this pull request Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add a convenient way for common pbkdf2::<Hmac<Sha1>>(*** )

3 participants