Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

generatekeys.py gives incorrect key values #53

@asm582

Description

@asm582

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions