mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Handle base-16 NarHash fields in signed .narinfo files
This commit is contained in:
parent
a64da5915d
commit
94378910fb
3 changed files with 17 additions and 3 deletions
|
@ -395,12 +395,15 @@ sub deleteOldManifests {
|
||||||
|
|
||||||
|
|
||||||
# Return a fingerprint of a store path to be used in binary cache
|
# Return a fingerprint of a store path to be used in binary cache
|
||||||
# signatures. It contains the store path, the SHA-256 hash of the
|
# signatures. It contains the store path, the base-32 SHA-256 hash of
|
||||||
# contents of the path, and the references.
|
# the contents of the path, and the references.
|
||||||
sub fingerprintPath {
|
sub fingerprintPath {
|
||||||
my ($storePath, $narHash, $narSize, $references) = @_;
|
my ($storePath, $narHash, $narSize, $references) = @_;
|
||||||
die if substr($storePath, 0, length($Nix::Config::storeDir)) ne $Nix::Config::storeDir;
|
die if substr($storePath, 0, length($Nix::Config::storeDir)) ne $Nix::Config::storeDir;
|
||||||
die if substr($narHash, 0, 7) ne "sha256:";
|
die if substr($narHash, 0, 7) ne "sha256:";
|
||||||
|
# Convert hash from base-16 to base-32, if necessary.
|
||||||
|
$narHash = "sha256:" . convertHash("sha256", substr($narHash, 7), 1)
|
||||||
|
if length($narHash) == 71;
|
||||||
die if length($narHash) != 59;
|
die if length($narHash) != 59;
|
||||||
foreach my $ref (@{$references}) {
|
foreach my $ref (@{$references}) {
|
||||||
die if substr($ref, 0, length($Nix::Config::storeDir)) ne $Nix::Config::storeDir;
|
die if substr($ref, 0, length($Nix::Config::storeDir)) ne $Nix::Config::storeDir;
|
||||||
|
|
|
@ -17,7 +17,7 @@ our @EXPORT = qw(
|
||||||
isValidPath queryReferences queryPathInfo queryDeriver queryPathHash
|
isValidPath queryReferences queryPathInfo queryDeriver queryPathHash
|
||||||
queryPathFromHashPart
|
queryPathFromHashPart
|
||||||
topoSortPaths computeFSClosure followLinksToStorePath exportPaths importPaths
|
topoSortPaths computeFSClosure followLinksToStorePath exportPaths importPaths
|
||||||
hashPath hashFile hashString
|
hashPath hashFile hashString convertHash
|
||||||
signString checkSignature
|
signString checkSignature
|
||||||
addToStore makeFixedOutputPath
|
addToStore makeFixedOutputPath
|
||||||
derivationFromPath
|
derivationFromPath
|
||||||
|
|
|
@ -232,6 +232,17 @@ SV * hashString(char * algo, int base32, char * s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SV * convertHash(char * algo, char * s, int toBase32)
|
||||||
|
PPCODE:
|
||||||
|
try {
|
||||||
|
Hash h = parseHash16or32(parseHashType(algo), s);
|
||||||
|
string s = toBase32 ? printHash32(h) : printHash(h);
|
||||||
|
XPUSHs(sv_2mortal(newSVpv(s.c_str(), 0)));
|
||||||
|
} catch (Error & e) {
|
||||||
|
croak(e.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SV * signString(SV * secretKey_, char * msg)
|
SV * signString(SV * secretKey_, char * msg)
|
||||||
PPCODE:
|
PPCODE:
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue