//
// BN_to_ASN1_ENUMERATED from 0xa7781c to 0xa77954 (312 bytes)
//
// 1 xrefs:
// > ??> @ 0x8337c
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:08:44 +0000
//
int __fastcall BN_to_ASN1_ENUMERATED(_DWORD *a1, int a2, int a3, int a4)
{
int v6; // r5
int v7; // r0
int v8; // r4
int v9; // r4
int v11; // r0
if ( a2 )
a4 = 10;
if ( a2 )
{
*(_DWORD *)(a2 + 4) = a4;
v6 = a2;
}
else
{
v11 = ASN1_STRING_type_new(10);
v6 = v11;
if ( !v11 )
{
ERR_put_error(13, 229, 58, (int)"crypto/asn1/a_int.c", 484);
return 0;
}
}
if ( BN_is_negative((int)a1) && !BN_is_zero((int)a1) )
*(_DWORD *)(v6 + 4) |= 0x102u;
v7 = BN_num_bits(a1);
v8 = v7 + 7;
if ( v7 + 7 < 0 )
v8 = v7 + 14;
v9 = v8 >> 3;
if ( !v9 )
v9 = 1;
if ( ASN1_STRING_set((signed int *)v6, nullptr, v9) )
{
if ( BN_is_zero((int)a1) )
**(_BYTE **)(v6 + 8) = 0;
else
v9 = BN_bn2bin(a1, *(_BYTE **)(v6 + 8));
*(_DWORD *)v6 = v9;
return v6;
}
else
{
ERR_put_error(13, 229, 65, (int)"crypto/asn1/a_int.c", 497);
if ( a2 != v6 )
ASN1_INTEGER_free(v6);
return 0;
}
}