mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-18 10:58:43 -04:00
first code for the gui : network dialog, start dialog and certificate first generation
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2009 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
45b2287d41
commit
77b3c0afd0
12 changed files with 267 additions and 510 deletions
|
@ -198,7 +198,7 @@ AuthGPG::AuthGPG()
|
|||
*/
|
||||
bool AuthGPG::availablePGPCertificates(std::list<std::string> &ids)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
int i = 0;
|
||||
gpgme_key_t KEY = NULL;
|
||||
|
@ -609,7 +609,7 @@ bool AuthGPG::printOwnKeys_locked()
|
|||
|
||||
bool AuthGPG::printKeys()
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
printAllKeys_locked();
|
||||
return printOwnKeys_locked();
|
||||
}
|
||||
|
@ -827,7 +827,7 @@ bool AuthGPG::VerifySignature_locked(const void *data, int datalen, const void *
|
|||
|
||||
bool AuthGPG::active()
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
return ((gpgmeInit) && (gpgmeKeySelected) && (gpgmeX509Selected));
|
||||
}
|
||||
|
@ -855,7 +855,7 @@ int AuthGPG::setConfigDirectories(std::string confFile, std::string neighDir
|
|||
/**** These Two are common */
|
||||
std::string AuthGPG::getPGPName(GPG_id id)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(id)))
|
||||
|
@ -867,7 +867,7 @@ std::string AuthGPG::getPGPName(GPG_id id)
|
|||
/**** These Two are common */
|
||||
std::string AuthGPG::getPGPEmail(GPG_id id)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(id)))
|
||||
|
@ -880,14 +880,14 @@ std::string AuthGPG::getPGPEmail(GPG_id id)
|
|||
|
||||
std::string AuthGPG::PGPOwnId()
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
return mOwnGpgId;
|
||||
}
|
||||
|
||||
bool AuthGPG::getPGPAllList(std::list<std::string> &ids)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
/* add an id for each pgp certificate */
|
||||
certmap::iterator it;
|
||||
|
@ -898,8 +898,29 @@ bool AuthGPG::getPGPAllList(std::list<std::string> &ids)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool AuthGPG::getPGPDetails(std::string id, RsPeerDetails &d)
|
||||
{
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
/* add an id for each pgp certificate */
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(id)))
|
||||
{
|
||||
d.id = it->second.id;
|
||||
d.name = it->second.name;
|
||||
d.email = it->second.email;
|
||||
d.trustLvl = it->second.trustLvl;
|
||||
d.validLvl = it->second.validLvl;
|
||||
d.ownsign = it->second.ownsign;
|
||||
d.signers = it->second.signers;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool AuthGPG::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) {
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
gpgme_set_armor (CTX, 1);
|
||||
gpg_error_t ERR;
|
||||
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_decrypt (CTX, CIPHER, PLAIN)))
|
||||
|
@ -914,7 +935,7 @@ bool AuthGPG::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) {
|
|||
}
|
||||
|
||||
bool AuthGPG::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) {
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
gpgme_encrypt_flags_t* flags = new gpgme_encrypt_flags_t();
|
||||
gpgme_key_t keys[2] = {mOwnGpgCert.key, NULL};
|
||||
|
@ -933,7 +954,7 @@ bool AuthGPG::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) {
|
|||
|
||||
bool AuthGPG::getPGPSignedList(std::list<std::string> &ids)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
certmap::iterator it;
|
||||
for(it = mKeyList.begin(); it != mKeyList.end(); it++)
|
||||
|
@ -948,7 +969,7 @@ bool AuthGPG::getPGPSignedList(std::list<std::string> &ids)
|
|||
|
||||
bool AuthGPG::isPGPValid(GPG_id id)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(id))) {
|
||||
|
@ -962,7 +983,7 @@ bool AuthGPG::isPGPValid(GPG_id id)
|
|||
|
||||
bool AuthGPG::isPGPSigned(GPG_id id)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(id)))
|
||||
|
@ -1135,8 +1156,7 @@ bool AuthGPG::SignCertificateLevel0(GPG_id id)
|
|||
}
|
||||
|
||||
/* reload stuff now ... */
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
storeAllKeys_locked();
|
||||
|
||||
return true;
|
||||
|
@ -1433,7 +1453,7 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \
|
|||
class SignParams *sparams = (class SignParams *)params->oParams;
|
||||
const char *result = NULL;
|
||||
|
||||
fprintf(stderr,"keySignCallback status: %d args: %s, params->state: %d\n", status, args, params->state);
|
||||
fprintf(stderr,"keySignCallback status: %d args: %s, params->state: %d\n", status, args, params->state);
|
||||
|
||||
/* printf stuff out */
|
||||
if (status == GPGME_STATUS_EOF)
|
||||
|
@ -1448,7 +1468,6 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \
|
|||
fprintf(stderr,"keySignCallback GPGME_STATUS_GOOD_PASSPHRASE\n");
|
||||
if (status == GPGME_STATUS_BAD_PASSPHRASE)
|
||||
fprintf(stderr,"keySignCallback GPGME_STATUS_BAD_PASSPHRASE\n");
|
||||
|
||||
if (status == GPGME_STATUS_GET_LINE)
|
||||
fprintf(stderr,"keySignCallback GPGME_STATUS_GET_LINE\n");
|
||||
if (status == GPGME_STATUS_GET_BOOL)
|
||||
|
@ -1456,6 +1475,26 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \
|
|||
if (status == GPGME_STATUS_ALREADY_SIGNED)
|
||||
fprintf(stderr,"keySignCallback GPGME_STATUS_ALREADY_SIGNED\n");
|
||||
|
||||
/* printf stuff out */
|
||||
if (params->state == SIGN_START)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_START\n");
|
||||
if (params->state == SIGN_COMMAND)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_COMMAND\n");
|
||||
if (params->state == SIGN_UIDS)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_UIDS\n");
|
||||
if (params->state == SIGN_SET_EXPIRE)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_SET_EXPIRE\n");
|
||||
if (params->state == SIGN_SET_CHECK_LEVEL)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_SET_CHECK_LEVEL\n");
|
||||
if (params->state == SIGN_CONFIRM)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_CONFIRM\n");
|
||||
if (params->state == SIGN_QUIT)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_QUIT\n");
|
||||
if (params->state == SIGN_ENTER_PASSPHRASE)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_ENTER_PASSPHRASE\n");
|
||||
if (params->state == SIGN_ERROR)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_ERROR");
|
||||
|
||||
|
||||
if(status == GPGME_STATUS_EOF ||
|
||||
status == GPGME_STATUS_GOT_IT ||
|
||||
|
@ -1598,27 +1637,19 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \
|
|||
params->err = gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
break;
|
||||
// case SIGN_ENTER_PASSPHRASE:
|
||||
// fprintf(stderr,"keySignCallback SIGN_ENTER_PASSPHRASE\n");
|
||||
//
|
||||
// if(status == GPGME_STATUS_GET_HIDDEN &&
|
||||
// (!std::string("passphrase.enter").compare(args)))
|
||||
// {
|
||||
// params->state = SIGN_CONFIRM;
|
||||
// result = sparams->passphrase.c_str();
|
||||
// }
|
||||
// // If using pgp_pwd_callback, then never have to enter passphrase this way.
|
||||
// // must catch GOOD_PASSPHRASE to move on.
|
||||
// else if (status == GPGME_STATUS_GOOD_PASSPHRASE)
|
||||
// {
|
||||
// params->state = SIGN_CONFIRM;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// params->state = SIGN_ERROR;
|
||||
// params->err = gpg_error (GPG_ERR_GENERAL);
|
||||
// }
|
||||
// break;
|
||||
case SIGN_ENTER_PASSPHRASE:
|
||||
fprintf(stderr,"keySignCallback SIGN_ENTER_PASSPHRASE\n");
|
||||
|
||||
if (status == GPGME_STATUS_GOOD_PASSPHRASE)
|
||||
{
|
||||
params->state = SIGN_CONFIRM;
|
||||
}
|
||||
else
|
||||
{
|
||||
params->state = SIGN_ERROR;
|
||||
params->err = gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
break;
|
||||
case SIGN_CONFIRM:
|
||||
fprintf(stderr,"keySignCallback SIGN_CONFIRM\n");
|
||||
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <openssl/ssl.h>
|
||||
#include <openssl/evp.h>
|
||||
#include "util/rsthreads.h"
|
||||
#include "rsiface/rspeers.h"
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
@ -150,6 +151,7 @@ class AuthGPG
|
|||
/* PGP web of trust management */
|
||||
GPG_id PGPOwnId();
|
||||
bool getPGPAllList(std::list<std::string> &ids);
|
||||
bool getPGPDetails(std::string id, RsPeerDetails &d);
|
||||
bool getPGPSignedList(std::list<std::string> &ids);
|
||||
bool getPGPValidList(std::list<std::string> &ids);
|
||||
bool isPGPValid(std::string id);
|
||||
|
|
|
@ -1769,7 +1769,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
|
|||
X509 *x509 = X509_new();
|
||||
if (x509 == NULL)
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1777,7 +1777,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
|
|||
unsigned long chtype = MBSTRING_ASC;
|
||||
X509_NAME *issuer_name = X509_NAME_new();
|
||||
X509_NAME_add_entry_by_txt(issuer_name, "CN", chtype,
|
||||
(unsigned char *) mOwnId.c_str(), -1, -1, 0);
|
||||
(unsigned char *) AuthGPG::getAuthGPG()->PGPOwnId().c_str(), -1, -1, 0);
|
||||
/****
|
||||
X509_NAME_add_entry_by_NID(issuer_name, 48, 0,
|
||||
(unsigned char *) "email@email.com", -1, -1, 0);
|
||||
|
@ -1787,24 +1787,24 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
|
|||
(unsigned char *) "loc", -1, -1, 0);
|
||||
****/
|
||||
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() Issuer name: " << mOwnId << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() Issuer name: " << AuthGPG::getAuthGPG()->PGPOwnId() << std::endl;
|
||||
|
||||
BIGNUM *btmp = BN_new();
|
||||
if (!BN_pseudo_rand(btmp, SERIAL_RAND_BITS, 0, 0))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() rand FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() rand FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
if (!BN_to_ASN1_INTEGER(btmp, serial))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() asn1 FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() asn1 FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
BN_free(btmp);
|
||||
|
||||
if (!X509_set_serialNumber(x509, serial))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() serial FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() serial FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
ASN1_INTEGER_free(serial);
|
||||
|
@ -1815,7 +1815,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
|
|||
|
||||
if (!X509_set_issuer_name(x509, issuer_name))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() issue FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() issue FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
X509_NAME_free(issuer_name);
|
||||
|
@ -1823,26 +1823,26 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
|
|||
|
||||
if (!X509_gmtime_adj(X509_get_notBefore(x509),0))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() notbefore FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() notbefore FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!X509_gmtime_adj(X509_get_notAfter(x509), (long)60*60*24*days))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() notafter FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() notafter FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!X509_set_subject_name(x509, X509_REQ_get_subject_name(req)))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() sub FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() sub FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tmppkey = X509_REQ_get_pubkey(req);
|
||||
if (!tmppkey || !X509_set_pubkey(x509,tmppkey))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() pub FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() pub FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1901,7 +1901,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
|
|||
{
|
||||
hashoutl=0;
|
||||
sigoutl=0;
|
||||
fprintf(stderr, "GPGAuthMgr::SignX509Req: ASN1err(ASN1_F_ASN1_SIGN,ERR_R_MALLOC_FAILURE)\n");
|
||||
fprintf(stderr, "AuthSSL::SignX509Req: ASN1err(ASN1_F_ASN1_SIGN,ERR_R_MALLOC_FAILURE)\n");
|
||||
goto err;
|
||||
}
|
||||
p=buf_in;
|
||||
|
@ -1916,7 +1916,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
|
|||
(unsigned int *)&hashoutl))
|
||||
{
|
||||
hashoutl=0;
|
||||
fprintf(stderr, "GPGAuthMgr::SignX509Req: ASN1err(ASN1_F_ASN1_SIGN,ERR_R_EVP_LIB)\n");
|
||||
fprintf(stderr, "AuthSSL::SignX509Req: ASN1err(ASN1_F_ASN1_SIGN,ERR_R_EVP_LIB)\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue