-
Notifications
You must be signed in to change notification settings - Fork 258
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
base: master
Are you sure you want to change the base?
Conversation
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.
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 Vec
s), 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.
@newpavlov |
The CI failure is fixed in #637, so you need to rebase to master. |
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.
Thank you! I have some surface-level comments for now. I will take a closer look at the algorithm implementation later.
md6/Cargo.toml
Outdated
rust-version = "1.81" | ||
|
||
[lib] | ||
name = "md6" |
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.
These two lines are not needed.
md6/Cargo.toml
Outdated
|
||
[package.metadata.docs.rs] | ||
all-features = true | ||
rustdoc-args = ["--cfg", "docsrs"] |
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.
docsrs
flag is passed by default during docs.rs builds and no longer needed. I will remove it from other crates in a separate PR.
md6/src/compress.rs
Outdated
@@ -0,0 +1,194 @@ | |||
use crate::consts::*; | |||
|
|||
const W: usize = MD6_W; // number of bits in a word (64) |
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.
You can simply rename these constants in the consts
module.
md6/src/compress.rs
Outdated
const V: usize = MD6_V; // words for control word (0 or 64/w) | ||
const B: usize = MD6_B; // data words per compression block (> 0) (64) | ||
|
||
const T0: usize = 17; // index for linear feedback |
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 it's worth to move these constants to the consts
module.
md6/src/consts.rs
Outdated
pub(crate) type Md6ControlWord = u64; | ||
pub(crate) type Md6NodeID = u64; | ||
|
||
pub(crate) const MD6_MAX_STACK_HEIGHT: usize = 29; // maximum stack height |
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.
Please use docstrings for constant descriptions, i.e.:
/// Maximum stack height
pub(crate) const MD6_MAX_STACK_HEIGHT: usize = 29;
md6/src/consts.rs
Outdated
pub(crate) const MD6_N: usize = 89; // size of compression input block in words | ||
|
||
/// These five values give lengths of the components of compression | ||
/// input block; they should sum to MD6_N. |
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.
It's not a docstring comment. Use //
instead to comment on a block of constants.
md6/src/consts.rs
Outdated
@@ -0,0 +1,21 @@ | |||
/// MD6 constants related to standard mode of operation | |||
|
|||
pub(crate) type Md6Word = u64; |
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.
You may just use pub
for items in this module since you use pub(crate) mod consts;
in lib.rs.
md6/tests/mod.rs
Outdated
@@ -0,0 +1,363 @@ | |||
#![no_std] |
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.
#![no_std]
is not needed in tests since tests rely on std
by default.
Could you also provide a provenance link for these test vectors?
md6/src/md6.rs
Outdated
impl Md6VarCore { | ||
#[inline] | ||
fn init(d: usize) -> Self { | ||
// |
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.
Remove this empty comment line?
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.
Ok sir
added source for test vectors
implementation of md6 in pure rust.