//
// ossl_ecdsa_verify_sig from 0xa0367c to 0xa03bc0 (1348 bytes)
//
// 2 xrefs:
// > ??> @ 0x7b46c
// > ??> @ 0xd16d78
//
// 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:07:39 +0000
//
int __fastcall ossl_ecdsa_verify_sig(_BYTE *a1, int a2, int *a3, int a4)
{
int *v8; // r7
int v9; // r0
bool v10; // zf
int v11; // r0
int v12; // r4
int v13; // r10
int *v14; // r11
_DWORD *v15; // r8
int v16; // r5
int v18; // r0
int v19; // r8
int v20; // r8
int v21; // r0
int *v22; // [sp+8h] [bp-14h]
int v23; // [sp+Ch] [bp-10h]
int *v24; // [sp+10h] [bp-Ch]
int v25; // [sp+14h] [bp-8h]
if ( !a4 )
goto LABEL_29;
v8 = (int *)EC_KEY_get0_group(a4);
if ( !v8 )
goto LABEL_29;
v9 = EC_KEY_get0_public_key(a4);
v10 = a3 == nullptr;
if ( a3 )
v10 = v9 == 0;
if ( !v10 )
{
if ( EC_KEY_can_sign(a4) )
{
v11 = BN_CTX_new();
v12 = v11;
if ( v11 )
{
BN_CTX_start(v11);
v22 = (int *)BN_CTX_get(v12);
v23 = BN_CTX_get(v12);
v24 = (int *)BN_CTX_get(v12);
v13 = BN_CTX_get(v12);
if ( !v13 )
{
v15 = nullptr;
ERR_put_error(16, 250, 3, "crypto/ec/ecdsa_ossl.c", 378);
v16 = -1;
goto LABEL_12;
}
v14 = (int *)EC_GROUP_get0_order((int)v8);
if ( !v14 )
{
v15 = nullptr;
ERR_put_error(16, 250, 16, "crypto/ec/ecdsa_ossl.c", 384);
v16 = -1;
goto LABEL_12;
}
if ( BN_is_zero(*a3)
|| BN_is_negative(*a3)
|| BN_ucmp((int *)*a3, v14) >= 0
|| BN_is_zero(a3[1])
|| BN_is_negative(a3[1])
|| BN_ucmp((int *)a3[1], v14) >= 0 )
{
ERR_put_error(16, 250, 156, "crypto/ec/ecdsa_ossl.c", 391);
v15 = nullptr;
v16 = 0;
goto LABEL_12;
}
if ( !BN_mod_inverse(v23, a3[1], v14, v12) )
{
v15 = nullptr;
v16 = -1;
ERR_put_error(16, 250, 3, "crypto/ec/ecdsa_ossl.c", 397);
goto LABEL_12;
}
v18 = BN_num_bits(v14);
if ( v18 >= 8 * a2 )
{
if ( BN_bin2bn(a1, a2, v24) )
{
LABEL_25:
v15 = (_DWORD *)BN_mod_mul(v22, v24, v23, v14, v12);
if ( v15 )
{
v15 = (_DWORD *)BN_mod_mul(v23, *a3, v23, v14, v12);
if ( v15 )
{
v15 = EC_POINT_new(v8);
if ( v15 )
{
if ( EC_POINT_mul((int)v8) )
{
v21 = EC_GROUP_method_of((int)v8);
if ( EC_METHOD_get_field_type(v21) == 406 )
{
if ( !EC_POINT_get_affine_coordinates_GFp((int)v8, v15) )
{
ERR_put_error(16, 250, 16, "crypto/ec/ecdsa_ossl.c", 438);
v16 = -1;
goto LABEL_12;
}
}
else if ( !EC_POINT_get_affine_coordinates_GF2m((int)v8, v15) )
{
ERR_put_error(16, 250, 16, "crypto/ec/ecdsa_ossl.c", 446);
v16 = -1;
goto LABEL_12;
}
if ( BN_nnmod(v22, v13, v14, v12, v12, v12) )
{
v16 = BN_ucmp(v22, (int *)*a3) == 0;
}
else
{
ERR_put_error(16, 250, 3, "crypto/ec/ecdsa_ossl.c", 452);
v16 = -1;
}
goto LABEL_12;
}
ERR_put_error(16, 250, 16, "crypto/ec/ecdsa_ossl.c", 432);
v16 = -1;
}
else
{
ERR_put_error(16, 250, 65, "crypto/ec/ecdsa_ossl.c", 428);
v16 = -1;
}
}
else
{
ERR_put_error(16, 250, 3, "crypto/ec/ecdsa_ossl.c", 423);
v16 = -1;
}
}
else
{
ERR_put_error(16, 250, 3, "crypto/ec/ecdsa_ossl.c", 418);
v16 = -1;
}
LABEL_12:
BN_CTX_end(v12);
BN_CTX_free(v12);
EC_POINT_free((int)v15);
return v16;
}
}
else
{
v19 = v18 + 7;
if ( v18 + 7 < 0 )
v19 = v18 + 14;
v20 = v19 >> 3;
v25 = v18;
if ( BN_bin2bn(a1, v20, v24) )
{
if ( v25 < 8 * v20 )
{
v15 = (_DWORD *)BN_rshift((int)v24, v24, 8 - (v25 & 7));
if ( !v15 )
{
ERR_put_error(16, 250, 3, "crypto/ec/ecdsa_ossl.c", 413);
v16 = -1;
goto LABEL_12;
}
}
goto LABEL_25;
}
}
ERR_put_error(16, 250, 3, "crypto/ec/ecdsa_ossl.c", 408);
v15 = nullptr;
v16 = -1;
goto LABEL_12;
}
ERR_put_error(16, 250, 65, "crypto/ec/ecdsa_ossl.c", 369);
return -1;
}
else
{
ERR_put_error(16, 250, 159, "crypto/ec/ecdsa_ossl.c", 363);
return -1;
}
}
else
{
LABEL_29:
ERR_put_error(16, 250, 124, "crypto/ec/ecdsa_ossl.c", 358);
return -1;
}
}