| CMS_SIGN(3) | Library Functions Manual | CMS_SIGN(3) |
CMS_sign — create
a CMS SignedData structure
#include
<openssl/cms.h>
CMS_ContentInfo *
CMS_sign(X509 *signcert,
EVP_PKEY *pkey, STACK_OF(X509)
*certs, BIO *data, unsigned int
flags);
CMS_sign()
creates and returns a CMS SignedData structure.
signcert is the certificate to sign with,
pkey is the corresponding private key.
certs is an optional additional set of certificates to
include in the CMS structure (for example any intermediate CAs in the
chain). Any or all of these parameters can be
NULL.
The data to be signed is read from data.
Any of the following flags (OR'ed together) can be passed in the flags argument:
CMS_TEXTCMS_NOCERTSCMS_DETACHEDCMS_BINARYCMS_NOATTRCMS_NOSMIMECAPCMS_USE_KEYIDCMS_STREAMCMS_PARTIALIf a signer is specified, it will use the default digest for the signing algorithm. This is SHA1 for both RSA and DSA keys.
If signcert and pkey
are NULL, then a certificates only CMS structure is
output.
The function
CMS_sign()
is a basic CMS signing function whose output will be suitable for many
purposes. For finer control of the output format the
certs, signcert and
pkey parameters can all be
NULL and the CMS_PARTIAL
flag set. Then one or more signers can be added using the function
CMS_add1_signer(3), non
default digests can be used and custom attributes added.
CMS_final(3) must then be
called to finalize the structure if streaming is not enabled.
CMS_sign() returns either a valid
CMS_ContentInfo structure or
NULL if an error occurred. The error can be obtained
from ERR_get_error(3).
CMS_add0_cert(3), CMS_add1_signer(3), CMS_ContentInfo_new(3), CMS_final(3), CMS_sign_receipt(3), CMS_verify(3)
RFC 5652: Cryptographic Message Syntax (CMS)
RFC 8419: Use of Edwards-Curve Digital Signature Algorithm (EdDSA) Signatures in the Cryptographic Message Syntax (CMS)
RFC 8551: Secure/Multipurpose Internet Mail Extensions (S/MIME) Version 4.0 Message Specification, section 2.5.2: SMIMECapabilities Attribute
CMS_sign() first appeared in OpenSSL
0.9.8h and has been available since OpenBSD 6.7.
Some attributes such as counter signatures are not supported.
| April 18, 2024 | openbsd |