Uh oh!
There was an error while loading. Please reload this page.
Refactoring of the pbkdf2 crate. - #20
Conversation
This makes the PR compatible to Rust 1.22.
jfrimmel
commented
Aug 18, 2019
Do you want to keep the minimum Rust version of 1.22? Some dependencies (e.g. rand) could also be updated, if the MSRV is bumped |
newpavlov
left a comment
There was a problem hiding this comment.
Thank you! Looks good!
But I think we can add a small optimization.
| // check the format of the input: there may be no tokens before the first | ||
| // and after the last `$`, tokens must have correct information and length. | ||
| let (count, salt, hash) = match parts[..] { |
There was a problem hiding this comment.
I think you can remove the allocation and be compatible with Rust 1.22 by using:
letmut p = hashed_value.split('$');let buf = [
p.next(), p.next(), p.next(), p.next(),
p.next(), p.next(), p.next(), p.next(),];let(count, salt, hash) = match buf {[Some(""),Some("rpbkdf2"),Some("0"),Some(count),Some(salt),Some(hash),Some(""),None,] => (count, salt, hash),
_ => returnErr(CheckError::InvalidFormat),};Also it looks like Err(CheckError::InvalidFormat)? is discouraged (e.g. by clippy), so we probably better to replace it with an explicit return.
There was a problem hiding this comment.
Thank you for your suggestion. I will remove the unnecessary allocation (I wasn't happy with it, too) by applying your changes 😄
Unfortunately, I don't think, that Rust 1.22 will support this code as well.
Edit: but I have an Idea how to do this in Rust 1.22. I'll update this PR soon
fubuloubu
commented
Aug 26, 2019
This will fix #17, correct? |
jfrimmel
commented
Aug 27, 2019
Unfortunately no, since this PR does not increase the MSRV. This would be required to use Rand 0.7. |
tarcieri
commented
Jun 10, 2020
@jfrimmel can you rebase? we've bumped MSRV to 1.41+ |
newpavlov
commented
Jun 10, 2020
I've included your refactor into #33. |
This PR applies refactoring to the
pbkdf2crate, especially for thesimplemodule.It is best viewed commit by commit.