//
// BN_hex2bn from 0xd7dea0 to 0xd7e07c (476 bytes)
//
// 4 xrefs:
// > BN_asc2bn @ 0xd7e2d8
// > s2i_ASN1_INTEGER @ 0xe039d0
// > EC_POINT_hex2point @ 0xe35038
// > ??> @ 0x639f0
//
// 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 BN_hex2bn(__int64 *a1, _BYTE *a2)
{
_BYTE *v2; // x23
int v4; // s9
__int64 v5; // x21
int v6; // w22
unsigned int v7; // s10
__int64 v8; // x26
int v9; // w1
__int64 v10; // x24
int v11; // w25
int v12; // w19
unsigned __int64 v13; // x20
__int64 v14; // x0
unsigned __int8 *v15; // x19
unsigned __int8 *v16; // x27
unsigned int v17; // t1
int v18; // w0
int v19; // w2
int v20; // w1
__int64 result; // x0
v2 = a2;
if ( !a2 || !*a2 )
return 0;
v4 = 0;
if ( *a2 == 45 )
{
v2 = a2 + 1;
v4 = 1;
}
v5 = 0;
while ( 1 )
{
v6 = v5;
if ( !isxdigit((unsigned __int8)v2[v5]) )
break;
if ( ++v5 == 0x20000000 )
goto LABEL_26;
}
if ( !(_DWORD)v5 )
{
LABEL_26:
v8 = 0;
goto LABEL_27;
}
v7 = v4 + v5;
if ( !a1 )
return v7;
v8 = *a1;
if ( *a1 )
{
BN_set_word(*a1, 0);
}
else
{
v8 = BN_new();
if ( !v8 )
return 0;
}
if ( 4 * (int)v5 <= 2147483584 )
{
v9 = (4 * (int)v5 + 63) >> 6;
if ( v9 <= *(_DWORD *)(v8 + 12) || bn_expand2((unsigned __int64 *)v8, v9) )
{
v10 = 0;
v5 = (int)v5;
v11 = 0;
do
{
if ( v6 > 16 )
v12 = 16;
else
v12 = v6;
v13 = 0;
v14 = v5 + 1 - v12 + (unsigned int)(v12 - 1);
v15 = &v2[v5 - v12];
v16 = &v2[v14];
do
{
v17 = *v15++;
v18 = OPENSSL_hexchar2int(v17);
if ( v18 < 0 )
v19 = 0;
else
v19 = v18;
v13 = v19 | (16 * v13);
}
while ( v15 != v16 );
v6 -= 16;
++v11;
v5 -= 16;
*(_QWORD *)(*(_QWORD *)v8 + v10) = v13;
v10 += 8;
}
while ( v6 > 0 );
*(_DWORD *)(v8 + 8) = v11;
bn_correct_top(v8);
v20 = *(_DWORD *)(v8 + 8);
*a1 = v8;
result = v7;
if ( v20 )
*(_DWORD *)(v8 + 16) = v4;
return result;
}
}
LABEL_27:
if ( *a1 )
return 0;
BN_free(v8);
return 0;
}