I'm trying to use this ECDSA private key provided by ietf.org in OpenSSL (https://datatracker.ietf.org/doc/html/rfc6979#appendix-A.2.8):
x = 09A4D6792295A7F730FC3F2B49CBC0F62E862272F
I'd like to convert this hex key into the PEM format so that I can use it in OpenSSL for ECDSA sign/verification. From my research there is the possibility of creating a DER file by concatenating a header with my binary key and then converting it to PEM.
I generated a DER file with the result of an ECDSA header (first 7 bytes, from what I've seen, could be wrong) + my key in binary like this:
# converted my key to binary
xxd -r -p key.hex key.bin
# generated a key just to get its header
openssl ecparam -name sect163k1 -genkey -noout -out tempkey.pem
openssl ec -in tempkey.pem -outform der -out tempkey.der
head -c 7 tempkey.der > header.der
# concatenated the header with my key
cat header.der key.bin > key.der
Then ran the command to convert the key to PEM format:
openssl ec -in key.der -inform der -out key.pem
But this last steps fails with:
Could not read private key from key.der
unable to load Key