I am trying to use the OpenSSL command line to generate a ECDH public key that meets the following specifications:
Use a Base64 encoded X.509 SubjectPublicKeyInfo structure containing a ECDH public key for group P256
They following commands provide me with a key:
openssl ecparam -name prime256v1 -out prime256v1.pem
openssl ecparam -in prime256v1.pem -genkey -noout -out prime256v1-key.pem
openssl ec -in prime256v1-key.pem -pubout -out pubkey.pem
Key: MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE85KGK3YiX7tC7mFm+Te1xRYOeDq23h80MPPt1nMZ/ZRpwjRGPEUr6vaoOCB8QC3uHmaPKOAgQ0Kk9Sc4M1QUmA==
However this key is not being accepted by the API I am accessing.
An example key that is working is:
MDkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDIgACKoJz0lSBocGMsdl8TiMasRsBOxpMywCqzAoOLwZfUl0=
This example key is 44 (Base64) bytes shorter and has a slightly different SubjectPublickKeyInfo
signature.
My question is what is the difference between these two keys and how could I use the OpenSSL command line tools to generate such a key pair.