SMIME_READ_ASN1(3ossl)
π SMIME_read_ASN1(3ossl) π
okay bestie, pull up a chair, we're reading the SMIME_read_ASN1(3ossl) manual page together and honestly? it's giving β¨parsingβ¨. let's go π«Ά
β¨ NAME β¨
SMIME_read_ASN1_ex, SMIME_read_ASN1 β parse an S/MIME message π
πΈ SYNOPSIS πΈ
#include <openssl/asn1.h>
ASN1_VALUE *SMIME_read_ASN1_ex(BIO *in, int flags, BIO **bcont,
const ASN1_ITEM *it, ASN1_VALUE **x,
OSSL_LIB_CTX *libctx, const char *propq);
ASN1_VALUE *SMIME_read_ASN1(BIO *in, BIO **bcont, const ASN1_ITEM *it);
π¦ DESCRIPTION π¦
so SMIME_read_ASN1_ex() parses a message that's in S/MIME format. no cap, that's literally the whole job π
in is a BIO β that's where we read the message from, bestie.
now the flags tea β: if flags contains CMS_BINARY, then the input is assumed to be in binary format and is not translated to canonical form. and if in addition SMIME_ASCIICRLF is set? then the binary input is assumed to be followed by CR and LF characters. otherwise it's only followed by an LF character. periodt.
x can be used to optionally supply a previously created it ASN1_VALUE object (think CMS_ContentInfo or PKCS7 β iconic), and it can be set to NULL. the valid values that the ASN.1 structure it can use are ASN1_ITEM_rptr(PKCS7) or ASN1_ITEM_rptr(CMS_ContentInfo). π
any algorithm fetches that happen during the operation will use the OSSL_LIB_CTX you hand over in the libctx parameter, and they'll use the property query string propq. wanna know more about algorithm fetching? go read "ALGORITHM FETCHING" in crypto(7) for all the deets π
if cleartext signing is being used, then the content gets saved in a memory bio, which is written to *bcont. otherwise *bcont is set to NULL. simple as that π
the parsed ASN1_VALUE structure is returned β or NULL if an error occurred. no in-between, bestie π
and SMIME_read_ASN1()? it's similar to SMIME_read_ASN1_ex() but it sets the value of x to NULL and the value of flags to 0. the low-effort sibling, we love her π
π NOTES π
okay real talk: the higher level functions SMIME_read_CMS_ex(3) and SMIME_read_PKCS7_ex(3) should be used instead of SMIME_read_ASN1_ex(). like, use those. fr fr.
and to support future functionality, if bcont is not NULL, then *bcont should be initialized to NULL. do it for future-you π«Ά
π BUGS π
ngl, the MIME parser used by SMIME_read_ASN1_ex() is somewhat primitive. it will handle most S/MIME messages, but more complex compound formats may not work. it's doing its best π
also, the use of a memory BIO to hold the signed content limits the size of message which can be processed due to memory restraints β a streaming single pass option should be available. it's not. we're manifesting it though π
π RETURN VALUES π
SMIME_read_ASN1_ex() and SMIME_read_ASN1() return a valid ASN1_VALUE structure, or NULL if an error occurred. the error can be obtained from ERR_get_error(3) β go check it, that's where the lore is π
β SEE ALSO β
ERR_get_error(3)SMIME_read_CMS_ex(3)SMIME_read_PKCS7_ex(3)SMIME_write_ASN1(3)SMIME_write_ASN1_ex(3)
π HISTORY π
the function SMIME_read_ASN1_ex() was added in OpenSSL 3.0. a modern queen π
π COPYRIGHT π
Copyright 2020-2021 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 SMIME_read_ASN1(3ossl) from OpenSSL 3.5.9, dated 2026-09-29 β thanks for reading with me, mwah ππβ¨
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms