Skip to content

FSB hash function#256

Merged
tarcieri merged 21 commits into
RustCrypto:masterfrom
iquerejeta:master
Jul 18, 2021
Merged

FSB hash function#256
tarcieri merged 21 commits into
RustCrypto:masterfrom
iquerejeta:master

Conversation

@iquerejeta

Copy link
Copy Markdown
Contributor

As an exercise, I've implemented the FSB hash function taking as a reference the paper, so I might have missed out on some efficiency tricks in the reference implementation.

If you'd be happy to have this code in the repo, I'm happy to maintain it and make the necessary changes to take it to the repo quality standards!

@iquerejeta iquerejeta mentioned this pull request May 2, 2021
20 tasks
Comment thread .gitignore Outdated
Comment on lines +4 to +5
.idea
.DS_Store

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Speaking as a fellow IntelliJ user...

I'd suggest adding the following to your personal ~/.gitconfig instead:

[core]
  excludesfile = /home/myuser/.gitignore

...and then putting these kinds of directives in there.

That avoids every other project having to add .gitignore directives for every editor.

Comment thread fsb/Cargo.toml Outdated
@@ -0,0 +1,16 @@
[package]
name = "fsb_rust"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

RustCrypto owns the fsb name. You can use that.

@newpavlov can you add rustcrypto:hashes as an owner?

Comment thread fsb/Cargo.toml Outdated
@tarcieri

tarcieri commented May 3, 2021

Copy link
Copy Markdown
Member

Looks like a promising start!

@iquerejeta can you rebase? You'll probably want to git checkout --theirs Cargo.lock and have it recomputed from there.

Comment thread fsb/src/lib.rs
#[allow(dead_code)]
#[macro_use]
mod macros;
mod pi;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

GitHub won't even let me leave comments on that module, but... wow 😮

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not my work! Copied that file from the reference implementation

@tarcieri

tarcieri commented May 3, 2021

Copy link
Copy Markdown
Member

@iquerejeta it looks like you need to bump clippy MSRV in .github/workflows/workspace.yml L19

Also can copy/modify a README.md from one of the other crates? (e.g. blake2) Thanks!

@iquerejeta

iquerejeta commented May 3, 2021

Copy link
Copy Markdown
Contributor Author

I've rebased, hopefully correctly 😄

  • Missing the bump on clippy

qq, should I squash all commits to have a cleaner history?

@tarcieri

tarcieri commented May 3, 2021

Copy link
Copy Markdown
Member

We use GitHub's "Squash and merge" feature so you don't need to worry about squashing it yourself

@iquerejeta

iquerejeta commented May 16, 2021

Copy link
Copy Markdown
Contributor Author

Bumped version. I got a security audit failing in the repo, but can't really tell what the problems are. Also I got a bunch of PRs from the bot, requesting to bump dependencies on other crates (e.g. sha1 or sha2). Should I go ahead and merge all these PRs?
Thanks!

@tarcieri

Copy link
Copy Markdown
Member

Tests appear to be passing now.

@newpavlov newpavlov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I haven't checked the implementation itself, so I have only several surface-level comments for now.

Comment thread .github/workflows/workspace.yml Outdated
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.41.0 # MSRV
toolchain: 1.47.0 # MSRV

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can remove the "MSRV" comment from here, since it's not about MSRV, but about pinning clippy version.

Comment thread Cargo.lock

[[package]]
name = "fsb_rust"
version = "0.1.0"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since you've already changed the crate name, re-generate the lock file, so it will use fsb instead of fsb_rust? I have shared ownership of the fsb crate with the hashes group, so we can publish it immediately after merge.

Comment thread fsb/Cargo.toml Outdated
categories = ["cryptography", "no-std"]

[dependencies]
whirlpool = "0.9"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suggest using whirlpool = { version = "0.9", path = "../whirlpool", default-features = false } here.

Comment thread fsb/README.md Outdated
[![crate][crate-image]][crate-link]
[![Docs][docs-image]][docs-link]
[![Build Status][build-image]][build-link]
-->

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Don't forget to uncomment these lines?

Comment thread fsb/src/lib.rs
@@ -0,0 +1,21 @@
#![allow(non_snake_case)]
#[allow(dead_code)]
#[macro_use]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is it truly necessary to allow dead code? It also would be nice to add crate-level docs, no_std and other attributes (see other crates for reference).

@iquerejeta iquerejeta Jun 5, 2021

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

added no_std, and I depend on alloc now for dynamically sized arrays. We use them here.

Comment thread fsb/tests/lib.rs
assert_eq!(
result[..],
hex!("6e8ce7998e4c46a4ca7c5e8f6498a5778140d14b")[..]
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can simply use the following code here:

assert_eq!(
    Fsb160::digest(msg_1)[..],
    hex!("6e8ce7998e4c46a4ca7c5e8f6498a5778140d14b")[..],
);

@tarcieri tarcieri merged commit a1e8900 into RustCrypto:master Jul 18, 2021
@tarcieri

Copy link
Copy Markdown
Member

@iquerejeta thank you!

@iquerejeta

Copy link
Copy Markdown
Contributor Author

Pleasure! I'm happy to change the tests using the use digest::new_test; macro, but when I tried it out I couldn't figure out how to generate the data (e.g. hashes/sha2/tests/data/sha256.blb), any tips?

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.

3 participants