mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 06:04:21 +01:00
Using a PEM keyfile instead of a DER for the signing key
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user