//
// CMS_RecipientInfo_decrypt from 0xa880f8 to 0xa88534 (1084 bytes)
//
// 1 xrefs:
// > ??> @ 0x83bac
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:08:53 +0000
//
int __fastcall CMS_RecipientInfo_decrypt(int a1, _DWORD *a2)
{
_DWORD *v2; // r4
int v5; // r6
int v6; // r3
int v7; // r0
int v8; // r8
int *v9; // r0
void *v10; // r5
int v11; // r5
int v12; // r6
char *v13; // r0
int v14; // r1
void *v15; // r8
int v16; // r4
int v17; // r0
void *v18[62]; // [sp+Ch] [bp-F8h] BYREF
v2 = (_DWORD *)*a2;
if ( *a2 == 2 )
{
v11 = a2[1];
v2 = *(_DWORD **)(v11 + 16);
v12 = *(_DWORD *)(*(_DWORD *)(a1 + 4) + 12);
if ( !v2 )
{
ERR_put_error(46, 135, 130, (int)"crypto/cms/cms_env.c", 682);
return (int)v2;
}
v13 = OBJ_obj2nid(**(_DWORD **)(v11 + 8)) - 788;
if ( (unsigned int)v13 <= 2 )
{
v14 = dword_C5E858[(_DWORD)v13];
if ( *(_DWORD *)(v11 + 20) == v14 )
goto LABEL_18;
}
else
{
v14 = 0;
if ( !*(_DWORD *)(v11 + 20) )
{
LABEL_18:
if ( **(int **)(v11 + 12) > 15 )
{
if ( AES_set_decrypt_key(*(_DWORD *)(v11 + 16), 8 * v14, (unsigned int *)v18) )
{
ERR_put_error(46, 135, 115, (int)"crypto/cms/cms_env.c", 703);
v15 = nullptr;
}
else
{
v15 = CRYPTO_malloc((void *)(**(_DWORD **)(v11 + 12) - 8), (int)"crypto/cms/cms_env.c", 707);
if ( v15 )
{
v17 = AES_unwrap_key(v18, 0, v15, *(_DWORD *)(*(_DWORD *)(v11 + 12) + 8), **(_DWORD **)(v11 + 12));
if ( v17 > 0 )
{
v16 = 1;
*(_DWORD *)(v12 + 16) = v15;
*(_DWORD *)(v12 + 20) = v17;
goto LABEL_21;
}
ERR_put_error(46, 135, 157, (int)"crypto/cms/cms_env.c", 719);
}
else
{
ERR_put_error(46, 135, 65, (int)"crypto/cms/cms_env.c", 710);
}
}
}
else
{
ERR_put_error(46, 135, 117, (int)"crypto/cms/cms_env.c", 697);
v15 = nullptr;
}
CRYPTO_free(v15, (int)"crypto/cms/cms_env.c", 731);
v16 = 0;
LABEL_21:
OPENSSL_cleanse(v18, 0xF4u);
return v16;
}
}
ERR_put_error(46, 135, 118, (int)"crypto/cms/cms_env.c", 689);
return 0;
}
if ( v2 != (int *)((char *)&dword_0 + 3) )
{
if ( v2 )
{
ERR_put_error(46, 134, 155, (int)"crypto/cms/cms_env.c", 752);
return 0;
}
v5 = a2[1];
v6 = *(_DWORD *)(a1 + 4);
v7 = *(_DWORD *)(v5 + 20);
v8 = *(_DWORD *)(v6 + 12);
if ( !v7 )
{
ERR_put_error(46, 140, 133, (int)"crypto/cms/cms_env.c", 369);
return (int)v2;
}
v9 = (int *)EVP_PKEY_CTX_new(v7, (_DWORD *)*a2);
*(_DWORD *)(v5 + 24) = v9;
if ( !v9 )
return (int)v2;
if ( EVP_PKEY_decrypt_init(v9) > 0 && cms_env_asn1_ctrl(a2, 1) )
{
if ( EVP_PKEY_CTX_ctrl(*(_DWORD *)(v5 + 24), -1, 512) <= 0 )
{
ERR_put_error(46, 140, 110, (int)"crypto/cms/cms_env.c", 385);
v10 = nullptr;
goto LABEL_11;
}
if ( EVP_PKEY_decrypt(
*(int **)(v5 + 24),
0,
(unsigned int *)v18,
*(_DWORD *)(*(_DWORD *)(v5 + 12) + 8),
**(_DWORD **)(v5 + 12)) > 0 )
{
v10 = CRYPTO_malloc(v18[0], (int)"crypto/cms/cms_env.c", 394);
if ( v10 )
{
if ( EVP_PKEY_decrypt(
*(int **)(v5 + 24),
(int)v10,
(unsigned int *)v18,
*(_DWORD *)(*(_DWORD *)(v5 + 12) + 8),
**(_DWORD **)(v5 + 12)) > 0 )
{
CRYPTO_clear_free(*(_BYTE **)(v8 + 16), *(_DWORD *)(v8 + 20), (int)"crypto/cms/cms_env.c", 410);
*(void **)(v8 + 20) = v18[0];
*(_DWORD *)(v8 + 16) = v10;
EVP_PKEY_CTX_free(*(_DWORD *)(v5 + 24));
*(_DWORD *)(v5 + 24) = 0;
return 1;
}
ERR_put_error(46, 140, 104, (int)"crypto/cms/cms_env.c", 404);
}
else
{
ERR_put_error(46, 140, 65, (int)"crypto/cms/cms_env.c", 397);
}
goto LABEL_11;
}
}
v10 = nullptr;
LABEL_11:
EVP_PKEY_CTX_free(*(_DWORD *)(v5 + 24));
*(_DWORD *)(v5 + 24) = 0;
CRYPTO_free(v10, (int)"crypto/cms/cms_env.c", 418);
return 0;
}
return cms_RecipientInfo_pwri_crypt(a1);
}