From b281edec0524ce729c5fb77cc02fc608526d844a Mon Sep 17 00:00:00 2001 From: gardners Date: Wed, 2 May 2012 02:32:21 +0930 Subject: [PATCH] filter out invalid SIDs when generating. --- keyring.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/keyring.c b/keyring.c index ce9d485c..22291dc7 100644 --- a/keyring.c +++ b/keyring.c @@ -846,10 +846,14 @@ keyring_identity *keyring_create_identity(keyring_file *k,keyring_context *c, WHY("malloc() failed preparing first public key storage"); goto kci_safeexit; } - crypto_box_curve25519xsalsa20poly1305_keypair(id->keypairs[0]->public_key, - id->keypairs[0]->private_key); + /* Filter out public keys that start with 0x0, as they are reserved for address + abbreviation. */ + id->keypairs[0]->public_key[0]=0; + while(id->keypairs[0]->public_key[0]==0) + crypto_box_curve25519xsalsa20poly1305_keypair(id->keypairs[0]->public_key, + id->keypairs[0]->private_key); - /* crypto_box key pair */ + /* crypto_sign key pair */ id->keypairs[1]=calloc(sizeof(keypair),1); if (!id->keypairs[1]) { WHY("calloc() failed preparing second key pair storage"); @@ -869,7 +873,6 @@ keyring_identity *keyring_create_identity(keyring_file *k,keyring_context *c, WHY("malloc() failed preparing second public key storage"); goto kci_safeexit; } -#warning XXX - Doesnt make sure that public key first nybl is >0 - 1 in 16 identities will be invalid crypto_sign_edwards25519sha512batch_keypair(id->keypairs[1]->public_key, id->keypairs[1]->private_key);