mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
added code to generate 3072 and 4096 bit PGP keys at startup (Patch from Serhaf)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7841 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7bc98f1cd5
commit
8cb3ae6d2e
9 changed files with 75 additions and 37 deletions
|
@ -360,7 +360,7 @@ bool PGPHandler::availableGPGCertificatesWithPrivateKeys(std::list<RsPgpId>& ids
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool PGPHandler::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passphrase, RsPgpId& pgpId, std::string& errString)
|
||||
bool PGPHandler::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passphrase, RsPgpId& pgpId, const int keynumbits, std::string& errString)
|
||||
{
|
||||
// Some basic checks
|
||||
|
||||
|
@ -384,13 +384,16 @@ bool PGPHandler::GeneratePGPCertificate(const std::string& name, const std::stri
|
|||
errString = std::string("(EE) passphrase in certificate exceeds the maximum allowed passphrase size") ;
|
||||
return false ;
|
||||
}
|
||||
if(keynumbits % 1024 != 0)
|
||||
{
|
||||
errString = std::string("(EE) RSA key length is not a multiple of 1024") ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// Now the real thing
|
||||
RsStackMutex mtx(pgphandlerMtx) ; // lock access to PGP memory structures.
|
||||
RsStackFileLock flck(_pgp_lock_filename) ; // lock access to PGP directory.
|
||||
|
||||
static const int KEY_NUMBITS = 2048 ;
|
||||
|
||||
// 1 - generate keypair - RSA-2048
|
||||
//
|
||||
ops_user_id_t uid ;
|
||||
|
@ -398,7 +401,7 @@ bool PGPHandler::GeneratePGPCertificate(const std::string& name, const std::stri
|
|||
uid.user_id = (unsigned char *)s ;
|
||||
unsigned long int e = 65537 ; // some prime number
|
||||
|
||||
ops_keydata_t *key = ops_rsa_create_selfsigned_keypair(KEY_NUMBITS,e,&uid) ;
|
||||
ops_keydata_t *key = ops_rsa_create_selfsigned_keypair(keynumbits, e, &uid) ;
|
||||
|
||||
free(s) ;
|
||||
|
||||
|
@ -409,7 +412,7 @@ bool PGPHandler::GeneratePGPCertificate(const std::string& name, const std::stri
|
|||
|
||||
ops_create_info_t *cinfo = NULL ;
|
||||
ops_memory_t *buf = NULL ;
|
||||
ops_setup_memory_write(&cinfo, &buf, 0);
|
||||
ops_setup_memory_write(&cinfo, &buf, 0);
|
||||
|
||||
if(!ops_write_transferable_secret_key(key,(unsigned char *)passphrase.c_str(),passphrase.length(),ops_false,cinfo))
|
||||
{
|
||||
|
|
|
@ -77,7 +77,7 @@ class PGPHandler
|
|||
bool exportGPGKeyPair(const std::string& filename,const RsPgpId& exported_id) const ;
|
||||
|
||||
bool availableGPGCertificatesWithPrivateKeys(std::list<RsPgpId>& ids);
|
||||
bool GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, RsPgpId& pgpId, std::string& errString) ;
|
||||
bool GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, RsPgpId& pgpId, const int keynumbits, std::string& errString) ;
|
||||
|
||||
bool LoadCertificateFromString(const std::string& pem, RsPgpId& gpg_id, std::string& error_string);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue