aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/crypto.cc
diff options
context:
space:
mode:
authorjade <lix@jade.fyi>2024-08-08 23:09:30 +0000
committerGerrit Code Review <gerrit@localhost>2024-08-08 23:09:30 +0000
commit9682ab4f3859ca60b0b4525452b27297e31cb751 (patch)
tree140cf7817556db65c80693f8b89a76c722b6d726 /src/libstore/crypto.cc
parent757041c3e74787c755b3de826078968119f706d6 (diff)
parenta5f0954c290157875b4dfb79edcf651f55742dc2 (diff)
Merge changes I6358a393,I2d9f276b,Idd096dc9 into main
* changes: clang-tidy: write a lint for charptr_cast tree-wide: automated migration to charptr_cast clang-tidy: enforce the new rules
Diffstat (limited to 'src/libstore/crypto.cc')
-rw-r--r--src/libstore/crypto.cc13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/libstore/crypto.cc b/src/libstore/crypto.cc
index e8ab15537..6f4a36735 100644
--- a/src/libstore/crypto.cc
+++ b/src/libstore/crypto.cc
@@ -1,3 +1,4 @@
+#include "charptr-cast.hh"
#include "crypto.hh"
#include "file-system.hh"
#include "globals.hh"
@@ -44,15 +45,15 @@ std::string SecretKey::signDetached(std::string_view data) const
{
unsigned char sig[crypto_sign_BYTES];
unsigned long long sigLen;
- crypto_sign_detached(sig, &sigLen, reinterpret_cast<const unsigned char *>(data.data()), data.size(),
- reinterpret_cast<const unsigned char *>(key.data()));
+ crypto_sign_detached(sig, &sigLen, charptr_cast<const unsigned char *>(data.data()), data.size(),
+ charptr_cast<const unsigned char *>(key.data()));
return name + ":" + base64Encode(std::string(reinterpret_cast<char *>(sig), sigLen));
}
PublicKey SecretKey::toPublicKey() const
{
unsigned char pk[crypto_sign_PUBLICKEYBYTES];
- crypto_sign_ed25519_sk_to_pk(pk, reinterpret_cast<const unsigned char *>(key.data()));
+ crypto_sign_ed25519_sk_to_pk(pk, charptr_cast<const unsigned char *>(key.data()));
return PublicKey(name, std::string(reinterpret_cast<char *>(pk), crypto_sign_PUBLICKEYBYTES));
}
@@ -85,9 +86,9 @@ bool verifyDetached(const std::string & data, const std::string & sig,
if (sig2.size() != crypto_sign_BYTES)
throw Error("signature is not valid");
- return crypto_sign_verify_detached(reinterpret_cast<unsigned char *>(sig2.data()),
- reinterpret_cast<const unsigned char *>(data.data()), data.size(),
- reinterpret_cast<const unsigned char *>(key->second.key.data())) == 0;
+ return crypto_sign_verify_detached(charptr_cast<unsigned char *>(sig2.data()),
+ charptr_cast<const unsigned char *>(data.data()), data.size(),
+ charptr_cast<const unsigned char *>(key->second.key.data())) == 0;
}
PublicKeys getDefaultPublicKeys()