changed Radix64::decode to return result as std::vector

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8520 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
electron128 2015-06-18 13:45:08 +00:00
parent 6a924cb854
commit 13355a7efe
5 changed files with 23 additions and 44 deletions

View file

@ -29,16 +29,12 @@ bool PGPKeyManagement::createMinimalKey(const std::string& pgp_certificate,std::
// 1 - Convert armored key into binary key
//
char *keydata = NULL ;
size_t len = 0 ;
Radix64::decode(radix_cert,keydata,len) ;
std::vector<uint8_t> keydata = Radix64::decode(radix_cert) ;
size_t new_len ;
findLengthOfMinimalKey((unsigned char *)keydata,len,new_len) ;
findLengthOfMinimalKey(keydata.data(), keydata.size(), new_len) ;
cleaned_certificate = makeArmouredKey((unsigned char*)keydata,new_len,version_string) ;
cleaned_certificate = makeArmouredKey(keydata.data(), new_len, version_string) ;
return true ;
}
catch(std::exception& e)

View file

@ -251,12 +251,11 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code)
#endif
// 1 - decode the string.
//
char *bf = NULL ;
size_t size ;
Radix64::decode(str,bf, size) ;
std::vector<uint8_t> bf = Radix64::decode(str) ;
size_t size = bf.size();
bool checksum_check_passed = false ;
unsigned char *buf = (unsigned char *)bf ;
unsigned char *buf = bf.data() ;
size_t total_s = 0 ;
only_pgp = true ;
uint8_t certificate_version = 0x00 ;
@ -348,7 +347,7 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code)
err_code = CERTIFICATE_PARSING_ERROR_INVALID_CHECKSUM_SECTION ;
return false ;
}
uint32_t computed_crc = PGPKeyManagement::compute24bitsCRC((unsigned char *)bf,size-5) ;
uint32_t computed_crc = PGPKeyManagement::compute24bitsCRC(bf.data(),size-5) ;
uint32_t certificate_crc = buf[0] + (buf[1] << 8) + (buf[2] << 16) ;
if(computed_crc != certificate_crc)
@ -386,7 +385,6 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code)
if(total_s != size)
std::cerr << "(EE) Certificate contains trailing characters. Weird." << std::endl;
delete[] bf ;
return true ;
}
catch(std::exception& e)