Closed macjohnny closed 4 years ago
Hi Esteban,
There may be cases where PKCS8/DER/PEM/... encoding may be necessary.
But outside of TLS, these have shown to be pretty rare.
Instead of trying to address one particular case, it would be better done as a distinct, standalone project, that properly handles different keys and signature encodings.
@jedisct1 how about extending the docs?
just now I discovered your project https://jedisct1.github.io/minisign/, which allows to verify the signature in the command line, thanks! Note: this requires implementing the format required by minisign when storing the key, which is different from binary-only or DER.
Context
Currently, a pair of public/private keys using the
Ed25519
can be created using thefunction described in https://libsodium.gitbook.io/doc/public-key_cryptography/public-key_signatures and used to sign a message with e.g. the following code snippet:
Feature Request
It would be useful to have a function e.g.
convert_key_to_der(unsigned char *public_key, unsigned char *public_key_der)
to convert the generatedpublic_key
into theDER
formatThis would allow to validate the
signature
(e.g. stored to a filesignature.bin
) ofmessage
(e.g. stored to a filemessage.bin
) to be validated against thepublic_key
(converted toDER
and e.g. stored to a filepublic_key.der
) with a command line tool such asopenssl
Note:
Ed25519
is only supported inopenssl>=3.0.0-alpha1
(https://github.com/openssl/openssl/issues/6988#issuecomment-618297128), which can be used e.g. like this:Proof of concept
A simple implementation to store the
public_key
to a validDER
format is as followsImplementation
The simple implementation consisting of prepending
kDerHeaderSequence
to thepublic_key
allows conversion without adding a dependence on a ASN.1 serializer. Analogously, this could also be done forprivate_key
. If you agree, I am willing to file a PR with such an implementation.Literature
Useful concerning private key: