mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 04:21:51 +00:00
value: cleanup, move sign & encrypt to cpp
This commit is contained in:
1 parent
56442acc84
commit
5f743344e5
2 files changed
+25
-17
No files matched your search
@@ -254,6 +254,27 @@ unpackId(const Json::Value& json, const std::string& key) {
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
Value::sign(const crypto::PrivateKey& key)
|
||||
{
|
||||
if (isEncrypted())
|
||||
throw DhtException("Can't sign encrypted data.");
|
||||
owner = key.getSharedPublicKey();
|
||||
signature = key.sign(getToSign());
|
||||
}
|
||||
|
||||
Value
|
||||
Value::encrypt(const crypto::PrivateKey& from, const crypto::PublicKey& to)
|
||||
{
|
||||
if (isEncrypted())
|
||||
throw DhtException("Data is already encrypted.");
|
||||
setRecipient(to.getId());
|
||||
sign(from);
|
||||
Value nv {id};
|
||||
nv.setCypher(to.encrypt(getToEncrypt()));
|
||||
return nv;
|
||||
}
|
||||
|
||||
bool
|
||||
Value::checkSignature()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user