Using a PEM keyfile instead of a DER for the signing key

This commit is contained in:
Salvatore Ingala
2019-10-11 11:53:29 +07:00
parent 7c1d8b69c7
commit c6db6eddb3
3 changed files with 20 additions and 5 deletions

View File

@@ -1,6 +1,16 @@
import ecdsa
import os.path
from sys import exit
# Simple tool to generate an ECDSA private key using the secp256k1 curve and save it to signing_key.pem
FILE_NAME = 'signing_key.pem'
if __name__ == '__main__':
if os.path.exists(FILE_NAME):
print("A key with name \"{}\" already exists. Aborting.".format(FILE_NAME))
exit(1)
sk = ecdsa.SigningKey.generate(curve=ecdsa.SECP256k1)
print(sk.to_der())
open(FILE_NAME, 'wb').write(sk.to_pem())
print("Saved key \"{}\".".format(FILE_NAME))