simple server mode now correctly opens and populates keyring

with any identities with blank pins.
This commit is contained in:
gardners 2012-04-13 09:35:22 +09:30
parent 6f93d7a48d
commit 3e920c8dfa
2 changed files with 10 additions and 8 deletions

View File

@ -1122,20 +1122,21 @@ int keyring_seed(keyring_file *k)
if (!k) return WHY("keyring is null");
/* nothing to do if there is already an identity */
if (k->contexts[0]->identity_count) return 0;
if (k->contexts[0]->identity_count)
return 0;
int i;
char did[65];
unsigned char did[65];
/* Securely generate random telephone number */
urandombytes((unsigned char *)did,10);
/* Make DID start with 2 through 9, as 1 is special in many number spaces. */
did[0]='2'+did[0]%8;
did[0]='2'+(did[0]%8);
/* Then add 10 more digits, which is what we do in the mobile phone software */
for(i=1;i<11;i++) did[i]='0'+did[i]%10; did[11]=0;
for(i=1;i<11;i++) did[i]='0'+(did[i]%10); did[11]=0;
keyring_identity *id=keyring_create_identity(k,k->contexts[0],"");
if (!id) return WHY("Could not create new identity");
if (keyring_set_did(id,did)) return WHY("Could not set DID of new identity");
if (keyring_set_did(id,(char *)did)) return WHY("Could not set DID of new identity");
if (keyring_commit(k)) return WHY("Could not commit new identity to keyring file");
return 0;
}

View File

@ -150,10 +150,11 @@ int getKeyring(char *backing_file)
}
else
{
if (keyring) {
if (keyring)
exit(WHY("Keyring being opened twice"));
keyring=keyring_open(backing_file);
}
keyring=keyring_open(backing_file);
/* unlock all entries with blank pins */
keyring_enter_pins(keyring,"");
}
keyring_seed(keyring);