//
// PKCS12_setup_mac from 0xa3a2bc to 0xa3a47c (448 bytes)
//
// 2 xrefs:
// > PKCS12_set_mac @ 0xa3a4c0
// > ??> @ 0x7f2dc
//
// 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:10 +0000
//
int __fastcall PKCS12_setup_mac(int a1, int a2, const void *a3, void *a4, int a5)
{
_DWORD *v9; // r5
void *v10; // r4
int v11; // r5
_DWORD *v12; // r3
void *v13; // r0
_DWORD **v14; // r4
unsigned int v15; // r0
char **v16; // r0
_DWORD **v18; // [sp+Ch] [bp-4h] BYREF
v9 = PKCS12_MAC_DATA_new();
*(_DWORD *)(a1 + 4) = v9;
if ( !v9 )
return 0;
if ( a2 > 1 )
{
v10 = (void *)ASN1_INTEGER_new();
v9[2] = v10;
if ( v10 )
{
v10 = (void *)ASN1_INTEGER_set(*(_DWORD *)(*(_DWORD *)(a1 + 4) + 8), a2);
if ( v10 )
{
v9 = *(_DWORD **)(a1 + 4);
goto LABEL_6;
}
ERR_put_error(35, 122, 65, (int)"crypto/pkcs12/p12_mutl.c", 215);
}
else
{
ERR_put_error(35, 122, 65, (int)"crypto/pkcs12/p12_mutl.c", 211);
}
return (int)v10;
}
LABEL_6:
if ( !a4 )
a4 = byte_8;
v11 = v9[1];
v10 = CRYPTO_malloc(a4, (int)"crypto/pkcs12/p12_mutl.c", 221);
*(_DWORD *)(v11 + 8) = v10;
if ( !v10 )
{
ERR_put_error(35, 122, 65, (int)"crypto/pkcs12/p12_mutl.c", 222);
return (int)v10;
}
v12 = *(_DWORD **)(*(_DWORD *)(a1 + 4) + 4);
*v12 = a4;
v13 = (void *)v12[2];
if ( a3 )
{
memcpy(v13, a3, (size_t)a4);
LABEL_11:
X509_SIG_getm(**(_DWORD **)(a1 + 4), &v18, 0);
v14 = v18;
v15 = EVP_MD_type(a5);
v16 = OBJ_nid2obj(v15);
if ( !X509_ALGOR_set0(v14, v16, 5, 0) )
{
ERR_put_error(35, 122, 65, (int)"crypto/pkcs12/p12_mutl.c", 234);
return 0;
}
return 1;
}
if ( RAND_bytes(v13, a4) > 0 )
goto LABEL_11;
return 0;
}