//
// BN_hex2bn from 0x7d77ac to 0x7d795c (432 bytes)
//
// 4 xrefs:
// > BN_asc2bn @ 0x7d7b84
// > s2i_ASN1_INTEGER @ 0x85d0d0
// > EC_POINT_hex2point @ 0x88b6d0
// > ??> @ 0x5feec
//
// 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
//
int __fastcall BN_hex2bn(int ***a1, _BYTE *a2)
{
_BYTE *v2; // r6
int v3; // r3
_BYTE *v4; // r2
int v5; // r5
int v6; // t1
int v7; // r1
int **v8; // r9
int v10; // r1
int v11; // r7
int *v12; // r8
int v13; // r3
unsigned __int8 *v14; // r10
int v15; // r11
int v16; // t1
int v17; // r0
int *v18; // r3
_BOOL4 v20; // [sp+8h] [bp-Ch]
int v21; // [sp+Ch] [bp-8h]
v2 = a2;
if ( !a2 )
return 0;
v3 = (unsigned __int8)*a2;
if ( !*a2 )
return 0;
v20 = v3 == 45;
if ( v3 == 45 )
v2 = a2 + 1;
v4 = v2 - 1;
v5 = 0;
while ( 1 )
{
v6 = (unsigned __int8)*++v4;
v7 = *(_BYTE *)(ctype_ + v6 + 1) & 0x44;
if ( (*(_BYTE *)(ctype_ + v6 + 1) & 0x44) == 0 )
break;
if ( ++v5 == 0x20000000 )
{
v8 = nullptr;
goto LABEL_11;
}
}
if ( v5 )
{
v21 = v20 + v5;
if ( !a1 )
return v20 + v5;
v8 = *a1;
if ( *a1 )
{
BN_set_word(*a1, v7);
}
else
{
v8 = (int **)BN_new();
if ( !v8 )
return 0;
}
if ( 4 * v5 <= 2147483616 )
{
v10 = (4 * v5 + 31) >> 5;
if ( v10 <= (int)v8[2] || bn_expand2((int)v8, v10) )
{
v11 = 0;
v12 = nullptr;
do
{
if ( v5 > 8 )
v13 = v5 - 8;
else
v13 = 0;
v14 = &v2[v13];
v15 = 0;
do
{
v16 = *v14++;
v17 = OPENSSL_hexchar2int(v16);
v15 = v17 & ~(v17 >> 31) | (16 * v15);
}
while ( v14 != &v2[v5] );
v5 -= 8;
(*v8)[v11] = v15;
v12 = (int *)((char *)v12 + 1);
++v11;
}
while ( v5 > 0 );
v8[1] = v12;
bn_correct_top(v8);
v18 = v8[1];
*a1 = v8;
if ( v18 )
v8[3] = (int *)v20;
return v21;
}
}
}
else
{
v8 = nullptr;
}
LABEL_11:
if ( *a1 )
return 0;
BN_free((int)v8);
return 0;
}