From 40f7399d48637096dac6fcb1861a5ea20dae1bf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= Date: Fri, 21 Aug 2015 14:36:59 -0400 Subject: [PATCH] value: encypted value is not signed (until decrypted) --- include/opendht/value.h | 2 +- src/securedht.cpp | 4 ++-- src/value.cpp | 7 ++----- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/include/opendht/value.h b/include/opendht/value.h index f17c4bb5..8f98737a 100644 --- a/include/opendht/value.h +++ b/include/opendht/value.h @@ -283,7 +283,7 @@ struct Value return not cypher.empty(); } bool isSigned() const { - return isEncrypted() or not signature.empty(); + return not signature.empty(); } Value() {} diff --git a/src/securedht.cpp b/src/securedht.cpp index efca552f..5ee1e2fd 100644 --- a/src/securedht.cpp +++ b/src/securedht.cpp @@ -104,7 +104,7 @@ ValueType SecureDht::secureType(ValueType&& type) { type.storePolicy = [this,type](InfoHash id, std::shared_ptr& v, InfoHash nid, const sockaddr* a, socklen_t al) { - if (v->isSigned() && !v->isEncrypted()) { + if (v->isSigned()) { if (!v->owner.checkSignature(v->getToSign(), v->signature)) { DHT_WARN("Signature verification failed"); return false; @@ -115,7 +115,7 @@ SecureDht::secureType(ValueType&& type) return type.storePolicy(id, v, nid, a, al); }; type.editPolicy = [this,type](InfoHash id, const std::shared_ptr& o, std::shared_ptr& n, InfoHash nid, const sockaddr* a, socklen_t al) { - if (!o->isSigned() || o->isEncrypted()) + if (!o->isSigned()) return type.editPolicy(id, o, n, nid, a, al); if (o->owner != n->owner) { DHT_WARN("Edition forbidden: owner changed."); diff --git a/src/value.cpp b/src/value.cpp index d34c653d..c8076182 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -38,14 +38,11 @@ namespace dht { std::ostream& operator<< (std::ostream& s, const Value& v) { s << "Value[id:" << std::hex << v.id << std::dec << " "; - if (v.isSigned()) - s << "signed (v" << v.seq << ") "; if (v.isEncrypted()) s << "encrypted "; else if (v.isSigned()) { - if (v.recipient == InfoHash()) - s << "signed (v" << v.seq << ") "; - else + s << "signed (v" << v.seq << ") "; + if (v.recipient != InfoHash()) s << "decrypted "; } if (not v.isEncrypted()) {