//
// ossl_ecdsa_verify_sig from 0x10137bc to 0x1013cb4 (1272 bytes)
//
// 2 xrefs:
// > ??> @ 0x100cc0
// > ??> @ 0x1539e78
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// 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 13:16:03 +0000
//
__int64 __fastcall ossl_ecdsa_verify_sig(_BYTE *a1, int a2, __int64 *a3, __int64 a4)
{
__int64 *v8; // x21
_QWORD *v9; // x0
__int64 v10; // x1
__int64 v11; // x2
__int64 v12; // x0
__int64 v13; // x19
__int64 *v14; // d8
__int64 v15; // d9
__int64 v16; // x28
__int64 v17; // x24
__int64 *v18; // x25
_QWORD *v19; // x22
unsigned int v20; // w20
int v22; // w0
int v23; // w22
int v24; // w26
__int64 v25; // x0
if ( a4 && (v8 = (__int64 *)EC_KEY_get0_group(a4)) != nullptr && EC_KEY_get0_public_key(a4) && a3 )
{
v9 = EC_KEY_can_sign(a4);
if ( (_DWORD)v9 )
{
v12 = BN_CTX_new(v9, v10, v11);
v13 = v12;
if ( v12 )
{
BN_CTX_start(v12);
v14 = (__int64 *)BN_CTX_get(v13);
v15 = BN_CTX_get(v13);
v16 = BN_CTX_get(v13);
v17 = BN_CTX_get(v13);
if ( !v17 )
{
v19 = nullptr;
v20 = -1;
ERR_put_error(16, 250, 3, "crypto/ec/ecdsa_ossl.c", 378);
goto LABEL_11;
}
v18 = (__int64 *)EC_GROUP_get0_order((__int64)v8);
if ( !v18 )
{
v19 = nullptr;
v20 = -1;
ERR_put_error(16, 250, 16, "crypto/ec/ecdsa_ossl.c", 384);
goto LABEL_11;
}
if ( BN_is_zero(*a3)
|| BN_is_negative(*a3)
|| (BN_ucmp((__int64 *)*a3, v18) & 0x80000000) == 0
|| BN_is_zero(a3[1])
|| BN_is_negative(a3[1])
|| (BN_ucmp((__int64 *)a3[1], v18) & 0x80000000) == 0 )
{
v19 = nullptr;
v20 = 0;
ERR_put_error(16, 250, 156, "crypto/ec/ecdsa_ossl.c", 391);
goto LABEL_11;
}
v19 = (_QWORD *)BN_mod_inverse(v15, a3[1], v18, v13);
if ( !v19 )
{
v20 = -1;
ERR_put_error(16, 250, 3, "crypto/ec/ecdsa_ossl.c", 397);
goto LABEL_11;
}
v22 = BN_num_bits((__int64)v18);
v23 = v22;
if ( v22 >= 8 * a2 )
{
if ( BN_bin2bn(a1, a2, v16) )
{
LABEL_22:
if ( (unsigned int)BN_mod_mul(v14, v16, v15, v18, v13) )
{
if ( (unsigned int)BN_mod_mul(v15, *a3, v15, v18, v13) )
{
v19 = EC_POINT_new(v8);
if ( v19 )
{
if ( (unsigned int)EC_POINT_mul((__int64)v8) )
{
v25 = EC_GROUP_method_of((__int64)v8);
if ( (unsigned int)EC_METHOD_get_field_type(v25) == 406 )
{
if ( !(unsigned int)EC_POINT_get_affine_coordinates_GFp((__int64)v8, v19) )
{
v20 = -1;
ERR_put_error(16, 250, 16, "crypto/ec/ecdsa_ossl.c", 438);
goto LABEL_11;
}
}
else if ( !(unsigned int)EC_POINT_get_affine_coordinates_GF2m((__int64)v8, v19) )
{
v20 = -1;
ERR_put_error(16, 250, 16, "crypto/ec/ecdsa_ossl.c", 446);
goto LABEL_11;
}
if ( (unsigned int)BN_nnmod(v14, v17, v18, v13) )
{
v20 = BN_ucmp(v14, (__int64 *)*a3) == 0;
}
else
{
v20 = -1;
ERR_put_error(16, 250, 3, "crypto/ec/ecdsa_ossl.c", 452);
}
goto LABEL_11;
}
v20 = -1;
ERR_put_error(16, 250, 16, "crypto/ec/ecdsa_ossl.c", 432);
}
else
{
v20 = -1;
ERR_put_error(16, 250, 65, "crypto/ec/ecdsa_ossl.c", 428);
}
}
else
{
v19 = nullptr;
v20 = -1;
ERR_put_error(16, 250, 3, "crypto/ec/ecdsa_ossl.c", 423);
}
}
else
{
v19 = nullptr;
v20 = -1;
ERR_put_error(16, 250, 3, "crypto/ec/ecdsa_ossl.c", 418);
}
LABEL_11:
BN_CTX_end(v13);
BN_CTX_free(v13);
EC_POINT_free((__int64)v19);
return v20;
}
}
else
{
v24 = (v22 + 7) / 8;
if ( BN_bin2bn(a1, v24, v16) )
{
if ( v23 < 8 * v24 && !(unsigned int)BN_rshift(v16, v16, 8 - (v23 & 7u)) )
{
v19 = nullptr;
v20 = -1;
ERR_put_error(16, 250, 3, "crypto/ec/ecdsa_ossl.c", 413);
goto LABEL_11;
}
goto LABEL_22;
}
}
v19 = nullptr;
v20 = -1;
ERR_put_error(16, 250, 3, "crypto/ec/ecdsa_ossl.c", 408);
goto LABEL_11;
}
ERR_put_error(16, 250, 65, "crypto/ec/ecdsa_ossl.c", 369);
return 0xFFFFFFFFLL;
}
else
{
ERR_put_error(16, 250, 159, "crypto/ec/ecdsa_ossl.c", 363);
return 0xFFFFFFFFLL;
}
}
else
{
ERR_put_error(16, 250, 124, "crypto/ec/ecdsa_ossl.c", 358);
return 0xFFFFFFFFLL;
}
}