mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-01 20:52:05 -04:00
Merged branch v0.5-OpenPGP into trunk:
User-level changes: ================== - libgpgme is not used anymore; it is replaced by a built-in piece of code called OpenPGP-SDK (http://openpgp.nominet.org.uk/cgi-bin/trac.cgi) that was improved to be used by RetroShare for handling PGP keys. - the gnupg keyring is not used anymore. Now, RetroShare has it's own gpg keyring, shared by all instances. On linux it's located in ~/.retroshare/pgp/. A lock system prevents multiple locations to read/write keyrings simultaneously. - the trust database from gnupg is not documented, so RetroShare cannot import it. This comes from the fact that the GPG standard (RFC4880) asks explicitly not to export trust information. So RetroShare has it's own trust DB shared by locations. This means you need to re-trust people. Sorry for that! - at start, if no keyring is found, RS will propose to copy the gnupg keyring to use your existing keys. Clicking on "OK" will do the copy, and you should find back all existing locations, except for DSA keys. - locations for which the suitable keypair is not in the keyring will not be displayed in the login window - locations for which the suitable keypair is not a RSA/RSA key will not be displayed. RetroShare does not support DSA/Elgamal keypairs yet. - a key import/export exchange function has been added in the certificate creation window (you go there from the login window by clicking on "manage keys/locations". This allows to easily create a new location with the same pgp key on another computer. To obtain a suitable keypair using gnupg, you need to concatenate the encrypted private key and the public key into an ascii file. This can be done using: gpg -a --export-secret-keys [your ID] > mykey.asc gpg -a --export [your ID] >> mykey.asc - importing a key with subkeys in not yet possible. Please remove subkeys before importing. - The code has been tested for a reasonnable amount of time, but it's not possible to prevent some new bugs to appear. Please report them asap supplying: call-stacks if possible, and terminal output. In particular, openpgp has some assert()'s that should not be triggered unless RetroShare is calling it in an improper way. Internal changes ================ - a specific component, PGPHandler, takes care of the interface between openpgp-sdk and RetroShare openpgp-sdk is c-code, with it's own memory management, which has been kept well separated from RetroShare. - GPG Ids are now a specific class (not a std::string anymore) for code consistency reasons. As strings are still used in many places, this requires a few conversions. In particular, AuthGPG takes strings as function params and calls GPGHandler with the proper PGPIdType class. In the future, RetroShare should only use PGPIdType. The same will be done for SSL ids. - signature cleaning is still handled by the Retroshare built-in function, not by openpgp, but we will do this later. Still to do =========== - DSA needs subkey handling, since the encryption is performed by a Elgamal subkey. Not sure this will be done. - GPGIds/SSLIds cleaning (meaning replace strings by appropriate types). Lots of confusion throughout the code in retroshare-gui in particular. - key removal from keyring. This is a challenge to keep locations synchronised. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5293 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
commit
fc8dfcf65b
109 changed files with 26549 additions and 2997 deletions
File diff suppressed because it is too large
Load diff
|
@ -50,6 +50,7 @@
|
|||
#include <set>
|
||||
#include <map>
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "pgp/pgphandler.h"
|
||||
|
||||
#define MAX_GPG_SIGNATURE_SIZE 4096
|
||||
|
||||
|
@ -57,39 +58,8 @@ class RsPeerDetails;
|
|||
|
||||
/*!
|
||||
* gpgcert is the identifier for a person.
|
||||
* It is a wrapper class for a GPGme OpenPGP certificate.
|
||||
* It is a wrapper class for a OpenPGP certificate.
|
||||
*/
|
||||
class AuthGPG;
|
||||
|
||||
class gpgcert
|
||||
{
|
||||
public:
|
||||
gpgcert();
|
||||
~gpgcert();
|
||||
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::string email;
|
||||
|
||||
std::string fpr; /* fingerprint */
|
||||
std::list<std::string> signers;
|
||||
|
||||
uint32_t trustLvl;
|
||||
uint32_t validLvl;
|
||||
|
||||
bool ownsign;
|
||||
|
||||
//This is not gpg, but RS data. A gpg peer can be accepted for connecting but not signed.
|
||||
bool accept_connection;
|
||||
|
||||
gpgme_key_t key;
|
||||
|
||||
// Cached Certificates...
|
||||
bool mHaveCachedCert;
|
||||
std::string mCachedCert;
|
||||
|
||||
|
||||
};
|
||||
|
||||
class AuthGPGOperation
|
||||
{
|
||||
|
@ -135,427 +105,289 @@ public:
|
|||
virtual void setGPGOperation(AuthGPGOperation *operation) = 0;
|
||||
};
|
||||
|
||||
/*!
|
||||
* The certificate map type
|
||||
*/
|
||||
typedef std::map<std::string, gpgcert> certmap;
|
||||
|
||||
//! provides basic gpg functionality
|
||||
/*!
|
||||
*
|
||||
* This provides retroshare basic gpg functionality and
|
||||
* key/web-of-trust management, also handle cert intialisation for retroshare
|
||||
*/
|
||||
|
||||
extern void AuthGPGInit();
|
||||
extern void AuthGPGExit();
|
||||
|
||||
class AuthGPG : public RsThread
|
||||
{
|
||||
|
||||
public:
|
||||
//AuthGPG();
|
||||
|
||||
static AuthGPG *getAuthGPG();
|
||||
|
||||
/**
|
||||
* @param ids list of gpg certificate ids (note, not the actual certificates)
|
||||
*/
|
||||
virtual bool availableGPGCertificatesWithPrivateKeys(std::list<std::string> &ids) = 0;
|
||||
virtual bool printKeys() = 0;
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 1 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 1: Initialisation.... As we are switching to OpenPGP the init functions
|
||||
* will be different. Just move the initialisation functions over....
|
||||
*
|
||||
* As GPGMe requires external calls to the GPG executable, which could potentially
|
||||
* be expensive, We'll want to cache the GPG keys in this class.
|
||||
* This should be done at initialisation, and saved in a map.
|
||||
* (see storage at the end of the class)
|
||||
*
|
||||
****/
|
||||
virtual bool active() = 0;
|
||||
|
||||
/* Initialize */
|
||||
virtual bool InitAuth () = 0;
|
||||
|
||||
/* Init by generating new Own PGP Cert, or selecting existing PGP Cert */
|
||||
virtual int GPGInit(const std::string &ownId) = 0;
|
||||
virtual bool CloseAuth() = 0;
|
||||
virtual bool GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &errString) = 0;
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 3 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 3: These are some of the most commonly used functions in Retroshare.
|
||||
*
|
||||
* More commonly used functions.
|
||||
*
|
||||
* provide access to details in cache list.
|
||||
*
|
||||
****/
|
||||
virtual std::string getGPGName(const std::string &pgp_id) = 0;
|
||||
virtual std::string getGPGEmail(const std::string &pgp_id) = 0;
|
||||
|
||||
/* PGP web of trust management */
|
||||
virtual std::string getGPGOwnId() = 0;
|
||||
virtual std::string getGPGOwnName() = 0;
|
||||
|
||||
//virtual std::string getGPGOwnEmail() = 0;
|
||||
virtual bool getGPGDetails(const std::string &id, RsPeerDetails &d) = 0;
|
||||
virtual bool getGPGAllList(std::list<std::string> &ids) = 0;
|
||||
virtual bool getGPGValidList(std::list<std::string> &ids) = 0;
|
||||
virtual bool getGPGAcceptedList(std::list<std::string> &ids) = 0;
|
||||
virtual bool getGPGSignedList(std::list<std::string> &ids) = 0;
|
||||
virtual bool isGPGValid(const std::string &id) = 0;
|
||||
virtual bool isGPGSigned(const std::string &id) = 0;
|
||||
virtual bool isGPGAccepted(const std::string &id) = 0;
|
||||
virtual bool isGPGId(const std::string &id) = 0;
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 4 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 4: Loading and Saving Certificates. (Strings and Files)
|
||||
*
|
||||
****/
|
||||
virtual bool LoadCertificateFromString(const std::string &pem, std::string &gpg_id,std::string& error_string) = 0;
|
||||
virtual std::string SaveCertificateToString(const std::string &id,bool include_signatures) = 0;
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 6 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 6: Authentication, Trust and Signing.
|
||||
*
|
||||
* This is some of the harder functions, but they should have been
|
||||
* done in gpgroot already.
|
||||
*
|
||||
****/
|
||||
|
||||
virtual bool AllowConnection(const std::string &gpg_id, bool accept) = 0;
|
||||
|
||||
virtual bool SignCertificateLevel0(const std::string &id) = 0;
|
||||
virtual bool RevokeCertificate(const std::string &id) = 0; /* Particularly hard - leave for later */
|
||||
//virtual bool TrustCertificateNone(std::string id) = 0;
|
||||
//virtual bool TrustCertificateMarginally(std::string id) = 0;
|
||||
//virtual bool TrustCertificateFully(std::string id) = 0;
|
||||
virtual bool TrustCertificate(const std::string &id, int trustlvl) = 0; //trustlvl is 2 for none, 3 for marginal and 4 for full trust
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 7 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 7: Signing Data.
|
||||
*
|
||||
* There should also be Encryption Functions... (do later).
|
||||
*
|
||||
****/
|
||||
//virtual bool SignData(std::string input, std::string &sign) = 0;
|
||||
//virtual bool SignData(const void *data, const uint32_t len, std::string &sign) = 0;
|
||||
//virtual bool SignDataBin(std::string input, unsigned char *sign, unsigned int *signlen) = 0;
|
||||
virtual bool SignDataBin(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen) = 0;
|
||||
virtual bool VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, const std::string &withfingerprint) = 0;
|
||||
virtual bool decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) = 0;
|
||||
virtual bool encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) = 0;
|
||||
//END of PGP public functions
|
||||
|
||||
/* GPG service */
|
||||
virtual bool addService(AuthGPGService *service) = 0;
|
||||
|
||||
};
|
||||
|
||||
/* The real implementation! */
|
||||
|
||||
|
||||
class AuthGPGimpl : public AuthGPG, public p3Config
|
||||
class AuthGPG: public p3Config, public RsThread, public PGPHandler
|
||||
{
|
||||
public:
|
||||
|
||||
AuthGPGimpl();
|
||||
~AuthGPGimpl();
|
||||
static void init( const std::string& path_to_pubring,
|
||||
const std::string& path_to_secring,
|
||||
const std::string& path_to_trustdb,
|
||||
const std::string& pgp_lock_file);
|
||||
|
||||
/**
|
||||
* @param ids list of gpg certificate ids (note, not the actual certificates)
|
||||
*/
|
||||
virtual bool availableGPGCertificatesWithPrivateKeys(std::list<std::string> &ids);
|
||||
static void exit();
|
||||
static AuthGPG *getAuthGPG() { return _instance ; }
|
||||
|
||||
virtual bool printKeys();
|
||||
/**
|
||||
* @param ids list of gpg certificate ids (note, not the actual certificates)
|
||||
*/
|
||||
virtual bool availableGPGCertificatesWithPrivateKeys(std::list<std::string> &ids);
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 1 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 1: Initialisation.... As we are switching to OpenPGP the init functions
|
||||
* will be different. Just move the initialisation functions over....
|
||||
*
|
||||
* As GPGMe requires external calls to the GPG executable, which could potentially
|
||||
* be expensive, We'll want to cache the GPG keys in this class.
|
||||
* This should be done at initialisation, and saved in a map.
|
||||
* (see storage at the end of the class)
|
||||
*
|
||||
****/
|
||||
virtual bool active();
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 1 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 1: Initialisation.... As we are switching to OpenPGP the init functions
|
||||
* will be different. Just move the initialisation functions over....
|
||||
*
|
||||
* As GPGMe requires external calls to the GPG executable, which could potentially
|
||||
* be expensive, We'll want to cache the GPG keys in this class.
|
||||
* This should be done at initialisation, and saved in a map.
|
||||
* (see storage at the end of the class)
|
||||
*
|
||||
****/
|
||||
virtual bool active();
|
||||
|
||||
/* Initialize */
|
||||
virtual bool InitAuth ();
|
||||
// /* Initialize */
|
||||
// virtual bool InitAuth ();
|
||||
// virtual bool CloseAuth();
|
||||
|
||||
/* Init by generating new Own PGP Cert, or selecting existing PGP Cert */
|
||||
virtual int GPGInit(const std::string &ownId);
|
||||
virtual bool CloseAuth();
|
||||
virtual bool GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &errString);
|
||||
/* Init by generating new Own PGP Cert, or selecting existing PGP Cert */
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 3 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 3: These are some of the most commonly used functions in Retroshare.
|
||||
*
|
||||
* More commonly used functions.
|
||||
*
|
||||
* provide access to details in cache list.
|
||||
*
|
||||
****/
|
||||
virtual std::string getGPGName(const std::string &pgp_id);
|
||||
virtual std::string getGPGEmail(const std::string &pgp_id);
|
||||
virtual int GPGInit(const std::string &ownId);
|
||||
virtual bool GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString);
|
||||
|
||||
/* PGP web of trust management */
|
||||
virtual std::string getGPGOwnId();
|
||||
virtual std::string getGPGOwnName();
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 3 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 3: These are some of the most commonly used functions in Retroshare.
|
||||
*
|
||||
* More commonly used functions.
|
||||
*
|
||||
* provide access to details in cache list.
|
||||
*
|
||||
****/
|
||||
virtual std::string getGPGName(const std::string &pgp_id,bool *success = NULL);
|
||||
virtual std::string getGPGEmail(const std::string &pgp_id,bool *success = NULL);
|
||||
|
||||
//virtual std::string getGPGOwnEmail();
|
||||
virtual bool getGPGDetails(const std::string &id, RsPeerDetails &d);
|
||||
virtual bool getGPGAllList(std::list<std::string> &ids);
|
||||
virtual bool getGPGValidList(std::list<std::string> &ids);
|
||||
virtual bool getGPGAcceptedList(std::list<std::string> &ids);
|
||||
virtual bool getGPGSignedList(std::list<std::string> &ids);
|
||||
virtual bool isGPGValid(const std::string &id);
|
||||
virtual bool isGPGSigned(const std::string &id);
|
||||
virtual bool isGPGAccepted(const std::string &id);
|
||||
virtual bool isGPGId(const std::string &id);
|
||||
/* PGP web of trust management */
|
||||
virtual std::string getGPGOwnId();
|
||||
virtual std::string getGPGOwnName();
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 4 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 4: Loading and Saving Certificates. (Strings and Files)
|
||||
*
|
||||
****/
|
||||
virtual bool LoadCertificateFromString(const std::string &pem, std::string &gpg_id,std::string& error_string);
|
||||
virtual std::string SaveCertificateToString(const std::string &id,bool include_signatures) ;
|
||||
//virtual std::string getGPGOwnEmail();
|
||||
virtual bool isKeySupported(const std::string &id) const ;
|
||||
virtual bool haveSecretKey(const std::string &id) const ;
|
||||
virtual bool getGPGDetails(const std::string &id, RsPeerDetails &d);
|
||||
virtual bool getGPGAllList(std::list<std::string> &ids);
|
||||
virtual bool getGPGValidList(std::list<std::string> &ids);
|
||||
virtual bool getGPGAcceptedList(std::list<std::string> &ids);
|
||||
virtual bool getGPGSignedList(std::list<std::string> &ids);
|
||||
virtual bool importProfile(const std::string& filename,std::string& gpg_id,std::string& import_error) ;
|
||||
virtual bool exportProfile(const std::string& filename,const std::string& gpg_id) ;
|
||||
|
||||
// Cached certificates.
|
||||
bool cacheGPGCertificate(const std::string &id, const std::string &certificate);
|
||||
bool getCachedGPGCertificate(const std::string &id, std::string &certificate);
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 4 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 4: Loading and Saving Certificates. (Strings and Files)
|
||||
*
|
||||
****/
|
||||
virtual bool LoadCertificateFromString(const std::string &pem, std::string &gpg_id,std::string& error_string);
|
||||
virtual std::string SaveCertificateToString(const std::string &id,bool include_signatures) ;
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 6 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 6: Authentication, Trust and Signing.
|
||||
*
|
||||
* This is some of the harder functions, but they should have been
|
||||
* done in gpgroot already.
|
||||
*
|
||||
****/
|
||||
virtual bool AllowConnection(const std::string &gpg_id, bool accept);
|
||||
// Cached certificates.
|
||||
bool getCachedGPGCertificate(const std::string &id, std::string &certificate);
|
||||
|
||||
virtual bool SignCertificateLevel0(const std::string &id);
|
||||
virtual bool RevokeCertificate(const std::string &id); /* Particularly hard - leave for later */
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 6 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 6: Authentication, Trust and Signing.
|
||||
*
|
||||
* This is some of the harder functions, but they should have been
|
||||
* done in gpgroot already.
|
||||
*
|
||||
****/
|
||||
virtual bool AllowConnection(const std::string &gpg_id, bool accept);
|
||||
|
||||
//virtual bool TrustCertificateNone(std::string id);
|
||||
//virtual bool TrustCertificateMarginally(std::string id);
|
||||
//virtual bool TrustCertificateFully(std::string id);
|
||||
virtual bool TrustCertificate(const std::string &id, int trustlvl); //trustlvl is 2 for none, 3 for marginal and 4 for full trust
|
||||
virtual bool SignCertificateLevel0(const std::string &id);
|
||||
virtual bool RevokeCertificate(const std::string &id); /* Particularly hard - leave for later */
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 7 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 7: Signing Data.
|
||||
*
|
||||
* There should also be Encryption Functions... (do later).
|
||||
*
|
||||
****/
|
||||
//virtual bool SignData(std::string input, std::string &sign);
|
||||
//virtual bool SignData(const void *data, const uint32_t len, std::string &sign);
|
||||
//virtual bool SignDataBin(std::string input, unsigned char *sign, unsigned int *signlen);
|
||||
virtual bool SignDataBin(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen);
|
||||
virtual bool VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, const std::string &withfingerprint);
|
||||
virtual bool decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN);
|
||||
virtual bool encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER);
|
||||
//END of PGP public functions
|
||||
virtual bool TrustCertificate(const std::string &id, int trustlvl); //trustlvl is 2 for none, 3 for marginal and 4 for full trust
|
||||
|
||||
/* GPG service */
|
||||
virtual bool addService(AuthGPGService *service);
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 7 ***********************************************/
|
||||
/*********************************************************************************/
|
||||
/*****
|
||||
* STAGE 7: Signing Data.
|
||||
*
|
||||
* There should also be Encryption Functions... (do later).
|
||||
*
|
||||
****/
|
||||
virtual bool SignDataBin(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen);
|
||||
virtual bool VerifySignBin(const void*, uint32_t, unsigned char*, unsigned int, const std::string &withfingerprint);
|
||||
|
||||
protected:
|
||||
/*****************************************************************/
|
||||
/*********************** p3config ******************************/
|
||||
/* Key Functions to be overloaded for Full Configuration */
|
||||
virtual RsSerialiser *setupSerialiser();
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
|
||||
virtual bool loadList(std::list<RsItem *>& load);
|
||||
/*****************************************************************/
|
||||
virtual bool decryptTextFromFile( std::string& text,const std::string& filename);
|
||||
virtual bool encryptTextToFile (const std::string& text,const std::string& filename);
|
||||
|
||||
bool getGPGFilteredList(std::list<std::string>& list,bool (*filter)(const PGPCertificateInfo&) = NULL) ;
|
||||
|
||||
//END of PGP public functions
|
||||
|
||||
/* GPG service */
|
||||
virtual bool addService(AuthGPGService *service) ;
|
||||
|
||||
protected:
|
||||
AuthGPG(const std::string& path_to_pubring, const std::string& path_to_secring,const std::string& path_to_trustdb,const std::string& pgp_lock_file);
|
||||
virtual ~AuthGPG();
|
||||
|
||||
/*****************************************************************/
|
||||
/*********************** p3config ******************************/
|
||||
/* Key Functions to be overloaded for Full Configuration */
|
||||
virtual RsSerialiser *setupSerialiser();
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
|
||||
virtual bool loadList(std::list<RsItem *>& load);
|
||||
/*****************************************************************/
|
||||
|
||||
private:
|
||||
|
||||
/* SKTAN */
|
||||
//void showData(gpgme_data_t dh);
|
||||
//void createDummyFriends(void); //NYI
|
||||
/* SKTAN */
|
||||
//void showData(gpgme_data_t dh);
|
||||
//void createDummyFriends(void); //NYI
|
||||
|
||||
/* Internal functions */
|
||||
bool DoOwnSignature(const void *, unsigned int, void *, unsigned int *);
|
||||
bool VerifySignature(const void *data, int datalen, const void *sig, unsigned int siglen, const std::string &withfingerprint);
|
||||
|
||||
/* Internal functions */
|
||||
bool DoOwnSignature(const void *, unsigned int, void *, unsigned int *);
|
||||
bool VerifySignature(const void *data, int datalen, const void *sig, unsigned int siglen, const std::string &withfingerprint);
|
||||
/* Sign/Trust stuff */
|
||||
int privateSignCertificate(const std::string &id);
|
||||
int privateRevokeCertificate(const std::string &id); /* revoke the signature on Certificate */
|
||||
int privateTrustCertificate(const std::string &id, int trustlvl);
|
||||
|
||||
/* Sign/Trust stuff */
|
||||
int privateSignCertificate(const std::string &id);
|
||||
int privateRevokeCertificate(const std::string &id); /* revoke the signature on Certificate */
|
||||
int privateTrustCertificate(const std::string &id, int trustlvl);
|
||||
// store all keys in map mKeyList to avoid calling gpgme exe repeatedly
|
||||
//bool storeAllKeys();
|
||||
//bool storeAllKeys_tick();
|
||||
|
||||
// store all keys in map mKeyList to avoid calling gpgme exe repeatedly
|
||||
bool storeAllKeys();
|
||||
bool storeAllKeys_tick();
|
||||
// Not used anymore
|
||||
// bool updateTrustAllKeys_locked();
|
||||
|
||||
// Not used anymore
|
||||
// bool updateTrustAllKeys_locked();
|
||||
/* GPG service */
|
||||
void processServices();
|
||||
|
||||
/* GPG service */
|
||||
void processServices();
|
||||
bool printAllKeys_locked();
|
||||
bool printOwnKeys_locked();
|
||||
|
||||
bool printAllKeys_locked();
|
||||
bool printOwnKeys_locked();
|
||||
/* own thread */
|
||||
virtual void run();
|
||||
|
||||
/* own thread */
|
||||
virtual void run();
|
||||
private:
|
||||
|
||||
private:
|
||||
static AuthGPG *instance_gpg; // pointeur vers le singleton
|
||||
|
||||
static AuthGPG *instance_gpg; // pointeur vers le singleton
|
||||
RsMutex gpgMtxService;
|
||||
RsMutex gpgMtxEngine;
|
||||
|
||||
RsMutex gpgMtxEngine;
|
||||
/* Below is protected via the mutex */
|
||||
/* Below is protected via the mutex */
|
||||
|
||||
gpgme_engine_info_t INFO;
|
||||
gpgme_ctx_t CTX;
|
||||
// gpgme_engine_info_t INFO;
|
||||
// gpgme_ctx_t CTX;
|
||||
|
||||
RsMutex gpgMtxData;
|
||||
/* Below is protected via the mutex */
|
||||
RsMutex gpgMtxData;
|
||||
/* Below is protected via the mutex */
|
||||
|
||||
certmap mKeyList;
|
||||
time_t mStoreKeyTime;
|
||||
time_t mStoreKeyTime;
|
||||
|
||||
bool gpgmeInit;
|
||||
PGPIdType mOwnGpgId;
|
||||
bool gpgKeySelected;
|
||||
bool _force_sync_database ;
|
||||
|
||||
bool gpgmeKeySelected;
|
||||
|
||||
std::string mOwnGpgId;
|
||||
gpgcert mOwnGpgCert;
|
||||
std::list<AuthGPGService*> services ;
|
||||
|
||||
std::map<std::string, bool> mAcceptToConnectMap;
|
||||
|
||||
RsMutex gpgMtxService;
|
||||
/* Below is protected via the mutex */
|
||||
|
||||
std::list<AuthGPGService*> services;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Sign a key
|
||||
**/
|
||||
typedef enum
|
||||
{
|
||||
SIGN_START,
|
||||
SIGN_COMMAND,
|
||||
SIGN_UIDS,
|
||||
SIGN_SET_EXPIRE,
|
||||
SIGN_SET_CHECK_LEVEL,
|
||||
SIGN_ENTER_PASSPHRASE,
|
||||
SIGN_CONFIRM,
|
||||
SIGN_QUIT,
|
||||
SIGN_SAVE,
|
||||
SIGN_ERROR
|
||||
} SignState;
|
||||
|
||||
|
||||
/*!
|
||||
* Change the key ownertrust
|
||||
**/
|
||||
typedef enum
|
||||
{
|
||||
TRUST_START,
|
||||
TRUST_COMMAND,
|
||||
TRUST_VALUE,
|
||||
TRUST_REALLY_ULTIMATE,
|
||||
TRUST_QUIT,
|
||||
TRUST_SAVE,
|
||||
TRUST_ERROR
|
||||
} TrustState;
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* This is the generic data object passed to the
|
||||
* callback function in a gpgme_op_edit operation.
|
||||
* The contents of this object are modified during
|
||||
* each callback, to keep track of states, errors
|
||||
* and other data.
|
||||
*/
|
||||
class EditParams
|
||||
{
|
||||
public:
|
||||
int state;
|
||||
|
||||
/*!
|
||||
* The return code of gpgme_op_edit() is the return value of
|
||||
* the last invocation of the callback. But returning an error
|
||||
* from the callback does not abort the edit operation, so we
|
||||
* must remember any error.
|
||||
*/
|
||||
gpg_error_t err;
|
||||
|
||||
/// Parameters specific to the key operation
|
||||
void *oParams;
|
||||
|
||||
EditParams(int state, void *oParams) {
|
||||
this->state = state;
|
||||
this->err = gpgme_error(GPG_ERR_NO_ERROR);
|
||||
this->oParams = oParams;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*!
|
||||
* Data specific to key signing
|
||||
**/
|
||||
class SignParams
|
||||
{
|
||||
public:
|
||||
|
||||
std::string checkLvl;
|
||||
|
||||
SignParams(std::string checkLvl) {
|
||||
this->checkLvl = checkLvl;
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* Data specific to key signing
|
||||
**/
|
||||
class TrustParams
|
||||
{
|
||||
public:
|
||||
|
||||
std::string trustLvl;
|
||||
|
||||
TrustParams(std::string trustLvl) {
|
||||
this->trustLvl = trustLvl;
|
||||
}
|
||||
static AuthGPG *_instance ;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Sign a key
|
||||
**/
|
||||
typedef enum
|
||||
{
|
||||
SIGN_START,
|
||||
SIGN_COMMAND,
|
||||
SIGN_UIDS,
|
||||
SIGN_SET_EXPIRE,
|
||||
SIGN_SET_CHECK_LEVEL,
|
||||
SIGN_ENTER_PASSPHRASE,
|
||||
SIGN_CONFIRM,
|
||||
SIGN_QUIT,
|
||||
SIGN_SAVE,
|
||||
SIGN_ERROR
|
||||
} SignState;
|
||||
|
||||
|
||||
/*!
|
||||
* Change the key ownertrust
|
||||
**/
|
||||
typedef enum
|
||||
{
|
||||
TRUST_START,
|
||||
TRUST_COMMAND,
|
||||
TRUST_VALUE,
|
||||
TRUST_REALLY_ULTIMATE,
|
||||
TRUST_QUIT,
|
||||
TRUST_SAVE,
|
||||
TRUST_ERROR
|
||||
} TrustState;
|
||||
|
||||
|
||||
|
||||
/*!
|
||||
* This is the generic data object passed to the
|
||||
* callback function in a gpgme_op_edit operation.
|
||||
* The contents of this object are modified during
|
||||
* each callback, to keep track of states, errors
|
||||
* and other data.
|
||||
*/
|
||||
class EditParams
|
||||
{
|
||||
public:
|
||||
int state;
|
||||
|
||||
/*!
|
||||
* The return code of gpgme_op_edit() is the return value of
|
||||
* the last invocation of the callback. But returning an error
|
||||
* from the callback does not abort the edit operation, so we
|
||||
* must remember any error.
|
||||
*/
|
||||
gpg_error_t err;
|
||||
|
||||
/// Parameters specific to the key operation
|
||||
void *oParams;
|
||||
|
||||
EditParams(int state, void *oParams) {
|
||||
this->state = state;
|
||||
this->err = gpgme_error(GPG_ERR_NO_ERROR);
|
||||
this->oParams = oParams;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/*!
|
||||
* Data specific to key signing
|
||||
**/
|
||||
class SignParams
|
||||
{
|
||||
public:
|
||||
|
||||
std::string checkLvl;
|
||||
|
||||
SignParams(std::string checkLvl) {
|
||||
this->checkLvl = checkLvl;
|
||||
}
|
||||
};
|
||||
|
||||
/*!
|
||||
* Data specific to key signing
|
||||
**/
|
||||
class TrustParams
|
||||
{
|
||||
public:
|
||||
|
||||
std::string trustLvl;
|
||||
|
||||
TrustParams(std::string trustLvl) {
|
||||
this->trustLvl = trustLvl;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -204,7 +204,10 @@ void setAuthSSL(AuthSSL *newssl)
|
|||
|
||||
void AuthSSLInit()
|
||||
{
|
||||
instance_ssl = new AuthSSLimpl();
|
||||
if (instance_ssl == NULL)
|
||||
{
|
||||
instance_ssl = new AuthSSLimpl();
|
||||
}
|
||||
}
|
||||
|
||||
AuthSSL *AuthSSL::getAuthSSL()
|
||||
|
|
|
@ -287,7 +287,18 @@ std::string cleanUpCertificate(const std::string& badCertificate,int& error_code
|
|||
while(currBadCertIdx < endCertStartIdx1 && (badCertificate[currBadCertIdx] == '=' || badCertificate[currBadCertIdx] == ' ' || badCertificate[currBadCertIdx] == '\n' ))
|
||||
currBadCertIdx++ ;
|
||||
|
||||
cleanCertificate += "==\n=";
|
||||
switch(cntPerLine % 4)
|
||||
{
|
||||
case 0: break ;
|
||||
case 1: std::cerr<<"Certificate corrupted beyond repair: wrongnumber of chars on last line (n%4=1)"<<std::endl;
|
||||
error_code = RS_PEER_CERT_CLEANING_CODE_WRONG_NUMBER;
|
||||
return badCertificate ;
|
||||
case 2: cleanCertificate += "==" ;
|
||||
break ;
|
||||
case 3: cleanCertificate += "=" ;
|
||||
break ;
|
||||
}
|
||||
cleanCertificate += "\n=";
|
||||
|
||||
// if (badCertificate[currBadCertIdx] == '=')
|
||||
// {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue