SMIME_READ_ASN1(3ossl)
π SMIME_READ_ASN1 β parse S/MIME message (3ossl, bestie edition)
okay so picture this: it's giving OpenSSL 3ossl energy, and this page is literally all about SMIME_read_ASN1_ex and SMIME_read_ASN1 β the two functions that parse an S/MIME message for you. no cap, they're the main characters here. π
β¨ 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. that's the whole vibe. π
in is the BIO you're reading the message from β like, that's your source, bestie.
If the flags argument contains CMS_BINARY, then the input is assumed to be in binary format and is not translated to canonical form. and if, on top of that, SMIME_ASCIICRLF is also set, then the binary input is assumed to be followed by CR and LF characters β otherwise it's only followed by an LF character. details matter, okay?? π
x is optional and kinda cute: you can use it to supply a previously created it ASN1_VALUE object (think CMS_ContentInfo or PKCS7), and you can also just set it to NULL. totally your call. the valid values that can be used by the ASN.1 structure it are:
ASN1_ITEM_rptr(PKCS7)ASN1_ITEM_rptr(CMS_ContentInfo)
Any algorithm fetches that happen during the operation will use the OSSL_LIB_CTX supplied in the libctx parameter, and use the property query string propq. (btw see "ALGORITHM FETCHING" in crypto(7) for further details about algorithm fetching β iykyk.)
If cleartext signing is used, then the content is saved in a memory bio which is written to *bcont β otherwise *bcont is set to NULL. slay.
The parsed ASN1_VALUE structure is returned, or NULL if an error occurred. π
SMIME_read_ASN1() is basically the chill sibling of SMIME_read_ASN1_ex() β it's similar, except it sets the value of x to NULL and the value of flags to 0.
πΈ NOTES πΈ
okay genuine advice time: 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, those are the ones you actually want. π«Ά
Also β to support future functionality, if bcont is not NULL, then *bcont should be initialized to NULL. tiny habit, big glow-up. β¨
π 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. π not its fault, it's just doing its best.
And 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. manifesting that for a future release, fr fr. π
π 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). periodt. π
π 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. iconic behavior. π
π 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 OpenSSL 3.5.0, dated 2026-09-25 β mwah, catch you on the next man page ππ₯
π¦ 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