mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
debugging of pgpkey parser and radix output form openpgpsdk
git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-OpenPGP@5061 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
51fa97ac59
commit
648555711c
5 changed files with 67 additions and 32 deletions
|
@ -99,28 +99,7 @@ bool PGPKeyManagement::createMinimalKey(const std::string& pgp_certificate,std::
|
|||
break ;
|
||||
}
|
||||
|
||||
std::string outstring ;
|
||||
Radix64::encode(keydata,(uint64_t)data - (uint64_t)keydata,outstring) ;
|
||||
|
||||
uint32_t crc = compute24bitsCRC((unsigned char *)keydata,(uint64_t)data - (uint64_t)keydata) ;
|
||||
|
||||
unsigned char tmp[3] = { (crc >> 16) & 0xff, (crc >> 8) & 0xff, crc & 0xff } ;
|
||||
std::string crc_string ;
|
||||
Radix64::encode((const char *)tmp,3,crc_string) ;
|
||||
|
||||
#ifdef DEBUG_PGPUTIL
|
||||
std::cerr << "After signature pruning: " << std::endl;
|
||||
std::cerr << outstring << std::endl;
|
||||
#endif
|
||||
|
||||
cleaned_certificate = std::string(PGP_CERTIFICATE_START_STRING) + "\n" + version_string + "\n\n" ;
|
||||
|
||||
for(uint32_t i=0;i<outstring.length();i+=64)
|
||||
cleaned_certificate += outstring.substr(i,64) + "\n" ;
|
||||
|
||||
cleaned_certificate += "=" + crc_string + "\n" ;
|
||||
cleaned_certificate += std::string(PGP_CERTIFICATE_END_STRING) + "\n" ;
|
||||
|
||||
cleaned_certificate = makeArmouredKey((unsigned char*)keydata,(uint64_t)data - (uint64_t)keydata,version_string) ;
|
||||
return true ;
|
||||
}
|
||||
catch(std::exception& e)
|
||||
|
@ -131,6 +110,33 @@ bool PGPKeyManagement::createMinimalKey(const std::string& pgp_certificate,std::
|
|||
}
|
||||
}
|
||||
|
||||
std::string PGPKeyManagement::makeArmouredKey(const unsigned char *keydata,size_t key_size,const std::string& version_string)
|
||||
{
|
||||
std::string outstring ;
|
||||
Radix64::encode((const char *)keydata,key_size,outstring) ;
|
||||
|
||||
uint32_t crc = compute24bitsCRC((unsigned char *)keydata,key_size) ;
|
||||
|
||||
unsigned char tmp[3] = { (crc >> 16) & 0xff, (crc >> 8) & 0xff, crc & 0xff } ;
|
||||
std::string crc_string ;
|
||||
Radix64::encode((const char *)tmp,3,crc_string) ;
|
||||
|
||||
#ifdef DEBUG_PGPUTIL
|
||||
std::cerr << "After signature pruning: " << std::endl;
|
||||
std::cerr << outstring << std::endl;
|
||||
#endif
|
||||
|
||||
std::string certificate = std::string(PGP_CERTIFICATE_START_STRING) + "\n" + version_string + "\n\n" ;
|
||||
|
||||
for(uint32_t i=0;i<outstring.length();i+=64)
|
||||
certificate += outstring.substr(i,64) + "\n" ;
|
||||
|
||||
certificate += "=" + crc_string + "\n" ;
|
||||
certificate += std::string(PGP_CERTIFICATE_END_STRING) + "\n" ;
|
||||
|
||||
return certificate ;
|
||||
}
|
||||
|
||||
uint32_t PGPKeyManagement::compute24bitsCRC(unsigned char *octets, size_t len)
|
||||
{
|
||||
long crc = PGP_CRC24_INIT;
|
||||
|
@ -171,6 +177,7 @@ uint32_t PGPKeyParser::read_125Size(unsigned char *& data)
|
|||
return b1 ;
|
||||
|
||||
uint8_t b2 = *data ;
|
||||
++data ;
|
||||
|
||||
if(b1 < 224)
|
||||
return ((b1-192) << 8) + b2 + 192 ;
|
||||
|
|
|
@ -59,6 +59,7 @@ class PGPKeyManagement
|
|||
//
|
||||
static bool createMinimalKey(const std::string& pgp_certificate,std::string& cleaned_certificate) ;
|
||||
|
||||
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.
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue