aboutsummaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2021-02-25 20:35:11 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2021-02-25 21:51:05 +0000
commitca0994819d68aee26a2906c37a47ae609ac46c4c (patch)
treec96805c008c22926b1eaadc340a99323d53be532 /perl
parent10e81bf871551901ff0383bdede0f79325e93867 (diff)
parentc189031e8be0530d73a817571ad7f81ad5eedce6 (diff)
Merge remote-tracking branch 'upstream/master' into path-info
Diffstat (limited to 'perl')
-rw-r--r--perl/Makefile.config.in1
-rw-r--r--perl/configure.ac6
-rw-r--r--perl/lib/Nix/Store.xs20
3 files changed, 8 insertions, 19 deletions
diff --git a/perl/Makefile.config.in b/perl/Makefile.config.in
index c87d4817e..eccfbd9f6 100644
--- a/perl/Makefile.config.in
+++ b/perl/Makefile.config.in
@@ -2,7 +2,6 @@ CC = @CC@
CFLAGS = @CFLAGS@
CXX = @CXX@
CXXFLAGS = @CXXFLAGS@
-HAVE_SODIUM = @HAVE_SODIUM@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
SODIUM_LIBS = @SODIUM_LIBS@
diff --git a/perl/configure.ac b/perl/configure.ac
index 255744afd..85183c005 100644
--- a/perl/configure.ac
+++ b/perl/configure.ac
@@ -40,11 +40,7 @@ AC_SUBST(perllibdir, [${libdir}/perl5/site_perl/$perlversion/$perlarchname])
AC_MSG_RESULT($perllibdir)
# Look for libsodium, an optional dependency.
-PKG_CHECK_MODULES([SODIUM], [libsodium],
- [AC_DEFINE([HAVE_SODIUM], [1], [Whether to use libsodium for cryptography.])
- CXXFLAGS="$SODIUM_CFLAGS $CXXFLAGS"
- have_sodium=1], [have_sodium=])
-AC_SUBST(HAVE_SODIUM, [$have_sodium])
+PKG_CHECK_MODULES([SODIUM], [libsodium], [CXXFLAGS="$SODIUM_CFLAGS $CXXFLAGS"])
# Check for the required Perl dependencies (DBI and DBD::SQLite).
perlFlags="-I$perllibdir"
diff --git a/perl/lib/Nix/Store.xs b/perl/lib/Nix/Store.xs
index ea8bbaf34..4a9df2ae2 100644
--- a/perl/lib/Nix/Store.xs
+++ b/perl/lib/Nix/Store.xs
@@ -14,9 +14,7 @@
#include "util.hh"
#include "crypto.hh"
-#if HAVE_SODIUM
#include <sodium.h>
-#endif
using namespace nix;
@@ -110,10 +108,14 @@ SV * queryPathInfo(char * path, int base32)
XPUSHs(sv_2mortal(newSVpv(s.c_str(), 0)));
mXPUSHi(info->registrationTime);
mXPUSHi(info->narSize);
- AV * arr = newAV();
+ AV * refs = newAV();
for (auto & i : info->referencesPossiblyToSelf())
- av_push(arr, newSVpv(store()->printStorePath(i).c_str(), 0));
- XPUSHs(sv_2mortal(newRV((SV *) arr)));
+ av_push(refs, newSVpv(store()->printStorePath(i).c_str(), 0));
+ XPUSHs(sv_2mortal(newRV((SV *) refs)));
+ AV * sigs = newAV();
+ for (auto & i : info->sigs)
+ av_push(sigs, newSVpv(i.c_str(), 0));
+ XPUSHs(sv_2mortal(newRV((SV *) sigs)));
} catch (Error & e) {
croak("%s", e.what());
}
@@ -235,12 +237,8 @@ SV * convertHash(char * algo, char * s, int toBase32)
SV * signString(char * secretKey_, char * msg)
PPCODE:
try {
-#if HAVE_SODIUM
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
} catch (Error & e) {
croak("%s", e.what());
}
@@ -249,7 +247,6 @@ SV * signString(char * secretKey_, char * msg)
int checkSignature(SV * publicKey_, SV * sig_, char * msg)
CODE:
try {
-#if HAVE_SODIUM
STRLEN publicKeyLen;
unsigned char * publicKey = (unsigned char *) SvPV(publicKey_, publicKeyLen);
if (publicKeyLen != crypto_sign_PUBLICKEYBYTES)
@@ -261,9 +258,6 @@ int checkSignature(SV * publicKey_, SV * sig_, char * msg)
throw Error("signature is not valid");
RETVAL = crypto_sign_verify_detached(sig, (unsigned char *) msg, strlen(msg), publicKey) == 0;
-#else
- throw Error("Nix was not compiled with libsodium, required for signed binary cache support");
-#endif
} catch (Error & e) {
croak("%s", e.what());
}