Skip to content
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

implementation of md6 in pure rust #636

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

truthixify
Copy link

implementation of md6 in pure rust.

Copy link
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

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

We can not merge this implementation in such state.

Please, do not disable the Clippy lints, follow the trait API defined in the digest crate, keep the crate no_std-capable (i.e. your code should not have any Vecs), add a CI workflow config for this crate (you can use the md5 file for reference), add the crate to the workspace by modifying the root Cargo.toml file, and remove the md6/.gitignore file.

Our trait APIs are a bit complex (and not documented that well), so I recommend taking a look at other crates in this repository first.

@truthixify
Copy link
Author

@newpavlov
I don't know why this is failing: sha2 / riscv64-zknh (pull_request)

@newpavlov
Copy link
Member

The CI failure is fixed in #637, so you need to rebase to master.

Copy link
Member

@newpavlov newpavlov left a comment

Choose a reason for hiding this comment

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

Thank you! I have some surface-level comments for now. I will take a closer look at the algorithm implementation later.

@newpavlov
Copy link
Member

Could you also add this crate to the algorithms table in the root README?

@newpavlov
Copy link
Member

Also please add a CI job for this crate. You can use the md5 config for reference.

while j < r * C {
// Call the loop bodies based on the value of `w`.
// This will perform the main computation for each step in the compression loop.
call_loop_bodies!(W, s, i);
Copy link
Member

Choose a reason for hiding this comment

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

You always use the W constant with this macro. Why do you then handle other potential W values in the macro?

You either need to change W depending on compilation target (it's fine to support only 32 and 64 bit targets), or you need to remove the dead branches.

Copy link
Author

Choose a reason for hiding this comment

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

The reason why I did that was because, I'd like to support compilation target.

Copy link
Member

Choose a reason for hiding this comment

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

Then you need to change the W constant depending on target:

#[cfg(target_pointer_width = "64")]
pub const N: usize = 64;
#[cfg(target_pointer_width = "32")]
pub const N: usize = 32;

You can remove branches responsible for 16 and 8 bit targets since Rust compiler does not support those.

Copy link
Author

Choose a reason for hiding this comment

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

Okay sir.


const _: () = {
if Q + K + U + V + B != N {
panic!("`Q + K + U + V` must be equal to `N`");
Copy link
Member

Choose a reason for hiding this comment

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

Sorry, forgot B, it should be "Q + K + U + V + B" in the panic message.

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.

2 participants