about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-17T11·41+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-02-17T11·42+0100
commitb49d323ce2d8491cfe11d6941b1f048012eed23e (patch)
treed701907dbcdf679e1e9f32ed25c72bee2e72d9eb /src/libstore
parentc4d22997f364a7fc2e5a8150c0a4a55590a92df5 (diff)
Fix build without sodium
http://hydra.nixos.org/build/32085949
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/crypto.cc11
-rw-r--r--src/libstore/local-store.cc5
2 files changed, 11 insertions, 5 deletions
diff --git a/src/libstore/crypto.cc b/src/libstore/crypto.cc
index 18ff3f89dea4..c1b57e51d9b4 100644
--- a/src/libstore/crypto.cc
+++ b/src/libstore/crypto.cc
@@ -37,6 +37,11 @@ SecretKey::SecretKey(const string & s)
 #endif
 }
 
+[[noreturn]] static void noSodium()
+{
+    throw Error("Nix was not compiled with libsodium, required for signed binary cache support");
+}
+
 std::string SecretKey::signDetached(const std::string & data) const
 {
 #if HAVE_SODIUM
@@ -46,7 +51,7 @@ std::string SecretKey::signDetached(const std::string & data) const
         (unsigned char *) key.data());
     return name + ":" + base64Encode(std::string((char *) sig, sigLen));
 #else
-    throw Error("Nix was not compiled with libsodium, required for signed binary cache support");
+    noSodium();
 #endif
 }
 
@@ -62,6 +67,7 @@ PublicKey::PublicKey(const string & s)
 bool verifyDetached(const std::string & data, const std::string & sig,
     const PublicKeys & publicKeys)
 {
+#if HAVE_SODIUM
     auto ss = split(sig);
 
     auto key = publicKeys.find(ss.first);
@@ -74,6 +80,9 @@ bool verifyDetached(const std::string & data, const std::string & sig,
     return crypto_sign_verify_detached((unsigned char *) sig2.data(),
         (unsigned char *) data.data(), data.size(),
         (unsigned char *) key->second.key.data()) == 0;
+#else
+    noSodium();
+#endif
 }
 
 }
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index b2908877ce34..308aebd73bb4 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -40,10 +40,7 @@ MakeError(SQLiteError, Error);
 MakeError(SQLiteBusy, SQLiteError);
 
 
-static void throwSQLiteError(sqlite3 * db, const format & f)
-    __attribute__ ((noreturn));
-
-static void throwSQLiteError(sqlite3 * db, const format & f)
+[[noreturn]] static void throwSQLiteError(sqlite3 * db, const format & f)
 {
     int err = sqlite3_errcode(db);
     if (err == SQLITE_BUSY || err == SQLITE_PROTOCOL) {