//
// BN_to_ASN1_ENUMERATED from 0xe0b02c to 0xe0b174 (328 bytes)
//
// 1 xrefs:
// > ??> @ 0x39450
//
// 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_to_ASN1_ENUMERATED(_QWORD *a1, __int64 a2)
{
__int64 v4; // x19
int v5; // w0
int v6; // w3
int v7; // w20
if ( a2 )
{
v4 = a2;
*(_DWORD *)(a2 + 4) = 10;
}
else
{
v4 = ASN1_STRING_type_new(10);
if ( !v4 )
{
ERR_put_error(13, 229, 58, (__int64)"crypto/asn1/a_int.c", 484);
return 0;
}
}
if ( BN_is_negative((__int64)a1) && !BN_is_zero((__int64)a1) )
*(_DWORD *)(v4 + 4) |= 0x102u;
v5 = BN_num_bits((__int64)a1);
v6 = v5 + 7;
if ( v5 + 7 < 0 )
v6 = v5 + 14;
v7 = v6 >> 3;
if ( !(v6 >> 3) )
v7 = 1;
if ( (unsigned int)ASN1_STRING_set(v4, nullptr, v7) )
{
if ( BN_is_zero((__int64)a1) )
**(_BYTE **)(v4 + 8) = 0;
else
v7 = BN_bn2bin(a1, *(_BYTE **)(v4 + 8));
*(_DWORD *)v4 = v7;
return v4;
}
else
{
ERR_put_error(13, 229, 65, (__int64)"crypto/asn1/a_int.c", 497);
if ( a2 != v4 )
ASN1_INTEGER_free(v4);
return 0;
}
}