mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -05:00
fixed code for certificate link generation.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5420 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
a940537331
commit
b714d68523
@ -61,7 +61,7 @@ class PGPKeyManagement
|
|||||||
|
|
||||||
static void findLengthOfMinimalKey(const unsigned char *keydata,size_t key_len,size_t& minimal_key_len) ;
|
static void findLengthOfMinimalKey(const unsigned char *keydata,size_t key_len,size_t& minimal_key_len) ;
|
||||||
static std::string makeArmouredKey(const unsigned char *keydata,size_t key_size,const std::string& version_string) ;
|
static std::string makeArmouredKey(const unsigned char *keydata,size_t key_size,const std::string& version_string) ;
|
||||||
private:
|
|
||||||
// Computes the 24 bits CRC checksum necessary to all PGP data.
|
// Computes the 24 bits CRC checksum necessary to all PGP data.
|
||||||
//
|
//
|
||||||
static uint32_t compute24bitsCRC(unsigned char *data,size_t len) ;
|
static uint32_t compute24bitsCRC(unsigned char *data,size_t len) ;
|
||||||
|
@ -265,6 +265,7 @@ virtual bool getAllowTunnelConnection() = 0 ;
|
|||||||
|
|
||||||
/* Auth Stuff */
|
/* Auth Stuff */
|
||||||
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures,bool old_format = false) = 0;
|
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures,bool old_format = false) = 0;
|
||||||
|
virtual bool GetPGPBase64StringAndCheckSum(const std::string& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) = 0 ;
|
||||||
virtual std::string GetRetroshareInvite(bool include_signatures,bool old_format = false) = 0;
|
virtual std::string GetRetroshareInvite(bool include_signatures,bool old_format = false) = 0;
|
||||||
virtual bool hasExportMinimal() = 0 ;
|
virtual bool hasExportMinimal() = 0 ;
|
||||||
|
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "util/radix64.h"
|
||||||
|
#include "pgp/pgpkeyutil.h"
|
||||||
|
|
||||||
#include "rsserver/p3peers.h"
|
#include "rsserver/p3peers.h"
|
||||||
#include "rsserver/p3face.h"
|
#include "rsserver/p3face.h"
|
||||||
|
|
||||||
@ -819,6 +822,31 @@ p3Peers::GetRetroshareInvite(bool include_signatures,bool old_format)
|
|||||||
return GetRetroshareInvite(getOwnId(),include_signatures,old_format);
|
return GetRetroshareInvite(getOwnId(),include_signatures,old_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool p3Peers::GetPGPBase64StringAndCheckSum( const std::string& gpg_id,
|
||||||
|
std::string& gpg_base64_string,
|
||||||
|
std::string& gpg_base64_checksum)
|
||||||
|
{
|
||||||
|
gpg_base64_string = "" ;
|
||||||
|
gpg_base64_checksum = "" ;
|
||||||
|
|
||||||
|
unsigned char *mem_block ;
|
||||||
|
size_t mem_block_size ;
|
||||||
|
|
||||||
|
if(!AuthGPG::getAuthGPG()->exportPublicKey(PGPIdType(gpg_id),mem_block,mem_block_size,false,false))
|
||||||
|
return false ;
|
||||||
|
|
||||||
|
Radix64::encode((const char *)mem_block,mem_block_size,gpg_base64_string) ;
|
||||||
|
|
||||||
|
uint32_t crc = PGPKeyManagement::compute24bitsCRC((unsigned char *)mem_block,mem_block_size) ;
|
||||||
|
|
||||||
|
unsigned char tmp[3] = { (crc >> 16) & 0xff, (crc >> 8) & 0xff, crc & 0xff } ;
|
||||||
|
Radix64::encode((const char *)tmp,3,gpg_base64_checksum) ;
|
||||||
|
|
||||||
|
delete[] mem_block ;
|
||||||
|
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
std::string p3Peers::GetRetroshareInvite(const std::string& ssl_id,bool include_signatures,bool old_format)
|
std::string p3Peers::GetRetroshareInvite(const std::string& ssl_id,bool include_signatures,bool old_format)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
@ -874,7 +902,7 @@ bool p3Peers::loadCertificateFromFile(const std::string &/*fname*/, std::string
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetails &pd,std::string& error_string)
|
bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetails &pd,std::string& /*error_string*/)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::LoadCertificateFromString() ";
|
std::cerr << "p3Peers::LoadCertificateFromString() ";
|
||||||
|
@ -96,6 +96,8 @@ virtual bool getAllowTunnelConnection() ;
|
|||||||
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures,bool old_format = false);
|
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures,bool old_format = false);
|
||||||
// same but for own id
|
// same but for own id
|
||||||
virtual std::string GetRetroshareInvite(bool include_signatures,bool old_format = false);
|
virtual std::string GetRetroshareInvite(bool include_signatures,bool old_format = false);
|
||||||
|
virtual bool GetPGPBase64StringAndCheckSum(const std::string& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) ;
|
||||||
|
|
||||||
virtual bool hasExportMinimal() ;
|
virtual bool hasExportMinimal() ;
|
||||||
|
|
||||||
virtual bool loadCertificateFromFile(const std::string &fname, std::string &id, std::string &gpg_id);
|
virtual bool loadCertificateFromFile(const std::string &fname, std::string &id, std::string &gpg_id);
|
||||||
|
@ -286,42 +286,39 @@ bool RetroShareLink::createCertificate(const std::string& ssl_or_gpg_id)
|
|||||||
// This is baaaaaad code:
|
// This is baaaaaad code:
|
||||||
// - we should not need to parse and re-read a cert in old format.
|
// - we should not need to parse and re-read a cert in old format.
|
||||||
//
|
//
|
||||||
std::string invite = rsPeers->GetRetroshareInvite(ssl_or_gpg_id, false,true) ;
|
|
||||||
|
|
||||||
if(invite == "")
|
|
||||||
{
|
|
||||||
std::cerr << "RetroShareLink::createPerson() Couldn't get retroshare invite for ssl id: " << ssl_or_gpg_id << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
RsPeerDetails detail;
|
RsPeerDetails detail;
|
||||||
if (rsPeers->getPeerDetails(ssl_or_gpg_id, detail) == false) {
|
if (rsPeers->getPeerDetails(ssl_or_gpg_id, detail) == false) {
|
||||||
std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_or_gpg_id << std::endl;
|
std::cerr << "RetroShareLink::createPerson() Couldn't find peer id " << ssl_or_gpg_id << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//_ssl_id = QString::fromStdString(id);
|
std::string gpg_base_64_str = "" ;
|
||||||
QString gpg_base_64 = QString::fromStdString(invite).section("\n\n",1).section("-----",0,0) ;
|
std::string gpg_base_64_checksum_str = "" ;
|
||||||
|
|
||||||
_GPGBase64CheckSum = gpg_base_64.section("=",-1,-1).section("\n",0,0) ;
|
if(!rsPeers->GetPGPBase64StringAndCheckSum(detail.gpg_id,gpg_base_64_str,gpg_base_64_checksum_str))
|
||||||
gpg_base_64 = gpg_base_64.section("\n=",0,0) ;
|
return false ;
|
||||||
|
|
||||||
|
_GPGBase64String = QString::fromStdString(gpg_base_64_str) ;
|
||||||
|
_GPGBase64CheckSum = QString::fromStdString(gpg_base_64_checksum_str) ;
|
||||||
|
|
||||||
_type = TYPE_CERTIFICATE;
|
_type = TYPE_CERTIFICATE;
|
||||||
|
|
||||||
_GPGid = QString::fromStdString(detail.gpg_id).right(8);
|
_GPGid = QString::fromStdString(detail.gpg_id).right(8);
|
||||||
if (detail.isOnlyGPGdetail) {
|
|
||||||
|
if(detail.isOnlyGPGdetail)
|
||||||
|
{
|
||||||
_SSLid.clear();
|
_SSLid.clear();
|
||||||
_location.clear();
|
_location.clear();
|
||||||
_ext_ip_port.clear();
|
_ext_ip_port.clear();
|
||||||
_loc_ip_port.clear();
|
_loc_ip_port.clear();
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_SSLid = QString::fromStdString(ssl_or_gpg_id) ;
|
_SSLid = QString::fromStdString(ssl_or_gpg_id) ;
|
||||||
_location = QString::fromUtf8(detail.location.c_str()) ;
|
_location = QString::fromUtf8(detail.location.c_str()) ;
|
||||||
_ext_ip_port = QString::fromStdString(invite).section("--EXT--",1,1) ;
|
_ext_ip_port = QString::fromStdString(detail.extAddr) + ":" + QString::number(detail.extPort) + ";" ;
|
||||||
QString lst = QString::fromStdString(invite).section("--EXT--",0,0) ;
|
_loc_ip_port = QString::fromStdString(detail.localAddr) + ":" + QString::number(detail.localPort) + ";" ;
|
||||||
_loc_ip_port = lst.section("--LOCAL--",1,1) ;
|
|
||||||
}
|
}
|
||||||
_GPGBase64String = gpg_base_64.replace("\n","") ;
|
|
||||||
_name = QString::fromUtf8(detail.name.c_str()) ;
|
_name = QString::fromUtf8(detail.name.c_str()) ;
|
||||||
|
|
||||||
std::cerr << "Found gpg base 64 string = " << _GPGBase64String.toStdString() << std::endl;
|
std::cerr << "Found gpg base 64 string = " << _GPGBase64String.toStdString() << std::endl;
|
||||||
|
Loading…
Reference in New Issue
Block a user