mirror of
https://github.com/NixOS/nix
synced 2025-07-02 13:31:48 +02:00
Signer infrastructure: Prep for #9076
This sets up infrastructure in libutil to allow for signing other than by a secret key in memory. #9076 uses this to implement remote signing. (Split from that PR to allow reviewing in smaller chunks.) Co-Authored-By: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
315aade89d
commit
12bb8cdd38
24 changed files with 233 additions and 70 deletions
|
@ -14,6 +14,8 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <sodium.h>
|
||||
|
||||
namespace nix {
|
||||
|
||||
static size_t regularHashSize(HashAlgorithm type) {
|
||||
|
@ -261,6 +263,13 @@ Hash::Hash(std::string_view rest, HashAlgorithm algo, bool isSRI)
|
|||
throw BadHash("hash '%s' has wrong length for hash algorithm '%s'", rest, printHashAlgo(this->algo));
|
||||
}
|
||||
|
||||
Hash Hash::random(HashAlgorithm algo)
|
||||
{
|
||||
Hash hash(algo);
|
||||
randombytes_buf(hash.hash, hash.hashSize);
|
||||
return hash;
|
||||
}
|
||||
|
||||
Hash newHashAllowEmpty(std::string_view hashStr, std::optional<HashAlgorithm> ha)
|
||||
{
|
||||
if (hashStr.empty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue