mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-18 05:44:14 -05:00
made cert of versions 0.5 and 0.6 incompatible. Removed old cert format parse/display
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-initdev@7033 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8c8baae044
commit
affdd49001
@ -9,7 +9,7 @@
|
||||
#include "rscertificate.h"
|
||||
#include "util/rsstring.h"
|
||||
|
||||
//#define DEBUG_RSCERTIFICATE
|
||||
#define DEBUG_RSCERTIFICATE
|
||||
|
||||
static const std::string PGP_CERTIFICATE_START ( "-----BEGIN PGP PUBLIC KEY BLOCK-----" );
|
||||
static const std::string PGP_CERTIFICATE_END ( "-----END PGP PUBLIC KEY BLOCK-----" );
|
||||
@ -27,6 +27,9 @@ static const uint8_t CERTIFICATE_PTAG_SSLID_SECTION = 0x05 ;
|
||||
static const uint8_t CERTIFICATE_PTAG_NAME_SECTION = 0x06 ;
|
||||
static const uint8_t CERTIFICATE_PTAG_CHECKSUM_SECTION = 0x07 ;
|
||||
static const uint8_t CERTIFICATE_PTAG_HIDDENNODE_SECTION = 0x08 ;
|
||||
static const uint8_t CERTIFICATE_PTAG_VERSION_SECTION = 0x09 ;
|
||||
|
||||
static const uint8_t CERTIFICATE_VERSION_06 = 0x06 ;
|
||||
|
||||
static bool is_acceptable_radix64Char(char c)
|
||||
{
|
||||
@ -74,7 +77,8 @@ std::string RsCertificate::toStdString() const
|
||||
size_t p = 0 ;
|
||||
unsigned char *buf = new unsigned char[BS] ;
|
||||
|
||||
addPacket( CERTIFICATE_PTAG_PGP_SECTION , binary_pgp_key , binary_pgp_key_size , buf, p, BS ) ;
|
||||
addPacket( CERTIFICATE_PTAG_VERSION_SECTION, &CERTIFICATE_VERSION_06 , 1 , buf, p, BS ) ;
|
||||
addPacket( CERTIFICATE_PTAG_PGP_SECTION , binary_pgp_key , binary_pgp_key_size , buf, p, BS ) ;
|
||||
|
||||
if(!only_pgp)
|
||||
{
|
||||
@ -132,7 +136,7 @@ RsCertificate::RsCertificate(const std::string& str)
|
||||
{
|
||||
uint32_t err_code ;
|
||||
|
||||
if(!initFromString(str,err_code) && !initFromString_oldFormat(str,err_code))
|
||||
if(!initFromString(str,err_code)) // && !initFromString_oldFormat(str,err_code))
|
||||
throw err_code ;
|
||||
}
|
||||
|
||||
@ -252,6 +256,7 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code)
|
||||
unsigned char *buf = (unsigned char *)bf ;
|
||||
size_t total_s = 0 ;
|
||||
only_pgp = true ;
|
||||
uint8_t certificate_version = 0x00 ;
|
||||
|
||||
while(total_s < size)
|
||||
{
|
||||
@ -272,8 +277,13 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code)
|
||||
#ifdef DEBUG_RSCERTIFICATE
|
||||
std::cerr << "Packet parse: read ptag " << (int)ptag << ", size " << s << ", total_s = " << total_s << ", expected total = " << size << std::endl;
|
||||
#endif
|
||||
|
||||
switch(ptag)
|
||||
{
|
||||
case CERTIFICATE_PTAG_VERSION_SECTION: certificate_version = buf[0] ;
|
||||
buf = &buf[s] ;
|
||||
break ;
|
||||
|
||||
case CERTIFICATE_PTAG_PGP_SECTION: binary_pgp_key = new unsigned char[s] ;
|
||||
memcpy(binary_pgp_key,buf,s) ;
|
||||
binary_pgp_key_size = s ;
|
||||
@ -360,6 +370,15 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code)
|
||||
return false ;
|
||||
}
|
||||
|
||||
if(certificate_version != CERTIFICATE_VERSION_06)
|
||||
{
|
||||
err_code = CERTIFICATE_PARSING_ERROR_WRONG_VERSION ;
|
||||
return false ;
|
||||
}
|
||||
#ifdef DEBUG_RSCERTIFICATE
|
||||
std::cerr << "Certificate is version " << (int)certificate_version << std::endl;
|
||||
#endif
|
||||
|
||||
if(total_s != size)
|
||||
std::cerr << "(EE) Certificate contains trailing characters. Weird." << std::endl;
|
||||
|
||||
@ -416,11 +435,11 @@ unsigned short RsCertificate::loc_port_us() const
|
||||
|
||||
bool RsCertificate::cleanCertificate(const std::string& input,std::string& output,Format& format,int& error_code)
|
||||
{
|
||||
if(cleanCertificate_oldFormat(input,output,error_code))
|
||||
{
|
||||
format = RS_CERTIFICATE_OLD_FORMAT ;
|
||||
return true ;
|
||||
}
|
||||
// if(cleanCertificate_oldFormat(input,output,error_code))
|
||||
// {
|
||||
// format = RS_CERTIFICATE_OLD_FORMAT ;
|
||||
// return true ;
|
||||
// }
|
||||
|
||||
if(cleanCertificate(input,output,error_code))
|
||||
{
|
||||
@ -843,6 +862,10 @@ bool RsCertificate::cleanCertificate_oldFormat(const std::string& certstr,std::s
|
||||
|
||||
std::string RsCertificate::toStdString_oldFormat() const
|
||||
{
|
||||
return std::string() ;
|
||||
|
||||
// not supported anymore.
|
||||
//
|
||||
std::string res ;
|
||||
|
||||
res += PGPKeyManagement::makeArmouredKey(binary_pgp_key,binary_pgp_key_size,pgp_version) ;
|
||||
@ -891,6 +914,8 @@ std::string RsCertificate::toStdString_oldFormat() const
|
||||
|
||||
bool RsCertificate::initFromString_oldFormat(const std::string& certstr,uint32_t& /*err_code*/)
|
||||
{
|
||||
return false ; // this format is not supported anymore.
|
||||
|
||||
//parse the text to get ip address
|
||||
try
|
||||
{
|
||||
|
@ -112,6 +112,7 @@ const uint32_t CERTIFICATE_PARSING_ERROR_INVALID_CHECKSUM_SECTION = 0x15 ;
|
||||
const uint32_t CERTIFICATE_PARSING_ERROR_CHECKSUM_ERROR = 0x16 ;
|
||||
const uint32_t CERTIFICATE_PARSING_ERROR_UNKNOWN_SECTION_PTAG = 0x17 ;
|
||||
const uint32_t CERTIFICATE_PARSING_ERROR_MISSING_CHECKSUM = 0x18 ;
|
||||
const uint32_t CERTIFICATE_PARSING_ERROR_WRONG_VERSION = 0x19 ;
|
||||
|
||||
const uint32_t PGP_KEYRING_REMOVAL_ERROR_NO_ERROR = 0x20 ;
|
||||
const uint32_t PGP_KEYRING_REMOVAL_ERROR_CANT_REMOVE_SECRET_KEYS = 0x21 ;
|
||||
|
@ -108,6 +108,7 @@ QString ConnectFriendWizard::getErrorString(uint32_t error_code)
|
||||
case CERTIFICATE_PARSING_ERROR_INVALID_LOCAL_IP: return tr("Invalid local IP.") ;
|
||||
case CERTIFICATE_PARSING_ERROR_INVALID_CHECKSUM_SECTION: return tr("Invalid checksum section.") ;
|
||||
case CERTIFICATE_PARSING_ERROR_CHECKSUM_ERROR: return tr("Checksum mismatch. Certificate is corrupted.") ;
|
||||
case CERTIFICATE_PARSING_ERROR_WRONG_VERSION: return tr("Certificate has wrong version number. Remember that v0.6 and v0.5 networks are incompatible.") ;
|
||||
case CERTIFICATE_PARSING_ERROR_UNKNOWN_SECTION_PTAG: return tr("Unknown section type found (Certificate might be corrupted).") ;
|
||||
case CERTIFICATE_PARSING_ERROR_MISSING_CHECKSUM: return tr("Missing checksum.") ;
|
||||
|
||||
@ -194,9 +195,10 @@ void ConnectFriendWizard::initializePage(int id)
|
||||
cleanfriendCertTimer->setInterval(1000); // 1 second
|
||||
connect(cleanfriendCertTimer, SIGNAL(timeout()), this, SLOT(cleanFriendCert()));
|
||||
|
||||
ui->userCertOldFormatButton->setChecked(true);
|
||||
ui->userCertOldFormatButton->setChecked(false);
|
||||
ui->userCertOldFormatButton->hide() ;
|
||||
|
||||
toggleFormatState(false);
|
||||
toggleFormatState(true);
|
||||
toggleSignatureState(false);
|
||||
updateOwnCert();
|
||||
|
||||
|
@ -49,6 +49,9 @@ CryptoPage::CryptoPage(QWidget * parent, Qt::WFlags flags)
|
||||
connect(ui._copyLink_PB, SIGNAL(clicked()), this, SLOT(copyRSLink()));
|
||||
connect(ui._useOldFormat_CB, SIGNAL(toggled(bool)), this, SLOT(load()));
|
||||
|
||||
ui._useOldFormat_CB->setEnabled(false) ;
|
||||
ui._useOldFormat_CB->setChecked(false) ;
|
||||
|
||||
// hide profile manager as it causes bugs when generating a new profile.
|
||||
//ui.profile_Button->hide() ;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user