//
// sub_D85A44 from 0xd85a44 to 0xd85bb0 (364 bytes)
//
// 2 xrefs:
// > ??> @ 0x1122690
// > ??> @ 0x1122768
//
// 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 sub_D85A44(_QWORD *a1, __int64 a2)
{
_DWORD *v4; // x19
__int64 v5; // x0
_DWORD *v6; // x1
int v7; // w0
__int64 v8; // x0
__int64 v9; // x22
__int64 v10; // x0
int v11; // w0
unsigned int v12; // w1
int v14; // [xsp+48h] [xbp+48h]
__int64 v15; // [xsp+58h] [xbp+58h] BYREF
v15 = 0;
v4 = (_DWORD *)ASN1_STRING_new();
if ( !v4 )
{
ERR_put_error(5, 111, 65, "crypto/dh/dh_ameth.c", 212);
goto LABEL_7;
}
v5 = *(_QWORD *)(a2 + 32);
v6 = v4 + 2;
if ( *(_UNKNOWN **)(a2 + 16) == &dhx_asn1_meth )
v7 = i2d_DHxparams(v5, v6);
else
v7 = i2d_DHparams(v5, v6);
*v4 = v7;
if ( v7 <= 0 )
{
ERR_put_error(5, 111, 65, "crypto/dh/dh_ameth.c", 218);
goto LABEL_7;
}
v4[1] = 16;
v8 = BN_to_ASN1_INTEGER(*(_QWORD *)(*(_QWORD *)(a2 + 32) + 40LL), 0);
v9 = v8;
if ( !v8 )
{
ERR_put_error(5, 111, 106, "crypto/dh/dh_ameth.c", 227);
goto LABEL_7;
}
v14 = i2d_ASN1_INTEGER(v8, &v15);
ASN1_STRING_clear_free(v9);
v10 = OBJ_nid2obj(**(unsigned int **)(a2 + 16));
v11 = PKCS8_pkey_set0(a1, v10, 0, 0x10u, (__int64)v4, v15, v14);
v12 = 1;
if ( !v11 )
{
LABEL_7:
CRYPTO_free(v15, "crypto/dh/dh_ameth.c", 243);
ASN1_STRING_free((__int64)v4);
ASN1_STRING_clear_free(0);
return 0;
}
return v12;
}