1#------------------------------------------------------------------------------- 2# Copyright (c) 2022, Arm Limited. All rights reserved. 3# 4# SPDX-License-Identifier: BSD-3-Clause 5# 6#------------------------------------------------------------------------------- 7 8import argparse 9import ecdsa 10 11parser = argparse.ArgumentParser() 12parser.add_argument("--input_key_file", help="the input key in binary format", required=True) 13parser.add_argument("--output_key_file", help="the file to output the pem key to", required=True) 14args = parser.parse_args() 15 16with open(args.input_key_file, "rb") as in_file: 17 input_key = in_file.read() 18 19# Remove fixed 0x04 byte from the start of the key before processing 20key = ecdsa.VerifyingKey.from_string(input_key[1:], curve=ecdsa.NIST384p) 21output_key = key.to_pem() 22 23with open(args.output_key_file, "wb") as out_file: 24 out_file.write(output_key) 25