CMS_GET0_TYPE(3)

πŸ“¦ version 4.1.0, in opensuse-leap 16.0

hey bestie πŸ’– welcome to CMS_GET0_TYPE(3) from the Library Functions Manual. this page is your group-chat explainer for getting and setting CMS content types and content, and honestly it's giving "crypto plumbing but make it iconic." let's go 🫢

✨ NAME ✨

CMS_get0_type, CMS_get_version, CMS_set1_eContentType, CMS_get0_eContentType, CMS_get0_content β€” get and set CMS content types and content πŸ’…

✨ SYNOPSIS ✨

#include <openssl/cms.h>

const ASN1_OBJECT *
CMS_get0_type(const CMS_ContentInfo *cms);

int
CMS_get_version(const CMS_ContentInfo *cms, long *version);

int
CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid);

const ASN1_OBJECT *
CMS_get0_eContentType(CMS_ContentInfo *cms);

ASN1_OCTET_STRING **
CMS_get0_content(CMS_ContentInfo *cms);

✨ DESCRIPTION ✨

okay so CMS_get0_type() returns the content type of the ContentInfo structure cms. the ASN1_OBJECT value it returns can be converted to an integer NID value using OBJ_obj2nid(3). here's the NID match-up, no cap:

  • 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).

✨ SEE ALSO ✨

✨ STANDARDS ✨

  • RFC 5652: Cryptographic Message Syntax
  • RFC 3274: Compressed Data Content Type for Cryptographic Message Syntax (CMS)

✨ HISTORY ✨

these functions first appeared in OpenSSL 0.9.8h and have been available since OpenBSD 6.7. 🌈

CMS_get_version() first appeared in OpenBSD 7.4. ⭐


xoxo, this page came from the Debian build, dated July 27, 2023, in the CMS_GET0_TYPE(3) / Library Functions Manual corner of the universe 🫢✨

πŸ“¦ where this page comes from