-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add checking for Blake256 parameters #117
fix: add checking for Blake256 parameters #117
Conversation
a6ff213
to
fa12759
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/hash/error.rs
Outdated
pub enum HashError { | ||
/// Length of input data exceeded a limit | ||
#[error("wrong length")] | ||
WorngLength, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WorngLength, | |
WrongLength, |
src/hash/blake2.rs
Outdated
)) | ||
pub fn with_params(key: &[u8], salt: &[u8], persona: &[u8]) -> Result<Self, HashError> { | ||
if salt.len() > 16 || persona.len() > 16 { | ||
Err(HashError::WorngLength) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Err(HashError::WorngLength) | |
Err(HashError::WrongLength) |
fa12759
to
0ff24df
Compare
I propose we add another function to make full use of the flexibility provided by pub fn with_params_var_size(key: &[u8], salt: &[u8], persona: &[u8], output_size: usize) -> Result<Self, HashError> |
} | ||
|
||
/// Constructs a `Blake256` hashing context with an explicitly specified output size. | ||
pub fn with_params_var_size( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a unit test for this and for pub fn with_params
testing all the edge cases.
Description --- The update for the upcoming `tari-crypto` updates: - tari-project/tari-crypto#117 - tari-project/tari-crypto#112 Motivation and Context --- How Has This Been Tested? ---
It adds checking for
Blake256
parameters: salt and persona should be less or equal 16 bytes length.Motivation: the fixes for #110.