mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-13 08:35:45 -04:00
improved login system: do not re-ask for passphrase when user clicks cancel. Removed warning stating that maybe passphrase is wrong
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8415 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3bec1f4f69
commit
74c01423f0
14 changed files with 87 additions and 45 deletions
|
@ -405,28 +405,44 @@ callback_cmd_get_secret_key(const ops_parser_content_t *content_,ops_parse_cb_in
|
|||
/* now get the key from the data */
|
||||
secret=ops_get_secret_key_from_data(cbinfo->cryptinfo.keydata);
|
||||
int tag_to_use = OPS_PARSER_CMD_GET_SK_PASSPHRASE ;
|
||||
int nbtries = 0 ;
|
||||
int nbtries = 0 ;
|
||||
|
||||
while( (!secret) && nbtries++ < 3)
|
||||
{
|
||||
if (!cbinfo->cryptinfo.passphrase)
|
||||
{
|
||||
memset(&pc,'\0',sizeof pc);
|
||||
pc.content.secret_key_passphrase.passphrase=&cbinfo->cryptinfo.passphrase;
|
||||
CB(cbinfo,tag_to_use,&pc);
|
||||
if (!cbinfo->cryptinfo.passphrase)
|
||||
{
|
||||
fprintf(stderr,"can't get passphrase\n");
|
||||
return 0 ; // ASSERT(0);
|
||||
}
|
||||
}
|
||||
/* then it must be encrypted */
|
||||
secret=ops_decrypt_secret_key_from_data(cbinfo->cryptinfo.keydata,cbinfo->cryptinfo.passphrase);
|
||||
{
|
||||
if (!cbinfo->cryptinfo.passphrase)
|
||||
{
|
||||
cbinfo->arg = malloc(sizeof(unsigned char)) ;
|
||||
*(unsigned char *)cbinfo->arg = 0 ;
|
||||
|
||||
free(cbinfo->cryptinfo.passphrase) ;
|
||||
cbinfo->cryptinfo.passphrase = NULL ;
|
||||
tag_to_use = OPS_PARSER_CMD_GET_SK_PASSPHRASE_PREV_WAS_BAD ;
|
||||
}
|
||||
memset(&pc,'\0',sizeof pc);
|
||||
pc.content.secret_key_passphrase.passphrase=&cbinfo->cryptinfo.passphrase;
|
||||
CB(cbinfo,tag_to_use,&pc);
|
||||
|
||||
if(*(unsigned char*)(cbinfo->arg) == 1)
|
||||
{
|
||||
fprintf(stderr,"passphrase cancelled\n");
|
||||
free(cbinfo->arg) ;
|
||||
cbinfo->arg=NULL ;
|
||||
return 0 ; // ASSERT(0);
|
||||
}
|
||||
if (!cbinfo->cryptinfo.passphrase)
|
||||
{
|
||||
free(cbinfo->arg) ;
|
||||
cbinfo->arg=NULL ;
|
||||
fprintf(stderr,"can't get passphrase\n");
|
||||
return 0 ; // ASSERT(0);
|
||||
}
|
||||
free(cbinfo->arg) ;
|
||||
cbinfo->arg=NULL ;
|
||||
}
|
||||
/* then it must be encrypted */
|
||||
secret=ops_decrypt_secret_key_from_data(cbinfo->cryptinfo.keydata,cbinfo->cryptinfo.passphrase);
|
||||
|
||||
free(cbinfo->cryptinfo.passphrase) ;
|
||||
cbinfo->cryptinfo.passphrase = NULL ;
|
||||
|
||||
tag_to_use = OPS_PARSER_CMD_GET_SK_PASSPHRASE_PREV_WAS_BAD ;
|
||||
}
|
||||
|
||||
if(!secret)
|
||||
return 0 ;
|
||||
|
|
|
@ -150,11 +150,10 @@ enum ops_content_tag_t
|
|||
OPS_PTAG_CT_ENCRYPTED_PK_SESSION_KEY=0x300+15,
|
||||
|
||||
/* commands to the callback */
|
||||
OPS_PARSER_CMD_GET_SK_PASSPHRASE =0x400,
|
||||
OPS_PARSER_CMD_GET_SECRET_KEY =0x400+1,
|
||||
OPS_PARSER_CMD_GET_SK_PASSPHRASE =0x400,
|
||||
OPS_PARSER_CMD_GET_SECRET_KEY =0x400+1,
|
||||
OPS_PARSER_CMD_GET_SK_PASSPHRASE_PREV_WAS_BAD =0x400+2,
|
||||
|
||||
|
||||
/* Errors */
|
||||
OPS_PARSER_ERROR =0x500, /*!< Internal Use: Parser Error */
|
||||
OPS_PARSER_ERRCODE =0x500+1, /*! < Internal Use: Parser Error with errcode returned */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue