mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
change back the engine setting. Now it should work with gpg1 and gpg2
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1740 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c1df0e1c1d
commit
c00928a349
@ -133,8 +133,8 @@ bool GPGAuthMgr::setPGPPassword_locked(std::string pwd)
|
||||
memcpy(PgpPassword, pwd.c_str(), pwd.length());
|
||||
PgpPassword[pwd.length()] = '\0';
|
||||
|
||||
fprintf(stderr, "GPGAuthMgr::setPGPPassword_locked() called\n");
|
||||
gpgme_set_passphrase_cb(CTX, pgp_pwd_callback, (void *) PgpPassword);
|
||||
fprintf(stderr, "GPGAuthMgr::setPGPPassword_locked() called\n");
|
||||
gpgme_set_passphrase_cb(CTX, pgp_pwd_callback, (void *) PgpPassword);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -155,12 +155,12 @@ GPGAuthMgr::GPGAuthMgr()
|
||||
|
||||
#ifndef WINDOWS_SYS
|
||||
/* setup the engine (gpg2) */
|
||||
if (GPG_ERR_NO_ERROR != gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP, "/usr/bin/gpg2", NULL))
|
||||
{
|
||||
std::cerr << "Error creating Setting engine";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
// if (GPG_ERR_NO_ERROR != gpgme_set_engine_info(GPGME_PROTOCOL_OpenPGP, "/usr/bin/gpg2", NULL))
|
||||
// {
|
||||
// std::cerr << "Error creating Setting engine";
|
||||
// std::cerr << std::endl;
|
||||
// return;
|
||||
// }
|
||||
#endif
|
||||
|
||||
if (GPG_ERR_NO_ERROR != gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP))
|
||||
@ -174,7 +174,24 @@ GPGAuthMgr::GPGAuthMgr()
|
||||
{
|
||||
std::cerr << "Error getting engine info";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
while (INFO && INFO->protocol != GPGME_PROTOCOL_OpenPGP) {
|
||||
INFO = INFO->next;
|
||||
}
|
||||
if (!INFO) {
|
||||
fprintf (stderr, "GPGME compiled without support for protocol %s",
|
||||
gpgme_get_protocol_name (INFO->protocol));
|
||||
} else if (INFO->file_name && !INFO->version) {
|
||||
fprintf (stderr, "Engine %s not installed properly",
|
||||
INFO->file_name);
|
||||
} else if (INFO->file_name && INFO->version && INFO->req_version) {
|
||||
fprintf (stderr, "Engine %s version %s installed, "
|
||||
"but at least version %s required", INFO->file_name,
|
||||
INFO->version, INFO->req_version);
|
||||
} else {
|
||||
fprintf (stderr, "Unknown problem with engine for protocol %s",
|
||||
gpgme_get_protocol_name (INFO->protocol));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Create New Contexts */
|
||||
@ -201,6 +218,16 @@ GPGAuthMgr::GPGAuthMgr()
|
||||
updateTrustAllKeys_locked();
|
||||
}
|
||||
|
||||
bool GPGAuthMgr::getPGPEngineFileName(std::string &fileName)
|
||||
{
|
||||
if (!INFO) {
|
||||
return false;
|
||||
} else {
|
||||
fileName = std::string(INFO->file_name);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* This function is called when retroshare is first started
|
||||
* to get the list of available GPG certificates.
|
||||
* This function should only return certs for which
|
||||
@ -817,11 +844,6 @@ X509 *GPGAuthMgr::SignX509Req(X509_REQ *req, long days, std::string gpg_passwd)
|
||||
sigoutll=sigoutl=2048; // hashoutl; //EVP_PKEY_size(pkey);
|
||||
buf_sigout=(unsigned char *)OPENSSL_malloc((unsigned int)sigoutl);
|
||||
|
||||
std::cerr << "Buffer Sizes: in: " << inl;
|
||||
std::cerr << " HashOut: " << hashoutl;
|
||||
std::cerr << " SigOut: " << sigoutl;
|
||||
std::cerr << std::endl;
|
||||
|
||||
if ((buf_in == NULL) || (buf_hashout == NULL) || (buf_sigout == NULL))
|
||||
{
|
||||
hashoutl=0;
|
||||
@ -854,6 +876,11 @@ X509 *GPGAuthMgr::SignX509Req(X509_REQ *req, long days, std::string gpg_passwd)
|
||||
goto err;
|
||||
}
|
||||
|
||||
std::cerr << "Buffer Sizes: in: " << inl;
|
||||
std::cerr << " HashOut: " << hashoutl;
|
||||
std::cerr << " SigOut: " << sigoutl;
|
||||
std::cerr << std::endl;
|
||||
|
||||
//passphrase = "NULL";
|
||||
|
||||
std::cerr << "Signature done: len:" << sigoutl << std::endl;
|
||||
@ -1119,7 +1146,7 @@ bool GPGAuthMgr::VerifySignature_locked(std::string id, void *data, int datalen,
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
if (GPG_ERR_NO_ERROR != gpgme_data_new_from_mem(&gpgmeSig, (const char *) sig, siglen, 1))
|
||||
if (GPG_ERR_NO_ERROR != gpgme_data_new_from_mem(&gpgmeSig, (const char *) sig, siglen, 1))
|
||||
{
|
||||
std::cerr << "Error create Sig";
|
||||
std::cerr << std::endl;
|
||||
@ -1133,9 +1160,33 @@ bool GPGAuthMgr::VerifySignature_locked(std::string id, void *data, int datalen,
|
||||
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_verify(CTX,gpgmeSig, gpgmeData, NULL)))
|
||||
{
|
||||
ProcessPGPmeError(ERR);
|
||||
std::cerr << "GPGAuthMgr::Verify FAILED";
|
||||
std::cerr << "GPGAuthMgr::VerifySignature_locked FAILED for first try.";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
std::cerr << "GPGAuthMgr::VerifySignature_locked making another signature check with siglen - 1 (mandatory for gpg v1)." << std::endl;
|
||||
|
||||
std::cerr << "VerifySignature: datalen: " << datalen << " siglen: " << (siglen - 1);
|
||||
std::cerr << std::endl;
|
||||
|
||||
if (GPG_ERR_NO_ERROR != gpgme_data_new_from_mem(&gpgmeData, (const char *) data, datalen, 1))
|
||||
{
|
||||
std::cerr << "Error create Data";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
if (GPG_ERR_NO_ERROR != gpgme_data_new_from_mem(&gpgmeSig, (const char *) sig, siglen - 1, 1))
|
||||
{
|
||||
std::cerr << "Error create Sig";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_verify(CTX,gpgmeSig, gpgmeData, NULL)))
|
||||
{
|
||||
ProcessPGPmeError(ERR);
|
||||
std::cerr << "GPGAuthMgr::VerifySignature_locked FAILED for second try.";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
gpgme_verify_result_t res = gpgme_op_verify_result(CTX);
|
||||
|
||||
|
@ -82,6 +82,9 @@ class GPGAuthMgr: public AuthSSL
|
||||
|
||||
bool availablePGPCertificates(std::list<std::string> &ids);
|
||||
|
||||
//get the pgpg engine used by the pgp functions
|
||||
bool getPGPEngineFileName(std::string &fileName);
|
||||
|
||||
int GPGInit(std::string ownId);
|
||||
int GPGInit(std::string name, std::string comment,
|
||||
std::string email, std::string passwd); /* create it */
|
||||
|
@ -47,6 +47,7 @@ class RsInit
|
||||
|
||||
/* Account Details (Combined GPG+SSL Setup) */
|
||||
static bool getPreferedAccountId(std::string &id);
|
||||
static bool getPGPEngineFileName(std::string &fileName);
|
||||
static bool getAccountIds(std::list<std::string> &ids);
|
||||
static bool getAccountDetails(std::string id,
|
||||
std::string &gpgId, std::string &gpgName,
|
||||
|
@ -780,6 +780,17 @@ int RsInit::GetPGPLogins(std::list<std::string> &pgpIds)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool RsInit::getPGPEngineFileName(std::string &fileName)
|
||||
{
|
||||
#ifdef PQI_USE_SSLONLY
|
||||
return false;
|
||||
#else // PGP+SSL
|
||||
GPGAuthMgr *mgr = (GPGAuthMgr *) getAuthMgr();
|
||||
|
||||
return mgr->getPGPEngineFileName(fileName);
|
||||
#endif
|
||||
}
|
||||
|
||||
int RsInit::GetPGPLoginDetails(std::string id, std::string &name, std::string &email)
|
||||
{
|
||||
std::cerr << "RsInit::GetPGPLoginDetails for \"" << id << "\"";
|
||||
|
@ -51,9 +51,17 @@ GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags)
|
||||
//ui.genName->setFocus(Qt::OtherFocusReason);
|
||||
|
||||
#ifndef WINDOWS_SYS /* UNIX */
|
||||
//comment those to show the pgp password field
|
||||
ui.genPGPpassword->hide();
|
||||
ui.label_3->hide();
|
||||
std::string gpgEngineFileName;
|
||||
if (RsInit::getPGPEngineFileName(gpgEngineFileName)) {
|
||||
std::cerr << "RsInit::getPGPEngineFileName() : " << gpgEngineFileName << std::endl;
|
||||
//if fileName contains gpg2 then the passphrase is set by pinentry and not by RS
|
||||
QString *fileName = new QString(gpgEngineFileName.c_str());
|
||||
if (fileName->contains("gpg2")) {
|
||||
ui.genPGPpassword->hide();
|
||||
ui.label_3->hide();
|
||||
}
|
||||
}
|
||||
//comment those to show the pgp password field
|
||||
#endif
|
||||
|
||||
#ifdef RS_USE_PGPSSL
|
||||
|
@ -83,8 +83,16 @@ StartDialog::StartDialog(QWidget *parent, Qt::WFlags flags)
|
||||
ui.loadPasswd->hide();
|
||||
ui.label_4->hide();
|
||||
|
||||
ui.loadGPGPasswd->hide();
|
||||
ui.label_5->hide();
|
||||
std::string gpgEngineFileName;
|
||||
if (RsInit::getPGPEngineFileName(gpgEngineFileName)) {
|
||||
std::cerr << "RsInit::getPGPEngineFileName() : " << gpgEngineFileName << std::endl;
|
||||
//if fileName contains gpg2 then the passphrase is set by pinentry and not by RS
|
||||
QString *fileName = new QString(gpgEngineFileName.c_str());
|
||||
if (fileName->contains("gpg2")) {
|
||||
ui.loadGPGPasswd->hide();
|
||||
ui.label_5->hide();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* get all available pgp private certificates....
|
||||
|
@ -47,6 +47,7 @@ class RsInit
|
||||
|
||||
/* Account Details (Combined GPG+SSL Setup) */
|
||||
static bool getPreferedAccountId(std::string &id);
|
||||
static bool getPGPEngineFileName(std::string &fileName);
|
||||
static bool getAccountIds(std::list<std::string> &ids);
|
||||
static bool getAccountDetails(std::string id,
|
||||
std::string &gpgId, std::string &gpgName,
|
||||
|
Loading…
Reference in New Issue
Block a user