mirror of
https://github.com/NixOS/nix
synced 2025-06-27 08:31:16 +02:00
Move signature support from NarInfo to ValidPathInfo
This commit is contained in:
parent
11525377e1
commit
374198ad6d
4 changed files with 43 additions and 39 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "store-api.hh"
|
||||
#include "crypto.hh"
|
||||
#include "globals.hh"
|
||||
#include "store-api.hh"
|
||||
#include "util.hh"
|
||||
|
||||
|
||||
|
@ -309,6 +310,32 @@ void Store::exportPaths(const Paths & paths,
|
|||
}
|
||||
|
||||
|
||||
std::string ValidPathInfo::fingerprint() const
|
||||
{
|
||||
return
|
||||
"1;" + path + ";"
|
||||
+ printHashType(narHash.type) + ":" + printHash32(narHash) + ";"
|
||||
+ std::to_string(narSize) + ";"
|
||||
+ concatStringsSep(",", references);
|
||||
}
|
||||
|
||||
|
||||
void ValidPathInfo::sign(const SecretKey & secretKey)
|
||||
{
|
||||
sigs.insert(secretKey.signDetached(fingerprint()));
|
||||
}
|
||||
|
||||
|
||||
unsigned int ValidPathInfo::checkSignatures(const PublicKeys & publicKeys) const
|
||||
{
|
||||
unsigned int good = 0;
|
||||
for (auto & sig : sigs)
|
||||
if (verifyDetached(fingerprint(), sig, publicKeys))
|
||||
good++;
|
||||
return good;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue