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

pkg: add a package for hashing with Keccak with unit test #7903

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

adrianghc
Copy link
Contributor

@adrianghc adrianghc commented Oct 28, 2017

This pull request adds a package to support hashing with the Keccak algorithm that is the basis of SHA-3. While SHA-3 per the NIST standard uses a state width of 1600 bits, the code supported here uses a state width of 800 bits in order to increase hashing speed with low-powered devices. The package source is downloaded from my fork of the KeccakCodePackage repository. It can be built for the following architectures:

  • native (x86)
  • Cortex-M0, Cortex-M0+ (ARMv6-M)
  • Cortex-M3, Cortex-M4, Cortex-M4F (ARMv7-M)

In addition to the package alone, this pull request adds unit tests for hashing with Keccak, placed under tests/unittests/tests-hashes along with the existing ones.

@miri64
Copy link
Member

miri64 commented Oct 29, 2017

There is also a keccak import in #7881.

Also any reason why you only provided a PR against the release branch, but not master? New features usually only go into master and are then provided with the next release.

@miri64 miri64 changed the base branch from 2017.10-branch to master October 29, 2017 07:59
@miri64 miri64 changed the base branch from master to 2017.10-branch October 29, 2017 08:00
miri64
miri64 previously requested changes Oct 29, 2017
Copy link
Member

@miri64 miri64 left a comment

Choose a reason for hiding this comment

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

Please rebase upon master and check with #7881 if your implementations can be merged somehow.

@miri64 miri64 changed the base branch from 2017.10-branch to master October 29, 2017 08:01
@miri64
Copy link
Member

miri64 commented Oct 29, 2017

Happy first contribution btw :-) 🎉

@adrianghc
Copy link
Contributor Author

adrianghc commented Oct 29, 2017

Pull request #7881 adds support for SHA-3 by directly adding the implementation as a module in sys whereas my pull request adds it as a package so I'm not sure how they could be merged as the approaches are somewhat opposite. However, it should be noted that while #7881 uses SHA-3 as per the NIST standard (i.e. with 1600 bit state), my PR imports a package where 800 bit state width is used, so under that perspective there is a place for both implementations perhaps?

And thanks. :)

@miri64 miri64 added State: duplicate State: The issue/PR is a duplicate of another issue/PR Type: new feature The issue requests / The PR implemements a new feature for RIOT Area: pkg Area: External package ports Area: security Area: Security-related libraries and subsystems labels Oct 29, 2017
@miri64 miri64 dismissed their stale review October 29, 2017 19:19

I leave the rest of the review to people more knowledgeable in hashes.

@emmanuelsearch
Copy link
Member

We should probably aim at a single PR which offers both NIST-standard SHA-3 and Keccak-800, based on Keccak imported as a package.

@emmanuelsearch
Copy link
Member

@adrianghc please rebase on current master.

@miri64 miri64 assigned emmanuelsearch and unassigned mtausig and kaspar030 Nov 6, 2017
Copy link
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

initial round

@mtausig
Copy link
Contributor

mtausig commented Nov 6, 2017

I am putting my opinion on this PR already stated in #7881 here, too:

A good direction what this package would be, to make a generic "sponge crypto" package out of it.
Having one common implementation for the sponge construction, the ability to use multiple permutations (Keccaks of different width or other lightweight sponges like photon or quark) and then several functions with cryptographic applications of the sponge (hash, mac, rng, aead, xof, streamcipher).

@emmanuelsearch
Copy link
Member

@adrianghc you still have 125 commits in your PR, most of them having nothing to do with this PR. Please fix.

@adrianghc
Copy link
Contributor Author

@emmanuelsearch Forgive me if this is a stupid question, but how would I do this? I'm afraid my experience with Git has its limits.

@miri64
Copy link
Member

miri64 commented Nov 13, 2017

@emmanuelsearch Forgive me if this is a stupid question, but how would I do this? I'm afraid my experience with Git has its limits.

@adrianghc if you want to, you can come by our office (we moved to 159 however) in the next few days and I can see if I can help you with that.

@adrianghc
Copy link
Contributor Author

adrianghc commented Nov 13, 2017

@miri64 Thank you very much for the offer, that sounds great. However, this would probably be best after all comments and requested changes here have been addressed and resolved, wouldn't it? Or wouldn't additional commits for those after the cleanup be a problem?

@miri64
Copy link
Member

miri64 commented Jul 2, 2020

On a side note, I feel like 80 is too low. People can be expected to have wide screens these days, so fitting more than 80 characters should be no issue, and such a low character limit actually lessens readability when it forces awkward line breaks, e.g. in if-clauses or in function signatures.

That's why 80 is our soft limit and 100 the hard ;-).

@miri64
Copy link
Member

miri64 commented Jul 2, 2020

Only micropython failing on nrf52dk. This is unrelated. Let's give it another spin without tests. @kaspar030 are you ok with this PR?

@miri64 miri64 added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: run tests If set, CI server will run tests on hardware for the labeled PR labels Jul 2, 2020
@adrianghc
Copy link
Contributor Author

On a side note, I feel like 80 is too low. People can be expected to have wide screens these days, so fitting more than 80 characters should be no issue, and such a low character limit actually lessens readability when it forces awkward line breaks, e.g. in if-clauses or in function signatures.

That's why 80 is our soft limit and 100 the hard ;-).

Well, there are still warnings in Murdock when exceeding just the 80 character limit.

@miri64
Copy link
Member

miri64 commented Jul 2, 2020

Well, there are still warnings in Murdock when exceeding just the 80 character limit.

Yes but warnings block your PR. See also discussion in #13400 :-).

@adrianghc
Copy link
Contributor Author

Well, there are still warnings in Murdock when exceeding just the 80 character limit.

Yes but warnings block your PR. See also discussion in #13400 :-).

Then how exactly is there a 100 character limit if passing 80 already generates a warning?

@miri64
Copy link
Member

miri64 commented Jul 2, 2020

Well, there are still warnings in Murdock when exceeding just the 80 character limit.

Yes but warnings block your PR. See also discussion in #13400 :-).

Then how exactly is there a 100 character limit if passing 80 already generates a warning?

See our coding conventions 80 characters is preferred, but it should never be longer than 100 characters. Disregarding that all Vera++ messages currently are warnings, as it is still more or less in a test phase: How do you model such a decision? Make 80 chars a warning and 100 chars an error. Right?

@adrianghc
Copy link
Contributor Author

Well, there are still warnings in Murdock when exceeding just the 80 character limit.

Yes but warnings block your PR. See also discussion in #13400 :-).

Then how exactly is there a 100 character limit if passing 80 already generates a warning?

See our coding conventions 80 characters is preferred, but it should never be longer than 100 characters. Disregarding that all Vera++ messages currently are warnings, as it is still more or less in a test phase: How do you model such a decision? Make 80 chars a warning and 100 chars an error. Right?

I know about the coding conventions, my point is that if 80 characters already generates a warning and warnings block the PR, then the limit is effectively at 80 characters. But perhaps I misunderstood something. Also it seemed like my files were the only ones causing warnings for the 80 character limit, and I didn't want them to stand out like that.

@aabadie
Copy link
Contributor

aabadie commented Jul 2, 2020

warnings block the PR

warnings in the static test should not block a PR. vera++ generates too many warnings so even if there are warnings it doesn't return in an error.

@miri64
Copy link
Member

miri64 commented Jul 2, 2020

Also it seemed like my files were the only ones causing warnings for the 80 character limit, and I didn't want them to stand out like that

Vera++ also checks changed files on the CI, so they won't stick out in the overall picture ;-).

@adrianghc
Copy link
Contributor Author

I guess it was all a misunderstanding then. I kind of regret changing all those lines to forcibly fit within 80 characters now. 😅 (All but two were already well within 100.)

@aabadie
Copy link
Contributor

aabadie commented Jul 2, 2020

I kind of regret changing all those lines to forcibly fit within 80 characters now

If you'd use fixup commits instead of force-pushing all the time, you would have kept the possibility to use git to remove
these changes (and also simplify our review work)

@adrianghc
Copy link
Contributor Author

I kind of regret changing all those lines to forcibly fit within 80 characters now

If you'd use fixup commits instead of force-pushing all the time, you would have kept the possibility to use git to remove
these changes (and also simplify our review work)

Well, I still have a backup of the old files, so I could still use those, but at this point I feel like maybe we could just get this over with. And to be honest with you, I didn't know about fixup commits. Please accept my apologies.

@aabadie
Copy link
Contributor

aabadie commented Jul 2, 2020

I didn't know about fixup commits

They are described in the contributing document.

@adrianghc
Copy link
Contributor Author

I didn't know about fixup commits

They are described in the contributing document.

Well, I didn't say I was blaming anyone but myself for not knowing about them.

@aabadie
Copy link
Contributor

aabadie commented Jul 2, 2020

I have another question regarding the version used for this package (sorry for asking so late and close from an ACK :) ): the commit targeted by the package is bc592d1780a6b3204c26c6f872552ace8fc6fd65, created on december, 2017. So it's quite old and the project has evolved quite a bit since then. The codebase is now completely different. Are we trying to merge support for completely outdated code ?

@adrianghc
Copy link
Contributor Author

Well, the PR is that old, too... I guess it could be merged in and if someone actually uses the Keccak package, then the package could be updated to the new codebase? This PR is a byproduct of my bachelor thesis from 2017 but right now I'm working on my masters thesis and I'm honestly not very interested in investing the work in updating a package that nobody may even end up using. Not to mention that with SHA-3 support now built in, as I've just found out, the purpose of this package becomes somewhat questionable. Basically what it offers vs built-in SHA-3 is Keccak-800 support, whereas SHA-3 uses Keccak-1600. Which isn't to say Keccak-800 support isn't interesting enough for inclusion but I'm not sure people are really going to use it, assuming they even know about it.

@MrKevinWeiss MrKevinWeiss added this to the Release 2021.07 milestone Jun 21, 2021
@MrKevinWeiss MrKevinWeiss removed this from the Release 2021.07 milestone Jul 15, 2021
@Teufelchen1 Teufelchen1 marked this pull request as draft March 12, 2024 17:14
@Teufelchen1
Copy link
Contributor

Marked as a draft. There seems to be little interest in merging this soon®. But the author stated that it might be worth looking at the PR when somebody else picks this topic up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: pkg Area: External package ports Area: security Area: Security-related libraries and subsystems CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.