Let's assume the following private key (in hex): dd1cd59c4de2fa92e363dac282afe790a5193177d413b38e206b2b86b879ffbf
.
I would like to sign a message with this private key via openSSL. OpenSSL requires a pem file as key. So I'm trying to convert the above hex string to a PEM file.
As far as I realized so far, I need to do the following steps:
- Add the following prefix to the hex string:
30740201010420
. - Add the following string after the hex string:
a00706052b8104000aa144034200
. - Add the public key
So I ended up with the following hex string: 30740201010420dd1cd59c4de2fa92e363dac282afe790a5193177d413b38e206b2b86b879ffbfa00706052b8104000aa144034200049d0f70eed85345ca5c1c04563bed19608562c37d644061785a836e8f199155f2818a1e2661f9ed501d8f906611892099a9de5a7ea9f641ecb4dd75bbb63c2d5a
.
I convert it to binary and base64 the result:
-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIN0c1ZxN4vqS42PawoKv55ClGTF31BOzjiBrK4a4ef+/oAcGBSuBBAAK
oUQDQgAEnQ9w7thTRcpcHARWO+0ZYIViw31kQGF4WoNujxmRVfKBih4mYfntUB2P
kGYRiSCZqd5afqn2Qey03XW7tjwtWg==
-----END EC PRIVATE KEY-----
Is this the proper way of doing it? Is this a valid PEM key?