How to sign programmatically
OpenSSL 3.0 provides the following APIs for digital signatures:
- Legacy low-level APIs that consist of functions with algorithm-specific prefixes, such as
RSA_
,DSA_
, andECDSA_
. These APIs have been deprecated since OpenSSL 3.0. - The
EVP_PKEY
API: This API is not deprecated but is still low level. It is more convenient to use a high-level API. - The
EVP_Sign
API: This API is high level but has some disadvantages. This API uses the key argument only after the whole input data has been read and hashed. Therefore, if there is a problem with the key, it will be discovered later rather than sooner. Another disadvantage is that this API is inflexible and does not allow you to set signing parameters toPKEY_CTX
if the signature algorithm supports them. The OpenSSL documentation does not recommend this API. - The
EVP_DigestSign
API: This is a high-level API where drawbacks of theEVP_Sign
API have been fixed. The OpenSSL documentation recommends...