//
// cms_SignedData_init_bio from 0xa8c2b0 to 0xa8c4e8 (568 bytes)
//
// 2 xrefs:
// > CMS_dataInit @ 0xa89cf8
// > ??> @ 0x83e7c
//
// 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:55 +0000
//
_DWORD *__fastcall cms_SignedData_init_bio(int *a1)
{
int v2; // r4
_DWORD *v4; // r6
signed int k; // r5
_DWORD *v6; // r0
_DWORD *inited; // r7
signed int i; // r5
int v9; // r3
signed int v10; // r5
int v11; // r0
unsigned int v12; // r1
bool v13; // cc
signed int j; // r5
int v15; // r0
int v16; // r3
int v17; // r3
if ( OBJ_obj2nid(*a1) == (_BYTE *)&dword_14 + 2 )
{
v2 = a1[1];
if ( v2 )
{
if ( *(_DWORD *)(*(_DWORD *)(v2 + 8) + 8) )
{
for ( i = 0; i < OPENSSL_sk_num(*(_DWORD *)(v2 + 12)); ++i )
{
v9 = *(_DWORD *)OPENSSL_sk_value(*(_DWORD **)(v2 + 12), i);
if ( v9 == 4 )
{
if ( *(int *)v2 <= 4 )
*(_DWORD *)v2 = 5;
}
else if ( v9 == 3 )
{
if ( *(int *)v2 <= 3 )
*(_DWORD *)v2 = 4;
}
else if ( v9 == 2 && *(int *)v2 <= 2 )
{
*(_DWORD *)v2 = 3;
}
}
v10 = 0;
while ( 1 )
{
v11 = OPENSSL_sk_num(*(_DWORD *)(v2 + 16));
v12 = v10;
v13 = v10++ < v11;
if ( !v13 )
break;
if ( *(_DWORD *)OPENSSL_sk_value(*(_DWORD **)(v2 + 16), v12) == 1 && *(int *)v2 <= 4 )
*(_DWORD *)v2 = 5;
}
if ( OBJ_obj2nid(**(_DWORD **)(v2 + 8)) != (_BYTE *)&dword_14 + 1 && *(int *)v2 <= 2 )
*(_DWORD *)v2 = 3;
for ( j = 0; j < OPENSSL_sk_num(*(_DWORD *)(v2 + 20)); ++j )
{
v15 = OPENSSL_sk_value(*(_DWORD **)(v2 + 20), j);
v16 = *(_DWORD *)v15;
if ( **(_DWORD **)(v15 + 4) == 1 )
{
v13 = v16 <= 2;
v17 = *(_DWORD *)v2;
if ( v13 )
*(_DWORD *)v15 = 3;
if ( v17 <= 2 )
*(_DWORD *)v2 = 3;
}
else if ( v16 <= 0 )
{
*(_DWORD *)v15 = 1;
}
}
if ( *(int *)v2 <= 0 )
*(_DWORD *)v2 = 1;
}
v4 = nullptr;
for ( k = 0; ; ++k )
{
if ( k >= OPENSSL_sk_num(*(_DWORD *)(v2 + 4)) )
return v4;
v6 = (_DWORD *)OPENSSL_sk_value(*(_DWORD **)(v2 + 4), k);
inited = cms_DigestAlgorithm_init_bio(v6);
if ( !inited )
break;
if ( v4 )
BIO_push(v4, (int)inited);
else
v4 = inited;
}
BIO_free_all((int)v4);
return nullptr;
}
else
{
return nullptr;
}
}
else
{
ERR_put_error(46, 133, 108, (int)"crypto/cms/cms_sd.c", 26);
return nullptr;
}
}