mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 22:25:04 -04:00
fixed password handling in deferred signature algorithm (in case of cancel, enter wrong passphrase, etc)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8423 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
46c5e08f31
commit
f360e9d0ba
8 changed files with 201 additions and 172 deletions
|
@ -58,7 +58,7 @@ public:
|
|||
virtual bool getKeyFingerprint(const RsPgpId& id,PGPFingerprintType& fp) const;
|
||||
virtual bool VerifySignBin(const void *data, uint32_t len, unsigned char *sign, unsigned int signlen, const PGPFingerprintType& withfingerprint);
|
||||
virtual bool getGPGAllList(std::list<RsPgpId> &ids);
|
||||
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result );
|
||||
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result );
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -1312,19 +1312,31 @@ bool PGPHandler::SignDataBin(const RsPgpId& id,const void *data, const uint32_t
|
|||
|
||||
PGPFingerprintType fp(f.fingerprint) ;
|
||||
#endif
|
||||
bool cancelled =false;
|
||||
std::string passphrase = _passphrase_callback(NULL,uid_hint.c_str(),"Please enter passwd for encrypting your key : ",false,&cancelled) ;
|
||||
|
||||
ops_secret_key_t *secret_key = ops_decrypt_secret_key_from_data(key,passphrase.c_str()) ;
|
||||
bool last_passwd_was_wrong = false ;
|
||||
ops_secret_key_t *secret_key = NULL ;
|
||||
|
||||
if(!secret_key)
|
||||
{
|
||||
std::cerr << "Key decryption went wrong. Wrong passwd?" << std::endl;
|
||||
return false ;
|
||||
}
|
||||
if(cancelled)
|
||||
for(int i=0;i<3;++i)
|
||||
{
|
||||
std::cerr << "Key entering cancelled" << std::endl;
|
||||
bool cancelled =false;
|
||||
std::string passphrase = _passphrase_callback(NULL,uid_hint.c_str(),"Please enter passwd for encrypting your key : ",last_passwd_was_wrong,&cancelled) ;
|
||||
|
||||
secret_key = ops_decrypt_secret_key_from_data(key,passphrase.c_str()) ;
|
||||
|
||||
if(cancelled)
|
||||
{
|
||||
std::cerr << "Key entering cancelled" << std::endl;
|
||||
return false ;
|
||||
}
|
||||
if(secret_key)
|
||||
break ;
|
||||
|
||||
std::cerr << "Key decryption went wrong. Wrong passwd?" << std::endl;
|
||||
last_passwd_was_wrong = true ;
|
||||
}
|
||||
if(!secret_key)
|
||||
{
|
||||
std::cerr << "Could not obtain secret key. Signature cancelled." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue