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

Standard hash algorithm names? #246

Open
matt-phylum opened this issue Aug 1, 2023 · 3 comments
Open

Standard hash algorithm names? #246

matt-phylum opened this issue Aug 1, 2023 · 3 comments
Labels
Ecma specification Work on the core specification PURL type definition Non-core definitions that describe and standardize PURL types

Comments

@matt-phylum
Copy link
Contributor

Everybody knows about the MD5 SHA-1 SHA-256 SHA-512 algorithms, and these are almost universally written as md5 sha1 sha256 sha512. Unfortunately, the PURL spec says the key for the checksum qualifier is "lowercase_algorithm" and then lowercases "SHA-1" and "SHA-256" into "sha1" and "sha256" for the example. For these algorithms, the description and example are probably okay. That implies that the rest of the SHA-2 family, SHA-224 SHA-384 SHA-512, becomes sha224 sha384 sha512.

However, it's unclear what the key should be for other algorithms like SHA3-256. It's probably sha3-256? sha3256 definitely doesn't seem right.

I've also noticed that some algorithms that shouldn't be ambiguous are made ambiguous by library implementations. For example, Python uses the ID shake_256 for the SHAKE256 algorithm and the ID ripemd160 for the RIPEMD-160 algorithm.

It would be helpful to have a list of standard hash algorithms with their correct keys.

@pombredanne
Copy link
Member

@matt-phylum what would be your recommendation?

@matt-phylum
Copy link
Contributor Author

  • BLAKE2b-256 blake2b-256 (used by pypi)
  • BLAKE3 blake3
  • MD5 md5 (used by pypi maven)
  • RIPEMD-160 ripemd160
  • SHAKE256 shake256
  • SHA1 sha1 (used by maven npm)
  • SHA2-224 sha224
  • SHA2-256 sha256 (used by cargo gem maven npm)
  • SHA2-384 sha384 (used by npm)
  • SHA2-512 sha512 (used by npm nuget)
  • SHA3-224 sha3-224
  • SHA3-256 sha3-256
  • SHA3-384 sha3-384
  • SHA3-512 sha3-512

blake3 and shake256 are variable length output algorithms.

Uncommon but similar algorithms like blake2b-512 or blake2s-256 may not need to be mentioned.

This is probably another topic, but NuGet packages and Go modules have their own specialized hashes and those should probably be documented or warned about somehow. For NuGet packages, sometimes the sha512 hash includes the attached signature file and sometimes it does not (the package identity must not change when the registry adds its own signature to this file). For Go, packages are conceptually distributed as directory hierarchies instead of flat files, so they have something called an h1 hash, which is an sha1 Merkle tree computed over the package content.

@matt-phylum
Copy link
Contributor Author

Related: #277

@johnmhoran johnmhoran added the PURL type definition Non-core definitions that describe and standardize PURL types label Oct 22, 2024
@johnmhoran johnmhoran added the Ecma specification Work on the core specification label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ecma specification Work on the core specification PURL type definition Non-core definitions that describe and standardize PURL types
Projects
None yet
Development

No branches or pull requests

3 participants