mirror of
https://github.com/NixOS/nix.git
synced 2025-12-06 00:51:00 +01:00
Implement support for Git hashing with SHA-256
SHA-256 is Git's next hash algorithm. The world is still basically stuck on SHA-1 with git, but shouldn't be. We can at least do our part to get ready. On the C++ implementation side, only a little bit of generalization was needed, and that was fairly straight-forward. The tests (unit and system) were actually bigger, and care was taken to make sure they were all cover both algorithms equally.
This commit is contained in:
parent
7f4acb9f10
commit
d21e3f88ec
20 changed files with 350 additions and 181 deletions
|
|
@ -20,23 +20,6 @@
|
|||
|
||||
namespace nix {
|
||||
|
||||
static size_t regularHashSize(HashAlgorithm type)
|
||||
{
|
||||
switch (type) {
|
||||
case HashAlgorithm::BLAKE3:
|
||||
return blake3HashSize;
|
||||
case HashAlgorithm::MD5:
|
||||
return md5HashSize;
|
||||
case HashAlgorithm::SHA1:
|
||||
return sha1HashSize;
|
||||
case HashAlgorithm::SHA256:
|
||||
return sha256HashSize;
|
||||
case HashAlgorithm::SHA512:
|
||||
return sha512HashSize;
|
||||
}
|
||||
unreachable();
|
||||
}
|
||||
|
||||
const StringSet hashAlgorithms = {"blake3", "md5", "sha1", "sha256", "sha512"};
|
||||
|
||||
const StringSet hashFormats = {"base64", "nix32", "base16", "sri"};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue