Add some documentation and fix some compiler warnings

This commit is contained in:
Gioacchino Mazzurco 2019-09-28 14:34:07 +02:00
parent 4e3ac4a9f4
commit 1e9adc1e23
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
2 changed files with 33 additions and 18 deletions

View File

@ -1581,24 +1581,25 @@ void PGPHandler::locked_updateOwnSignatureFlag(PGPCertificateInfo& cert,const Rs
cert._flags &= ~PGPCertificateInfo::PGP_CERTIFICATE_FLAG_HAS_SIGNED_ME ;
}
RsPgpId PGPHandler::pgpIdFromFingerprint(const PGPFingerprintType& f)
/*static*/ RsPgpId PGPHandler::pgpIdFromFingerprint(const RsPgpFingerprint& f)
{
return RsPgpId(f.toByteArray() + _RsIdSize::PGP_FINGERPRINT - _RsIdSize::PGP_ID);
return RsPgpId::fromBufferUnsafe(
f.toByteArray() +
RsPgpFingerprint::SIZE_IN_BYTES - RsPgpId::SIZE_IN_BYTES );
}
bool PGPHandler::getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const
bool PGPHandler::getKeyFingerprint(const RsPgpId& id, RsPgpFingerprint& fp) const
{
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
RS_STACK_MUTEX(pgphandlerMtx);
const ops_keydata_t *key = locked_getPublicKey(id,false) ;
if(key == NULL)
return false ;
if(!key) return false;
ops_fingerprint_t f ;
ops_fingerprint(&f,&key->key.pkey) ;
fp = PGPFingerprintType(f.fingerprint) ;
fp = RsPgpFingerprint::fromBufferUnsafe(f.fingerprint);
return true ;
}

View File

@ -79,7 +79,7 @@ class PGPCertificateInfo
/// This class offer an abstract pgp handler to be used in RetroShare.
class PGPHandler
{
public:
public:
PGPHandler( const std::string& path_to_public_keyring,
const std::string& path_to_secret_keyring,
const std::string& path_to_trust_database,
@ -124,7 +124,6 @@ class PGPHandler
bool encryptTextToFile(const RsPgpId& key_id,const std::string& text,const std::string& outfile) ;
bool decryptTextFromFile(const RsPgpId& key_id,std::string& text,const std::string& encrypted_inputfile) ;
bool getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const ;
void setAcceptConnexion(const RsPgpId&,bool) ;
void updateOwnSignatureFlag(const RsPgpId& ownId) ;
@ -148,14 +147,6 @@ class PGPHandler
const PGPCertificateInfo *getCertificateInfo(const RsPgpId& id) const ;
/**
* @brief Check if a PGP publick key is available
* @param id id of the key to check
* @return true if the public key for the given id is available,
* false otherwise
*/
bool isPgpPubKeyAvailable(const RsPgpId& id);
RS_DEPRECATED_FOR(isPgpPubKeyAvailable)
bool isGPGId(const RsPgpId &id);
bool isGPGSigned(const RsPgpId &id);
@ -163,7 +154,30 @@ class PGPHandler
static void setPassphraseCallback(PassphraseCallback cb) ;
static PassphraseCallback passphraseCallback() { return _passphrase_callback ; }
static RsPgpId pgpIdFromFingerprint(const PGPFingerprintType& f) ;
/**
* @brief Check if a PGP publick key is available
* @param id id of the key to check
* @return true if the public key for the given id is available,
* false otherwise
*/
bool isPgpPubKeyAvailable(const RsPgpId& id);
/**
* @brief Convert PGP fingerprint to PGP 64bit id
* @param f PGP fingerprint to convert
* @return PGP 64bit id extracted from fingerprint
*/
static RsPgpId pgpIdFromFingerprint(const RsPgpFingerprint& f);
/**
* @brief Get PGP fingerprint for the given key
* @param id PGP 64bit key id
* @param fp storage for the retrived key fingerpring, the contained value
* is meaningfull only if true is returned
* @return true if the key was found, false if not
*/
bool getKeyFingerprint(const RsPgpId& id, RsPgpFingerprint& fp) const;
// Gets info about the key. Who are the signers, what's the owner's name, etc.
//