mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
* Fixed up SSL peerIds and gpg password stuff.
* PGP version compiling / running on OSX now. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1268 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
edd13ba38a
commit
387b7bae6a
@ -82,14 +82,41 @@ p3AuthMgr *getAuthMgr()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
gpg_error_t pgp_pwd_callback(void *hook, const char *uid_hint, const char *passphrase_info, int prev_was_bad, int fd)
|
||||
{
|
||||
const char *passwd = (const char *) hook;
|
||||
|
||||
if (prev_was_bad)
|
||||
fprintf(stderr, "pgp_pwd_callback() Prev was bad!\n");
|
||||
//fprintf(stderr, "pgp_pwd_callback() Set Password to:\"%s\"\n", passwd);
|
||||
fprintf(stderr, "pgp_pwd_callback() Set Password\n");
|
||||
|
||||
write(fd, passwd, strlen(passwd));
|
||||
write(fd, "\n", 1); /* needs a new line? */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *PgpPassword = NULL;
|
||||
|
||||
bool GPGAuthMgr::setPGPPassword(std::string pwd)
|
||||
{
|
||||
/* reset it while we change it */
|
||||
gpgme_set_passphrase_cb(CTX, NULL, NULL);
|
||||
|
||||
if (PgpPassword)
|
||||
free(PgpPassword);
|
||||
PgpPassword = (char *) malloc(pwd.length() + 1);
|
||||
memcpy(PgpPassword, pwd.c_str(), pwd.length());
|
||||
PgpPassword[pwd.length()] = '\0';
|
||||
|
||||
gpgme_set_passphrase_cb(CTX, pgp_pwd_callback, (void *) PgpPassword);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
GPGAuthMgr::GPGAuthMgr()
|
||||
:gpgmeInit(false)
|
||||
@ -140,8 +167,6 @@ GPGAuthMgr::GPGAuthMgr()
|
||||
printAllKeys();
|
||||
updateTrustAllKeys();
|
||||
|
||||
static const char *realPassword = "aaaa\n";
|
||||
gpgme_set_passphrase_cb(CTX, pgp_pwd_callback, (void *) realPassword);
|
||||
|
||||
}
|
||||
|
||||
@ -244,6 +269,7 @@ int GPGAuthMgr::GPGInit(std::string ownId, std::string name, std::string passphr
|
||||
mOwnGpgCert.user.id = ownId;
|
||||
mOwnGpgCert.key = newKey;
|
||||
this->passphrase = passphrase;
|
||||
setPGPPassword(passphrase);
|
||||
|
||||
mOwnId = ownId;
|
||||
gpgmeKeySelected = true;
|
||||
@ -281,7 +307,9 @@ int GPGAuthMgr::GPGInit(std::string name, std::string comment,
|
||||
mOwnGpgCert.user.fpr = newKey->subkeys->fpr;
|
||||
mOwnGpgCert.user.id = newKey->subkeys->keyid;
|
||||
mOwnGpgCert.key = newKey;
|
||||
|
||||
this->passphrase = passphrase;
|
||||
setPGPPassword(passphrase);
|
||||
|
||||
mOwnId = mOwnGpgCert.user.id;
|
||||
gpgmeKeySelected = true;
|
||||
@ -1017,7 +1045,7 @@ bool GPGAuthMgr::DoOwnSignature(void *data, unsigned int datalen, void *buf_sigo
|
||||
/* now extract the data from gpgmeSig */
|
||||
size_t len = 0;
|
||||
char *export_sig = gpgme_data_release_and_get_mem(gpgmeSig, &len);
|
||||
fprintf(stderr, "GPGAuthMgr::Signature len: %d \n", len);
|
||||
fprintf(stderr, "GPGAuthMgr::Signature len: %ld \n", len);
|
||||
if (len < *outl)
|
||||
{
|
||||
*outl = len;
|
||||
|
@ -57,6 +57,8 @@ class GPGAuthMgr: public AuthSSL
|
||||
GPGAuthMgr();
|
||||
~GPGAuthMgr();
|
||||
|
||||
bool setPGPPassword(std::string pwd);
|
||||
|
||||
X509* SignX509Req(X509_REQ *req, long days, std::string);
|
||||
bool AuthX509(X509 *x509);
|
||||
|
||||
|
@ -1694,7 +1694,10 @@ bool getX509id(X509 *x509, std::string &xid)
|
||||
unsigned char *signdata = ASN1_STRING_data(signature);
|
||||
|
||||
std::ostringstream id;
|
||||
for(uint32_t i = 0; i < CERTSIGNLEN; i++)
|
||||
/* switched to the other end of the signature. for
|
||||
* more randomness
|
||||
*/
|
||||
for(uint32_t i = signlen - CERTSIGNLEN; i < signlen; i++)
|
||||
{
|
||||
id << std::hex << std::setw(2) << std::setfill('0')
|
||||
<< (uint16_t) (((uint8_t *) (signdata))[i]);
|
||||
|
@ -552,8 +552,14 @@ int RsInit::GetLoginDetails(std::string id, std::string &name, std::string &emai
|
||||
#else // PGP+SSL
|
||||
|
||||
GPGAuthMgr *mgr = (GPGAuthMgr *) getAuthMgr();
|
||||
name = id;
|
||||
email = id;
|
||||
pqiAuthDetails details;
|
||||
if (!mgr->getDetails(id, details))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
name = details.name;
|
||||
email = details.email;
|
||||
|
||||
return 1;
|
||||
#endif
|
||||
|
@ -27,7 +27,9 @@ ifndef MAC_I386_BUILD
|
||||
endif
|
||||
|
||||
# flags for components....
|
||||
PQI_USE_XPGP = 1
|
||||
#PQI_USE_SSLONLY = 1
|
||||
#PQI_USE_XPGP = 1
|
||||
|
||||
#PQI_USE_PROXY = 1
|
||||
#PQI_USE_CHANNELS = 1
|
||||
#USE_FILELOOK = 1
|
||||
@ -50,7 +52,11 @@ RANLIB = ranlib
|
||||
LIBDIR = $(RS_TOP_DIR)/lib
|
||||
LIBRS = $(LIBDIR)/libretroshare.a
|
||||
|
||||
INCLUDE = -I $(RS_TOP_DIR)
|
||||
OPT_DIR = /opt/local
|
||||
OPT_INCLUDE = $(OPT_DIR)/include
|
||||
OPT_LIBS = $(OPT_DIR)/lib
|
||||
|
||||
INCLUDE = -I $(RS_TOP_DIR) -I $(OPT_INCLUDE)
|
||||
#CFLAGS = -Wall -O3
|
||||
CFLAGS = -Wall -g
|
||||
|
||||
@ -69,13 +75,13 @@ CFLAGS += $(INCLUDE)
|
||||
# (but unlikely to work unless Qt Libraries are build properly)
|
||||
# CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk
|
||||
|
||||
|
||||
ifdef PQI_USE_XPGP
|
||||
INCLUDE += -I $(SSL_DIR)/include
|
||||
INCLUDE += -I $(SSL_DIR)/include
|
||||
CFLAGS += -DPQI_USE_XPGP
|
||||
endif
|
||||
|
||||
ifdef PQI_USE_XPGP
|
||||
CFLAGS += -DPQI_USE_XPGP
|
||||
ifdef PQI_USE_SSLONLY
|
||||
CFLAGS += -DPQI_USE_SSLONLY
|
||||
endif
|
||||
|
||||
ifdef PQI_USE_PROXY
|
||||
@ -136,6 +142,8 @@ ifdef PQI_USE_XPGP
|
||||
LIBS += -L$(SSL_DIR)
|
||||
endif
|
||||
LIBS += -lssl -lcrypto -lpthread
|
||||
LIBS += -L$(OPT_LIBS)
|
||||
LIBS += -lgpgme -lgpg-error
|
||||
LIBS += -L$(UPNPC_DIR) -lminiupnpc
|
||||
LIBS += $(XLIB) -ldl -lz
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user