first working version !

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-OpenPGP@5123 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2012-04-26 21:39:45 +00:00
parent afc23f39c8
commit 42687f32aa
2 changed files with 19 additions and 6 deletions

View File

@ -691,10 +691,7 @@ bool PGPHandler::VerifySignBin(const void *literal_data, uint32_t literal_data_l
return false ; return false ;
} }
std::cerr << "Verifying signature from fingerprint " << key_fingerprint.toStdString() << std::endl; std::cerr << "Verifying signature from fingerprint " << key_fingerprint.toStdString() << ", length " << std::dec << sign_len << ", literal data length = " << literal_data_length << 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;
return ops_validate_detached_signature(literal_data,literal_data_length,sign,sign_len,key) ; 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) bool PGPHandler::isGPGAccepted(const std::string &id)
{ {
std::map<std::string,PGPCertificateInfo>::const_iterator res = _public_keyring_map.find(id) ; std::map<std::string,PGPCertificateInfo>::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) ;
} }

View File

@ -585,6 +585,12 @@ bool AuthGPG::DoOwnSignature(const void *data, unsigned int datalen, void *buf_s
/* import to GnuPG and other Certificates */ /* import to GnuPG and other Certificates */
bool AuthGPG::VerifySignature(const void *data, int datalen, const void *sig, unsigned int siglen, const std::string &withfingerprint) 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)) ; 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 */ /**** These Two are common */
std::string AuthGPG::getGPGName(const std::string &id) 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 ******/ RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
const PGPCertificateInfo *info = PGPHandler::getCertificateInfo(PGPIdType::fromUserId_hex(id)) ; const PGPCertificateInfo *info = PGPHandler::getCertificateInfo(PGPIdType::fromUserId_hex(id)) ;
@ -646,7 +657,6 @@ std::string AuthGPG::getGPGOwnId()
std::string AuthGPG::getGPGOwnName() std::string AuthGPG::getGPGOwnName()
{ {
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/
return getGPGName(mOwnGpgId.toStdString()) ; return getGPGName(mOwnGpgId.toStdString()) ;
} }
@ -707,6 +717,12 @@ bool AuthGPG::getGPGDetails(const std::string& id, RsPeerDetails &d)
{ {
RsStackMutex stack(gpgMtxData); /******* LOCKED ******/ 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)) ; const PGPCertificateInfo *pc = PGPHandler::getCertificateInfo(PGPIdType::fromUserId_hex(id)) ;
if(pc == NULL) if(pc == NULL)