about summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2015-02-04T16·59+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2015-02-04T16·59+0100
commitf3a5930488e4a25de33d9aacc2e14ae614614b5e (patch)
tree2001e1e3a2de740642b112ac6385ad3b09dc28ab /scripts
parente0def5bc4b41ad09ce3f188bf522814ef3389e1f (diff)
Sign a subset of the .narinfo
We only need to sign the store path, NAR hash and references (the
"fingerprint"). Everything else is irrelevant to security. For
instance, the compression algorithm or the hash of the compressed NAR
don't matter as long as the contents of the uncompressed NAR are
correct.

(Maybe we should include derivers in the fingerprint, but they're
broken and nobody cares about them. Also, it might be nice in the
future if .narinfos contained signatures from multiple independent
signers. But that's impossible if the deriver is included in the
fingerprint, since everybody will tend to have a different deriver for
the same store path.)

Also renamed the "Signature" field to "Sig" since the format changed
in an incompatible way.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/nix-push.in5
1 files changed, 3 insertions, 2 deletions
diff --git a/scripts/nix-push.in b/scripts/nix-push.in
index 0e90ab3c21..a060ea128f 100755
--- a/scripts/nix-push.in
+++ b/scripts/nix-push.in
@@ -257,8 +257,9 @@ for (my $n = 0; $n < scalar @storePaths2; $n++) {
         chomp $s;
         my ($keyName, $secretKey) = split ":", $s;
         die "invalid secret key file ‘$secretKeyFile’\n" unless defined $keyName && defined $secretKey;
-        my $sig = encode_base64(signString(decode_base64($secretKey), $info), "");
-        $info .= "Signature: 2;$keyName;$sig\n";
+        my $fingerprint = fingerprintPath($storePath, $narHash, $refs);
+        my $sig = encode_base64(signString(decode_base64($secretKey), $fingerprint), "");
+        $info .= "Sig: $keyName:$sig\n";
     }
 
     my $pathHash = substr(basename($storePath), 0, 32);