//
// SMIME_read_ASN1 from 0xe712c0 to 0xe71848 (1416 bytes)
//
// 2 xrefs:
// > SMIME_read_CMS @ 0xe1eda4
// > ??> @ 0x35b50
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
int *__fastcall SMIME_read_ASN1(__int64 a1, __int64 *a2, __int64 a3)
{
int *v6; // x0
int *v7; // x19
int v8; // w1
__int64 v9; // x0
__int64 v10; // x21
const char *v11; // x20
__int64 v12; // x0
__int64 v13; // x0
_QWORD *v14; // x21
__int64 v15; // x20
__int64 v16; // x19
int v18; // w1
__int64 v19; // x0
char *v20; // x1
int v21; // w21
_QWORD *v22; // x24
int *v23; // x0
int *v24; // x19
int v25; // w1
__int64 v26; // x0
__int64 v27; // x23
const char *v28; // x21
__int64 v29; // x0
__int64 v30; // x0
_QWORD *v31; // x21
__int64 v32; // x20
int *v33; // [xsp+50h] [xbp+50h] BYREF
const char *v34; // [xsp+58h] [xbp+58h] BYREF
__int64 v35; // [xsp+60h] [xbp+60h]
__int64 v36; // [xsp+68h] [xbp+68h]
v33 = nullptr;
if ( a2 )
*a2 = 0;
v6 = sub_E70BD8(a1);
v7 = v6;
if ( !v6 )
{
ERR_put_error(13, 212, 207, (__int64)"crypto/asn1/asn_mime.c", 384);
return nullptr;
}
v35 = 0;
v34 = "content-type";
v36 = 0;
v8 = OPENSSL_sk_find((__int64)v6, (__int64)&v34);
if ( v8 < 0
|| (v9 = OPENSSL_sk_value((__int64)v7, v8), (v10 = v9) == 0)
|| (v11 = *(const char **)(v9 + 8)) == nullptr )
{
OPENSSL_sk_pop_free(v7, sub_E70690);
ERR_put_error(13, 212, 209, (__int64)"crypto/asn1/asn_mime.c", 391);
return nullptr;
}
if ( !strcmp(*(const char **)(v9 + 8), "multipart/signed") )
{
v35 = 0;
v34 = "boundary";
v18 = OPENSSL_sk_find(*(_QWORD *)(v10 + 16), (__int64)&v34);
if ( v18 < 0 || (v19 = OPENSSL_sk_value(*(_QWORD *)(v10 + 16), v18)) == 0 || (v20 = *(char **)(v19 + 8)) == nullptr )
{
OPENSSL_sk_pop_free(v7, sub_E70690);
ERR_put_error(13, 212, 211, (__int64)"crypto/asn1/asn_mime.c", 402);
return nullptr;
}
v21 = sub_E70980(a1, v20, &v33);
OPENSSL_sk_pop_free(v7, sub_E70690);
if ( v21 && (unsigned int)OPENSSL_sk_num((unsigned int *)v33) == 2 )
{
v22 = (_QWORD *)OPENSSL_sk_value((__int64)v33, 1);
v23 = sub_E70BD8((__int64)v22);
v24 = v23;
if ( !v23 )
{
ERR_put_error(13, 212, 208, (__int64)"crypto/asn1/asn_mime.c", 417);
LABEL_36:
OPENSSL_sk_pop_free(v33, (void (__fastcall *)(__int64))BIO_vfree);
return v24;
}
v35 = 0;
v34 = "content-type";
v36 = 0;
v25 = OPENSSL_sk_find((__int64)v23, (__int64)&v34);
if ( v25 < 0
|| (v26 = OPENSSL_sk_value((__int64)v24, v25), (v27 = v26) == 0)
|| (v28 = *(const char **)(v26 + 8)) == nullptr )
{
OPENSSL_sk_pop_free(v24, sub_E70690);
ERR_put_error(13, 212, 212, (__int64)"crypto/asn1/asn_mime.c", 427);
return nullptr;
}
if ( !strcmp(*(const char **)(v26 + 8), "application/x-pkcs7-signature")
|| !strcmp(v28, "application/pkcs7-signature") )
{
OPENSSL_sk_pop_free(v24, sub_E70690);
v29 = BIO_f_base64();
v30 = BIO_new(v29);
v31 = (_QWORD *)v30;
if ( v30 )
{
v32 = BIO_push(v30, (__int64)v22);
v24 = (int *)ASN1_item_d2i_bio(a3, v32, nullptr);
if ( v24 )
{
BIO_ctrl(v32, 0xBu, 0, 0);
BIO_pop(v32);
BIO_free(v31);
if ( a2 )
{
*a2 = OPENSSL_sk_value((__int64)v33, 0);
BIO_free(v22);
OPENSSL_sk_free((void **)v33);
return v24;
}
goto LABEL_36;
}
ERR_put_error(13, 209, 110, (__int64)"crypto/asn1/asn_mime.c", 143);
BIO_ctrl(v32, 0xBu, 0, 0);
BIO_pop(v32);
BIO_free(v31);
}
else
{
ERR_put_error(13, 209, 65, (__int64)"crypto/asn1/asn_mime.c", 137);
}
ERR_put_error(13, 212, 204, (__int64)"crypto/asn1/asn_mime.c", 442);
}
else
{
ERR_put_error(13, 212, 213, (__int64)"crypto/asn1/asn_mime.c", 433);
ERR_add_error_data(2, "type: ", *(_QWORD *)(v27 + 8));
OPENSSL_sk_pop_free(v24, sub_E70690);
}
}
else
{
ERR_put_error(13, 212, 210, (__int64)"crypto/asn1/asn_mime.c", 408);
}
OPENSSL_sk_pop_free(v33, (void (__fastcall *)(__int64))BIO_vfree);
return nullptr;
}
if ( strcmp(v11, "application/x-pkcs7-mime") && strcmp(v11, "application/pkcs7-mime") )
{
ERR_put_error(13, 212, 205, (__int64)"crypto/asn1/asn_mime.c", 460);
ERR_add_error_data(2, "type: ", *(_QWORD *)(v10 + 8));
OPENSSL_sk_pop_free(v7, sub_E70690);
return nullptr;
}
OPENSSL_sk_pop_free(v7, sub_E70690);
v12 = BIO_f_base64();
v13 = BIO_new(v12);
v14 = (_QWORD *)v13;
if ( !v13 )
{
ERR_put_error(13, 209, 65, (__int64)"crypto/asn1/asn_mime.c", 137);
goto LABEL_33;
}
v15 = BIO_push(v13, a1);
v16 = ASN1_item_d2i_bio(a3, v15, nullptr);
if ( !v16 )
{
ERR_put_error(13, 209, 110, (__int64)"crypto/asn1/asn_mime.c", 143);
BIO_ctrl(v15, 0xBu, 0, 0);
BIO_pop(v15);
BIO_free(v14);
LABEL_33:
ERR_put_error(13, 212, 203, (__int64)"crypto/asn1/asn_mime.c", 469);
return nullptr;
}
BIO_ctrl(v15, 0xBu, 0, 0);
BIO_pop(v15);
BIO_free(v14);
return (int *)v16;
}