From 42687f32aab6ee3edd93cdeda25c08b50a775bd3 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 26 Apr 2012 21:39:45 +0000 Subject: [PATCH] first working version ! git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-OpenPGP@5123 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pgp/pgphandler.cc | 7 ++----- libretroshare/src/pqi/authgpg.cc | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/libretroshare/src/pgp/pgphandler.cc b/libretroshare/src/pgp/pgphandler.cc index 5ff091244..a43456c0d 100644 --- a/libretroshare/src/pgp/pgphandler.cc +++ b/libretroshare/src/pgp/pgphandler.cc @@ -691,10 +691,7 @@ bool PGPHandler::VerifySignBin(const void *literal_data, uint32_t literal_data_l return false ; } - std::cerr << "Verifying signature from fingerprint " << key_fingerprint.toStdString() << std::endl; - - std::cerr << "Verifying signature of length " << std::dec << sign_len << ", literal_length = " << literal_data_length << std::endl; - std::cerr << "Data: " << (char *)sign << std::endl; + std::cerr << "Verifying signature from fingerprint " << key_fingerprint.toStdString() << ", length " << std::dec << sign_len << ", literal data length = " << literal_data_length << std::endl; return ops_validate_detached_signature(literal_data,literal_data_length,sign,sign_len,key) ; } @@ -735,6 +732,6 @@ bool PGPHandler::isGPGSigned(const std::string &id) bool PGPHandler::isGPGAccepted(const std::string &id) { std::map::const_iterator res = _public_keyring_map.find(id) ; - return (res != _public_keyring_map.end()) && (res->second._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_OWN_SIGNATURE) ; + return (res != _public_keyring_map.end()) && (res->second._flags & PGPCertificateInfo::PGP_CERTIFICATE_FLAG_ACCEPT_CONNEXION) ; } diff --git a/libretroshare/src/pqi/authgpg.cc b/libretroshare/src/pqi/authgpg.cc index 36246477a..83b793501 100644 --- a/libretroshare/src/pqi/authgpg.cc +++ b/libretroshare/src/pqi/authgpg.cc @@ -585,6 +585,12 @@ bool AuthGPG::DoOwnSignature(const void *data, unsigned int datalen, void *buf_s /* import to GnuPG and other Certificates */ bool AuthGPG::VerifySignature(const void *data, int datalen, const void *sig, unsigned int siglen, const std::string &withfingerprint) { + if(withfingerprint.length() != 40) + { + std::cerr << "WARNING: Still need to implement signature verification from complete keyring." << std::endl; + return false ; + } + return PGPHandler::VerifySignBin((unsigned char*)data,datalen,(unsigned char*)sig,siglen,PGPFingerprintType::fromFingerprint_hex(withfingerprint)) ; } @@ -614,6 +620,11 @@ bool AuthGPG::GeneratePGPCertificate(const std::string& name, /**** These Two are common */ std::string AuthGPG::getGPGName(const std::string &id) { + if(id.length() != 16) + { + std::cerr << "Wrong string passed to getGPGDetails: \"" << id << "\"" << std::endl; + return std::string() ; + } RsStackMutex stack(gpgMtxData); /******* LOCKED ******/ const PGPCertificateInfo *info = PGPHandler::getCertificateInfo(PGPIdType::fromUserId_hex(id)) ; @@ -646,7 +657,6 @@ std::string AuthGPG::getGPGOwnId() std::string AuthGPG::getGPGOwnName() { - RsStackMutex stack(gpgMtxData); /******* LOCKED ******/ return getGPGName(mOwnGpgId.toStdString()) ; } @@ -707,6 +717,12 @@ bool AuthGPG::getGPGDetails(const std::string& id, RsPeerDetails &d) { RsStackMutex stack(gpgMtxData); /******* LOCKED ******/ + if(id.length() != 16) + { + std::cerr << "Wrong string passed to getGPGDetails: \"" << id << "\"" << std::endl; + return false ; + } + const PGPCertificateInfo *pc = PGPHandler::getCertificateInfo(PGPIdType::fromUserId_hex(id)) ; if(pc == NULL)