From efd1447a84df19c37dd482f3a92039e3c06f4492 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 19 Jan 2014 14:42:16 +0000 Subject: [PATCH] removed code for old certificate format. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-initdev@7041 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pgp/rscertificate.cc | 579 +----------------- libretroshare/src/pgp/rscertificate.h | 4 - libretroshare/src/retroshare/rspeers.h | 4 +- libretroshare/src/rsserver/p3peers.cc | 11 +- libretroshare/src/rsserver/p3peers.h | 4 +- .../src/gui/connect/ConfCertDialog.cpp | 2 +- .../src/gui/connect/ConnectFriendWizard.cpp | 2 +- .../src/gui/settings/CryptoPage.cpp | 2 +- 8 files changed, 13 insertions(+), 595 deletions(-) diff --git a/libretroshare/src/pgp/rscertificate.cc b/libretroshare/src/pgp/rscertificate.cc index e5707d1c8..547c0bc20 100644 --- a/libretroshare/src/pgp/rscertificate.cc +++ b/libretroshare/src/pgp/rscertificate.cc @@ -136,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)) throw err_code ; } @@ -435,12 +435,6 @@ 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(input,output,error_code)) { format = RS_CERTIFICATE_RADIX ; @@ -494,576 +488,7 @@ bool RsCertificate::cleanCertificate(const std::string& instr,std::string& str,i return true ; } -// All the code below should be removed when in 0.6. Certificates will only use the new format. -// -bool RsCertificate::cleanCertificate_oldFormat(const std::string& certstr,std::string& cleanCertificate,int& error_code) -{ - error_code = RS_PEER_CERT_CLEANING_CODE_UNKOWN_ERROR ; // default - const std::string& badCertificate(certstr) ; - - std::string pgpend("-----END PGP PUBLIC KEY BLOCK-----"); - - size_t pos = certstr.find(pgpend); - std::string peer_info ; - std::string cert ; - - if (pos != std::string::npos) - { - pos += pgpend.length(); - cert = certstr.substr(0, pos); - if (pos + 1 < certstr.length()) - peer_info = certstr.substr(pos + 1); - } - else - { - error_code = RS_PEER_CERT_CLEANING_CODE_NO_END_TAG ; - return false ; - } - - if(cert.empty()) - return false ; - - /* - Buffer for storing the cleaned certificate. In certain cases the - cleanCertificate can be larger than the badCertificate - */ - cleanCertificate = ""; - //The entire certificate begin tag - const char * beginCertTag="-----BEGIN"; - //The entire certificate end tag - const char * endCertTag="-----END"; - //Tag containing dots. The common part of both start and end tags - const char * commonTag="-----"; - //Only BEGIN part of the begin tag - const char * beginTag="BEGIN"; - //Only END part of the end tag - const char * endTag="END"; - //The start index of the ----- part of the certificate begin tag - size_t beginCertStartIdx1=0; - //The start index of the BEGIN part of the certificate begin tag - size_t beginCertStartIdx2=0; - //The start index of the end part(-----) of the certificate begin tag. The begin tag ends with -----. Example -----BEGIN XPGP CERTIFICATE----- - size_t beginCertEndIdx=0; - //The start index of the ----- part of the certificate end tag - size_t endCertStartIdx1=0; - //The start index of the END part of the certificate end tag - size_t endCertStartIdx2=0; - //The start index of the end part(-----) of the certificate end tag. The begin tag ends with -----. Example -----BEGIN XPGP CERTIFICATE----- - size_t endCertEndIdx=0; - //The length of the bad certificate. - size_t lengthOfCert=certstr.length(); - //The current index value in the bad certificate - size_t currBadCertIdx=0; - //Temporary index value - size_t tmpIdx=0; - //Boolean flag showing if the begin tag or the end tag has been found - bool found=false; - /* - Calculating the value of the beginCertStartIdx1 and beginCertStartIdx2. Here - we first locate the occurance of ----- and then the location of BEGIN. Next - we check if there are any non space or non new-line characters between their - occureance. If there are any other characters between the two(----- and - BEGIN), other than space and new line then it means that it is the - certificate begin tag. Here we take care of the fact that we may have - introduced some spaces and newlines in the begin tag by mistake. This takes - care of the spaces and newlines between ----- and BEGIN. - */ - - while(found==false && (beginCertStartIdx1=certstr.find(commonTag,tmpIdx))!=std::string::npos) - { - beginCertStartIdx2=certstr.find(beginTag,beginCertStartIdx1+strlen(commonTag)); - tmpIdx=beginCertStartIdx1+strlen(commonTag); - if(beginCertStartIdx2!=std::string::npos) - { - found=true; - for(size_t i=beginCertStartIdx1+strlen(commonTag);i tag"< tag"< tag"<=lengthOfCert) - { - std::cerr<<"Certificate corrupted beyond repair: No <------END > tag"< header; - header.push_back("Version"); - header.push_back("Comment"); - header.push_back("MessageID"); - header.push_back("Hash"); - header.push_back("Charset"); - - for (std::list::iterator headerIt = header.begin (); headerIt != header.end(); headerIt++) - { - if (badCertificate.substr(currBadCertIdx, (*headerIt).length()) == *headerIt) - { - cleanCertificate += badCertificate.substr(currBadCertIdx, (*headerIt).length()); - currBadCertIdx += (*headerIt).length(); - while(currBadCertIdx=endCertStartIdx1) - { - std::cerr<<"Certificate corrupted beyond repair: No checksum, or no newline after first tag"<GetRetroshareInvite(detail.id,ui._shouldAddSignatures_CB->isChecked(),ui._useOldFormat_CB->isChecked()) ; // this needs to be a SSL id + std::string invite = rsPeers->GetRetroshareInvite(detail.id,ui._shouldAddSignatures_CB->isChecked()) ; // this needs to be a SSL id ui.userCertificateText->setReadOnly(true); ui.userCertificateText->setMinimumHeight(200); diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 0f5cd379f..09332788a 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -668,7 +668,7 @@ void ConnectFriendWizard::accept() void ConnectFriendWizard::updateOwnCert() { - std::string invite = rsPeers->GetRetroshareInvite(ui->userCertIncludeSignaturesButton->isChecked(),ui->userCertOldFormatButton->isChecked()); + std::string invite = rsPeers->GetRetroshareInvite(ui->userCertIncludeSignaturesButton->isChecked()); std::cerr << "TextPage() getting Invite: " << invite << std::endl; diff --git a/retroshare-gui/src/gui/settings/CryptoPage.cpp b/retroshare-gui/src/gui/settings/CryptoPage.cpp index c9fa14fc4..4b9b4235a 100755 --- a/retroshare-gui/src/gui/settings/CryptoPage.cpp +++ b/retroshare-gui/src/gui/settings/CryptoPage.cpp @@ -112,7 +112,7 @@ void CryptoPage::load() { /* Loads ouer default Puplickey */ - ui.certplainTextEdit->setPlainText(QString::fromUtf8(rsPeers->GetRetroshareInvite(ui._includeSignatures_CB->isChecked(),ui._useOldFormat_CB->isChecked()).c_str())); + ui.certplainTextEdit->setPlainText(QString::fromUtf8(rsPeers->GetRetroshareInvite(ui._includeSignatures_CB->isChecked()).c_str())); } void CryptoPage::copyRSLink()