CMS_GET0_TYPE(3ossl)

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

πŸ’… CMS_GET0_TYPE πŸ’…

okay so this is a page from the OpenSSL manual, and it's all about getting and setting CMS content types and content. bestie, if you've ever been like "what even IS inside this CMS_ContentInfo" β€” this is your girl. let's go πŸŽ€


✨ NAME ✨

CMS_get0_type, 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_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() hands you the content type of a CMS_ContentInfo structure, as an ASN1_OBJECT pointer. so then your app can look at that value and go "okay, this is what we're dealing with" and decide how to process the whole CMS_ContentInfo structure. main character decision-making energy πŸ‘‘

CMS_set1_eContentType() sets the embedded content type of a CMS_ContentInfo structure. important vibe check: you call it with CMS functions (like CMS_sign(3), CMS_encrypt(3)) using the CMS_PARTIAL flag, and you do it before the structure gets finalised β€” otherwise the results are undefined 😭 (like, genuinely undefined, not cute-undefined, keep it in order fr fr).

ASN1_OBJECT *CMS_get0_eContentType() returns a pointer to the embedded content type. literally just points at it 🫢

CMS_get0_content() returns a pointer to the ASN1_OCTET_STRING pointer containing the embedded content. yes, a pointer to a pointer, it's giving inception πŸ’€


✨ NOTES ✨

so the 0 in the name is a whole thing β€” as that 0 implies, CMS_get0_type(), CMS_get0_eContentType() and CMS_get0_content() all return internal pointers, and you should not free them. hands off, bestie πŸ™ˆ

meanwhile CMS_set1_eContentType() copies the OID you supply, so that one you should free up after use. different rules, don't mix them up ✨

the ASN1_OBJECT values you get back can be converted to an integer NID value using OBJ_obj2nid(). for the currently supported content types, these are the values you get:

NID_pkcs7_data
NID_pkcs7_signed
NID_pkcs7_digest
NID_id_smime_ct_compressedData:
NID_pkcs7_encrypted
NID_pkcs7_enveloped

and about the return value of CMS_get0_content() β€” it's a pointer to the ASN1_OCTET_STRING content pointer. which means, for example:

ASN1_OCTET_STRING **pconf = CMS_get0_content(cms);

that *pconf could be NULL if there's no embedded content. 😢 applications can use this function to access, modify or create the embedded content in a CMS_ContentInfo structure. that said, apps usually won't need to modify the embedded content, because it's normally set by higher level functions. let them cook πŸ“


✨ RETURN VALUES ✨

  • CMS_get0_type() and CMS_get0_eContentType() return an ASN1_OBJECT structure. πŸ¦‹
  • CMS_set1_eContentType() returns 1 for success or 0 if an error occurred. the error can be obtained from ERR_get_error(3). slay, but like, slay-with-error-handling πŸ”₯

✨ SEE ALSO ✨

ERR_get_error(3) πŸ‘‘


Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved. πŸ’œ

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


and that's the whole page, bestie 🌈 β€” this was OpenSSL 3.5.0, dated 2026-09-25, filed under CMS_GET0_TYPE(3ossl). go forth and type-check your CMS content, ily, mwah πŸ’…πŸ’–βœ¨

πŸ“¦ where this page comes from