//
// ECDH_KDF_X9_62 from 0xe35080 to 0xe35230 (432 bytes)
//
// 2 xrefs:
// > sub_E34B44 @ 0xe34c60
// > ??> @ 0x31938
//
// 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 ECDH_KDF_X9_62(
char *a1,
unsigned __int64 a2,
__int64 a3,
unsigned __int64 a4,
__int64 a5,
unsigned __int64 a6,
__int64 a7)
{
size_t v7; // x21
__int64 *v10; // x20
int v11; // w19
unsigned __int64 v12; // x22
int v13; // w0
__int64 v14; // x1
unsigned int v15; // w19
_BYTE v18[64]; // [xsp+80h] [xbp+80h] BYREF
v7 = a2;
if ( a2 > 0x40000000 || a4 > 0x40000000 )
return 0;
if ( a6 > 0x40000000 )
return 0;
v10 = (__int64 *)EVP_MD_CTX_new();
if ( !v10 )
return 0;
v11 = 1;
v12 = (int)EVP_MD_size(a7);
while ( 1 )
{
if ( !(unsigned int)EVP_DigestInit_ex(v10, a7, 0) )
goto LABEL_13;
++v11;
if ( !(unsigned int)EVP_DigestUpdate((__int64)v10) )
goto LABEL_13;
if ( !(unsigned int)EVP_DigestUpdate((__int64)v10) )
goto LABEL_13;
v13 = EVP_DigestUpdate((__int64)v10);
v14 = (__int64)a1;
if ( !v13 )
goto LABEL_13;
if ( v7 < v12 )
break;
a1 += v12;
v7 -= v12;
if ( !(unsigned int)EVP_DigestFinal((int **)v10, v14, nullptr) )
goto LABEL_13;
if ( !v7 )
goto LABEL_18;
}
if ( !(unsigned int)EVP_DigestFinal((int **)v10, (__int64)v18, nullptr) )
{
LABEL_13:
v15 = 0;
goto LABEL_14;
}
memcpy(a1, v18, v7);
OPENSSL_cleanse(v18, v12);
LABEL_18:
v15 = 1;
LABEL_14:
EVP_MD_CTX_free(v10);
return v15;
}