//
// HMAC_Init_ex from 0xdafaa4 to 0xdafe04 (864 bytes)
//
// 14 xrefs:
// > tls_construct_new_session_ticket @ 0xd54384
// > tls_check_serverhello_tlsext_early @ 0xd578c0
// > sub_DAF5A4 @ 0xdaf604
// > HMAC_Init @ 0xdb0064
// > HMAC @ 0xdb01cc
// > sub_DB2434 @ 0xdb24e4
// > sub_DB2434 @ 0xdb2598
// > PKCS12_gen_mac @ 0xdcaa28
// > PKCS12_verify_mac @ 0xdcacc4
// > PKCS12_set_mac @ 0xdcb1f4
// > PKCS5_PBKDF2_HMAC @ 0xe623bc
// > PKCS5_PBKDF2_HMAC @ 0xe62a38
// > PKCS5_PBKDF2_HMAC @ 0xe62aa4
// > ??> @ 0xa2fc0
//
// 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
//
bool __fastcall HMAC_Init_ex(__int64 a1, const void *a2, unsigned int a3, __int64 a4, __int64 a5)
{
__int64 v5; // x20
unsigned int v8; // w21
int v10; // w0
__int64 v12; // x0
__int64 v13; // x20
__int64 v14; // [xsp+A8h] [xbp+A8h]
v5 = a4;
v8 = a3;
if ( a4 )
{
if ( *(_QWORD *)a1 == a4 )
{
*(_QWORD *)a1 = a4;
if ( !a2 )
{
LABEL_13:
if ( !(unsigned int)EVP_DigestInit_ex(*(__int64 **)(a1 + 16), v5, a5) )
return 0;
v14 = *(_QWORD *)(a1 + 16);
EVP_MD_block_size(v5);
if ( !(unsigned int)EVP_DigestUpdate(v14) )
return 0;
if ( !(unsigned int)EVP_DigestInit_ex(*(__int64 **)(a1 + 24), v5, a5) )
return 0;
v12 = v5;
v13 = *(_QWORD *)(a1 + 24);
EVP_MD_block_size(v12);
if ( !(unsigned int)EVP_DigestUpdate(v13) )
return 0;
return (unsigned int)EVP_MD_CTX_copy_ex(*(__int64 **)(a1 + 8), *(__int64 **)(a1 + 16)) != 0;
}
}
else
{
if ( !a2 || (a3 & 0x80000000) != 0 )
return 0;
*(_QWORD *)a1 = a4;
}
LABEL_6:
v10 = EVP_MD_block_size(v5);
if ( v10 > 128 )
OPENSSL_die("assertion failed: j <= (int)sizeof(ctx->key)", "crypto/hmac/hmac.c", 40);
if ( (int)v8 > v10 )
{
if ( !(unsigned int)EVP_DigestInit_ex(*(__int64 **)(a1 + 8), v5, a5)
|| !(unsigned int)EVP_DigestUpdate(*(_QWORD *)(a1 + 8))
|| !(unsigned int)EVP_DigestFinal_ex(*(int ***)(a1 + 8), a1 + 36, (_DWORD *)(a1 + 32)) )
{
return 0;
}
v8 = *(_DWORD *)(a1 + 32);
}
else
{
if ( v8 > 0x80 )
return 0;
memcpy((void *)(a1 + 36), a2, (int)v8);
*(_DWORD *)(a1 + 32) = v8;
}
if ( v8 != 128 )
memset((void *)(a1 + v8 + 36), 0, 128 - v8);
goto LABEL_13;
}
v5 = *(_QWORD *)a1;
if ( !*(_QWORD *)a1 )
return 0;
if ( a2 )
goto LABEL_6;
return (unsigned int)EVP_MD_CTX_copy_ex(*(__int64 **)(a1 + 8), *(__int64 **)(a1 + 16)) != 0;
}