CMS_GET0_TYPE(3ossl)
π 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()andCMS_get0_eContentType()return anASN1_OBJECTstructure. π¦CMS_set1_eContentType()returns1for success or0if an error occurred. the error can be obtained fromERR_get_error(3). slay, but like, slay-with-error-handling π₯
β¨ SEE ALSO β¨
ERR_get_error(3) π
β¨ COPYRIGHT β¨
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
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms