SeattleTestbed / softwareupdater

Software updater daemon
MIT License
1 stars 6 forks source link

generatekeys.py gives incorrect key values #53

Open asm582 opened 9 years ago

asm582 commented 9 years ago

when we run generatekeys.py over an existing key, it gives some weird keys! below is observed behavior, as shared by albert as well:-

python generatekeys.py abc 4096 Generating key files called 'abc.publickey' and 'abc.privatekey' of length 4096. This may take a moment... Success! $ wc abc 0 3 2469 abc.privatekey 0 2 1239 abc.publickey 0 5 3708 total $ openssl md5 abc MD5(abc.privatekey)= a510da7973bce6e114a7277ab1d7c122 MD5(abc.publickey)= f700ed9253d5f4f54d5054c89d39fe9e

Okay, that's the 4096-bit key's stats. Recreate using the same key name but shorter (!) length:

$ python generatekeys.py abc 1024 Generating key files called 'abc.publickey' and 'abc.privatekey' of length 1024. This may take a moment... Success! $ wc abc 0 5 2469 abc.privatekey 0 2 1239 abc.publickey 0 7 3708 total $ openssl md5 abc MD5(abc.privatekey)= f2d4f2f15071705b11a1efa926f8ff94 MD5(abc.publickey)= 1c25c843d8dd171e6f3280650bfecc3c

Ouch, file size didn't change, but contents changed. This must not happen.

For comparison, a proper 1024-bit key has much smaller files:

$ python generatekeys.py def 1024 Generating key files called 'def.publickey' and 'def.privatekey' of length 1024. This may take a moment... Success! $ wc def* 0 3 619 def.privatekey 0 2 314 def.publickey 0 5 933 total

asm582 commented 9 years ago

Can we add a check in generatekeys.py to check if file exists and i exists, clear the files and then generate keys in the file??