-
Notifications
You must be signed in to change notification settings - Fork 918
Rust wrapper: add HMAC-BLAKE2[bs] wrappers #9687
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
base: master
Are you sure you want to change the base?
Conversation
|
retest this please (org.jenkinsci.plugins.workflow.support.steps.AgentOfflineException: Unable to create live FilePath for wolf-linux-cloud-node-2zcwho; wolf-linux-cloud-node-2zcwho was marked offline: Connection was broken) |
| /// | ||
| /// Returns either Ok(()) on success or Err(e) containing the wolfSSL | ||
| /// library error code value. | ||
| #[cfg(blake2b_hmac)] |
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 this is not necessary, since the whole impl block is gated (line 177).
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.
Ah yes, thanks. I originally had the one-shot API in the BLAKE2b impl block instead of making a separate BLAKE2bHmac struct. Removed!
| /// | ||
| /// Returns either Ok(()) on success or Err(e) containing the wolfSSL | ||
| /// library error code value. | ||
| #[cfg(blake2s_hmac)] |
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 this is not necessary, since the whole impl block is gated (line 451).
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.
Removed
| /// let mut mac = [0u8; 64]; | ||
| /// hmac_blake2b.finalize(&key, &mut mac).expect("Error with finalize()"); | ||
| /// ``` | ||
| pub fn finalize(&mut self, key: &[u8], mac: &mut [u8]) -> Result<(), i32> { |
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.
From the docs it says "must be 64 bytes", but there's no check to enforce that.
Maybe you can turn the mac argument to be &mut [u8; 64], or at least document what happens if the length is not respected once the buffer is passed to the C api.
This applies to the finalize function in the HMAC-BLAKE2s module too, but with 32 bytes instead.
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.
Good idea; I added an exact length requirement.
| /// Returns either Ok(()) on success or Err(e) containing the wolfSSL | ||
| /// library error code value. | ||
| #[cfg(blake2b_hmac)] | ||
| pub fn hmac(data: &[u8], key: &[u8], out: &mut [u8]) -> Result<(), i32> { |
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.
The out parameter doesn't document or enforce its expected size (64 bytes for BLAKE2b, 32 bytes for BLAKE2s). Maybe turn it to &mut [u8; 64] for compile-time enforcement, or at least document what happens if the length is not respected once the buffer is passed to the C API. This applies to both BLAKE2bHmac::hmac() and BLAKE2sHmac::hmac().
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.
Good idea; I added an exact length requirement.
|
retest this please (org.jenkinsci.plugins.workflow.support.steps.AgentOfflineException: Unable to create live FilePath for wolf-linux-cloud-node-q02z3c; wolf-linux-cloud-node-q02z3c was marked offline: Connection was broken) |
Description
Add Rust wrapper for HMAC-BLAKE2[bs] one-shot and incremental APIs.
Also attempted to avoid a couple coverity messages about overrunning the x_key array (false positives).
Testing
Unit tests and integration with boringtun
Checklist