libressl-CMS_get0_type3
Get and set cms content types and content
Usage
Crypto Library
(libcrypto,
-lcrypto)
const ASN1_OBJECT
*
int
int
const ASN1_OBJECT
*
ASN1_OCTET_STRING **
Overview
CMS_get0_type() returns the content type of the ContentInfo structure cms. The ASN1_OBJECT value returned can be converted to an integer NID value using OBJ_obj2nid(3). The following content types are identified by the following NIDs:
| SignedData | NID_pkcs7_signed |
| EnvelopedData | NID_pkcs7_enveloped |
| DigestedData | NID_pkcs7_digest |
| EncryptedData | NID_pkcs7_encrypted |
| AuthenticatedData | NID_id_smime_ct_authData |
| CompressedData | NID_id_smime_ct_compressedData |
| arbitrary data | NID_pkcs7_data |
The SignedData, DigestedData, AuthenticatedData, and CompressedData types contain a field encapContentInfo to allow embedding content, and EnvelopedData and EncryptedData contain a field encryptedContentInfo for that purpose. The type of the embedded content to be stored in that field can be set with the function CMS_set1_eContentType(), to be called on cms structures returned from functions such as CMS_sign(3) or CMS_encrypt(3) with the CMS_PARTIAL flag set and before the structure is finalised; otherwise the results are undefined. CMS_set1_eContentType() copies the supplied oid, so it should be freed up after use.
CMS_get_version() sets *version to the syntax version number of the ContentInfo structure cms. The version is a number between 0 and 5 and is defined for all the above content types except for arbitrary data. For arbitrary data and unsupported content types CMS_get_version() fails and the content of *version is unspecified.
CMS_get0_eContentType() returns the type of the embedded content.
CMS_get0_content() returns a pointer to the storage location where the pointer to the embedded content is stored. That means that for example after
ASN1_OCTET_STRING **pconf = CMS_get0_content(cms);
*pconf could be NULL if there is no embedded content. Applications can access, modify or create the embedded content in a CMS_ContentInfo structure using this function. Applications usually will not need to modify the embedded content as it is normally set by higher level functions.
Return values
CMS_get0_type() and CMS_get0_eContentType() return internal pointers to OBJECT IDENTIFIER structures.
CMS_get_version() returns 1 on success and 0 on failure.
CMS_get0_content() returns an internal pointer to the storage location where the pointer to the embedded content is stored.
CMS_set1_eContentType() returns 1 for success or 0 if an error occurred. The error can be obtained from ERR_get_error(3).