//
// PKCS12_setup_mac from 0xdcaec4 to 0xdcb0c0 (508 bytes)
//
// 2 xrefs:
// > PKCS12_set_mac @ 0xdcb104
// > ??> @ 0x692b8
//
// 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
//
__int64 __fastcall PKCS12_setup_mac(__int64 a1, int a2, const void *a3, int a4, unsigned int *a5)
{
__int64 v10; // x0
__int64 v11; // x20
__int64 v12; // x0
unsigned int v13; // w19
size_t v14; // x23
__int64 v15; // x27
void *v16; // x0
__int64 v17; // x1
void *v18; // x0
__int64 *v19; // x19
unsigned int v20; // w0
char **v21; // x0
__int64 *v23; // [xsp+68h] [xbp+68h] BYREF
v10 = PKCS12_MAC_DATA_new();
*(_QWORD *)(a1 + 8) = v10;
v11 = v10;
if ( !v10 )
return 0;
if ( a2 > 1 )
{
v12 = ASN1_INTEGER_new();
*(_QWORD *)(v11 + 16) = v12;
v13 = v12;
if ( !v12 )
{
ERR_put_error(35, 122, 65, (__int64)"crypto/pkcs12/p12_mutl.c", 211);
return v13;
}
v13 = ASN1_INTEGER_set(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 16LL), a2);
if ( !v13 )
{
ERR_put_error(35, 122, 65, (__int64)"crypto/pkcs12/p12_mutl.c", 215);
return v13;
}
v11 = *(_QWORD *)(a1 + 8);
}
v14 = a4;
if ( !a4 )
{
v14 = 8;
a4 = 8;
}
v15 = *(_QWORD *)(v11 + 8);
v16 = CRYPTO_malloc((void *)v14, (__int64)"crypto/pkcs12/p12_mutl.c", 221);
*(_QWORD *)(v15 + 8) = v16;
v13 = (unsigned int)v16;
if ( !v16 )
{
ERR_put_error(35, 122, 65, (__int64)"crypto/pkcs12/p12_mutl.c", 222);
return v13;
}
v17 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL);
*(_DWORD *)v17 = a4;
v18 = *(void **)(v17 + 8);
if ( !a3 )
{
if ( (int)RAND_bytes(v18, (unsigned int)a4) > 0 )
goto LABEL_11;
return 0;
}
memcpy(v18, a3, v14);
LABEL_11:
X509_SIG_getm(**(_QWORD **)(a1 + 8), &v23, 0);
v19 = v23;
v20 = EVP_MD_type(a5);
v21 = OBJ_nid2obj(v20);
if ( (unsigned int)X509_ALGOR_set0(v19, (__int64)v21, 5u, 0) )
return 1;
ERR_put_error(35, 122, 65, (__int64)"crypto/pkcs12/p12_mutl.c", 234);
return 0;
}