Overview
When trying to create Salt via Salt::new(...) with an invalid PHC character, the operation fails with the Error::SaltToLong error which was a little confusing until I looked into the code here:
https://github.com/RustCrypto/traits/blob/master/password-hash/src/salt.rs#L108
Example salt to reproduce: 1234_mysalt.
From the left todo, I assume it might have been a known issue.
Possible solution
Perhaps the Error::ParamValueInvalid could be extended to contain the cause of the invalid value:
...pubenumError{
...
ParamValueInvalid(ParamValueError)
...
}pubenumParamValueError{ToLong,ToShort,InvalidChar,// ... and any other possible issues}This might be treated as a breaking change from the library perspective tho.
I can try to draft the PR if there is any interest in this solution, otherwise happy to discuss further 🙂
Overview
When trying to create
SaltviaSalt::new(...)with an invalid PHC character, the operation fails with theError::SaltToLongerror which was a little confusing until I looked into the code here:https://github.com/RustCrypto/traits/blob/master/password-hash/src/salt.rs#L108
Example salt to reproduce:
1234_mysalt.From the left todo, I assume it might have been a known issue.
Possible solution
Perhaps the
Error::ParamValueInvalidcould be extended to contain the cause of the invalid value:This might be treated as a breaking change from the library perspective tho.
I can try to draft the PR if there is any interest in this solution, otherwise happy to discuss further 🙂