CMS_GET0_TYPE(3)
π CMS_GET0_TYPE π
okay so this is the CMS_GET0_TYPE(3) page from the Library Functions Manual, and honestly? it's giving "functions that peek at your CMS content and sometimes poke it." bestie, let's get into it π«Ά
β¨ NAME β¨
CMS_get0_type, CMS_get_version, CMS_set1_eContentType, CMS_get0_eContentType, CMS_get0_content β the little squad that gets and sets CMS content types and content π
πΈ SYNOPSIS πΈ
library "libcrypto"
#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 π¦
π« CMS_get0_type()
CMS_get0_type() hands you back the content type of the ContentInfo structure cms. The ASN1_OBJECT value you get can be converted into an integer NID value using OBJ_obj2nid(3) β so worth it, iykyk.
The following content types are identified by the following NIDs (yes, this is the whole list, no gatekeeping here π):
SignedDataβNID_pkcs7_signedEnvelopedDataβNID_pkcs7_envelopedDigestedDataβNID_pkcs7_digestEncryptedDataβNID_pkcs7_encryptedAuthenticatedDataβNID_id_smime_ct_authDataCompressedDataβNID_id_smime_ct_compressedData- arbitrary data β
NID_pkcs7_data
π§ the embedded content situation
So 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. cute, right?
The type of that embedded content β the stuff you're storing in that field β can be set with CMS_set1_eContentType(). Call it 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 π so like, please don't.
Also lowkey important: CMS_set1_eContentType() copies the supplied oid, so it should be freed up after use. don't be out here leaking, bestie π
π CMS_get_version()
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. so like, don't trust it, it's giving chaos π
β CMS_get0_eContentType()
CMS_get0_eContentType() returns the type of the embedded content. that's it, that's the whole vibe β¨
π CMS_get0_content()
CMS_get0_content() returns a pointer to the storage location where the pointer to the embedded content is stored. which means that, for example, after
ASN1_OCTET_STRING **pconf = CMS_get0_content(cms);
*pconf could be NULL if there is no embedded content. main character emptiness, honestly.
Applications can access, modify or create the embedded content in a CMS_ContentInfo structure using this function. That said, applications usually will not need to modify the embedded content, as it is normally set by higher level functions. so like, hands off unless you know what you're doing π
π RETURN VALUES π
CMS_get0_type()andCMS_get0_eContentType()return internal pointers toOBJECT IDENTIFIERstructures.CMS_get_version()returns1on success and0on failure.CMS_get0_content()returns an internal pointer to the storage location where the pointer to the embedded content is stored.CMS_set1_eContentType()returns1for success or0if an error occurred. The error can be obtained fromERR_get_error(3).
π₯ SEE ALSO π₯
go read them, they're literally right there π
π STANDARDS π
RFC 5652: Cryptographic Message SyntaxRFC 3274: Compressed Data Content Type for Cryptographic Message Syntax (CMS)
we love a documented queen πΈ
π 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.
okay that's the whole page, slay π«Ά this Debian build is dated June 8, 2025, and you've been reading CMS_GET0_TYPE(3) β no cap, go forth and get your content types πβ¨
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2019 Ingo Schwarze <schwarze@openbsd.org>
- Copyright (c) 2008, 2015 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms