diff options
Diffstat (limited to 'perl/lib/Nix/Store.xs')
-rw-r--r-- | perl/lib/Nix/Store.xs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/perl/lib/Nix/Store.xs b/perl/lib/Nix/Store.xs index 5a1e8424f036..44c88a87bfc6 100644 --- a/perl/lib/Nix/Store.xs +++ b/perl/lib/Nix/Store.xs @@ -10,6 +10,7 @@ #include "globals.hh" #include "store-api.hh" #include "util.hh" +#include "crypto.hh" #if HAVE_SODIUM #include <sodium.h> @@ -108,7 +109,7 @@ SV * queryPathInfo(char * path, int base32) XPUSHs(&PL_sv_undef); else XPUSHs(sv_2mortal(newSVpv(info.deriver.c_str(), 0))); - string s = "sha256:" + (base32 ? printHash32(info.hash) : printHash(info.hash)); + string s = "sha256:" + (base32 ? printHash32(info.narHash) : printHash(info.narHash)); XPUSHs(sv_2mortal(newSVpv(s.c_str(), 0))); mXPUSHi(info.registrationTime); mXPUSHi(info.narSize); @@ -160,6 +161,7 @@ SV * topoSortPaths(...) SV * followLinksToStorePath(char * path) CODE: try { + store(); RETVAL = newSVpv(followLinksToStorePath(path).c_str(), 0); } catch (Error & e) { croak("%s", e.what()); @@ -234,19 +236,12 @@ SV * convertHash(char * algo, char * s, int toBase32) } -SV * signString(SV * secretKey_, char * msg) +SV * signString(char * secretKey_, char * msg) PPCODE: try { #if HAVE_SODIUM - STRLEN secretKeyLen; - unsigned char * secretKey = (unsigned char *) SvPV(secretKey_, secretKeyLen); - if (secretKeyLen != crypto_sign_SECRETKEYBYTES) - throw Error("secret key is not valid"); - - unsigned char sig[crypto_sign_BYTES]; - unsigned long long sigLen; - crypto_sign_detached(sig, &sigLen, (unsigned char *) msg, strlen(msg), secretKey); - XPUSHs(sv_2mortal(newSVpv((char *) sig, sigLen))); + auto sig = SecretKey(secretKey_).signDetached(msg); + XPUSHs(sv_2mortal(newSVpv(sig.c_str(), sig.size()))); #else throw Error("Nix was not compiled with libsodium, required for signed binary cache support"); #endif |