// // ossl_ecdsa_sign_sig from 0x7edf88 to 0x7ee8f4 (2412 bytes) // // 2 xrefs: // > @ 0x619cc // > @ 0xab2694 // // 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 // int *__fastcall ossl_ecdsa_sign_sig(_BYTE *a1, int a2, _DWORD *a3, int a4, int a5) { int v7; // r4 int v8; // r0 bool v9; // zf int v10; // r7 int *v11; // r5 int v12; // r0 bool v13; // zf int v14; // r8 _DWORD *v15; // r0 int v16; // r0 int v17; // r4 bool v18; // zf int v19; // r1 bool v20; // zf int v21; // r3 _DWORD *v22; // r4 int v23; // r10 int v24; // r0 bool v25; // zf int v26; // r3 _DWORD *v27; // r10 int v28; // r0 int v30; // r9 int v31; // r8 int v32; // r0 int mont_data; // r0 _BYTE *v34; // [sp+8h] [bp-3Ch] _DWORD *v35; // [sp+Ch] [bp-38h] int *v36; // [sp+10h] [bp-34h] int v37; // [sp+14h] [bp-30h] _BYTE *v40; // [sp+20h] [bp-24h] int v41; // [sp+24h] [bp-20h] int v42; // [sp+28h] [bp-1Ch] int *v43; // [sp+2Ch] [bp-18h] int **v44; // [sp+30h] [bp-14h] _BYTE *v45; // [sp+34h] [bp-10h] _DWORD *v46; // [sp+38h] [bp-Ch] int v47; // [sp+3Ch] [bp-8h] v7 = EC_KEY_get0_group(a5); v8 = EC_KEY_get0_private_key(a5); v9 = v7 == 0; if ( v7 ) v9 = v8 == 0; v37 = v8; v10 = v9; if ( v9 ) { ERR_put_error(16, 249, 67, "crypto/ec/ecdsa_ossl.c", 210); return nullptr; } if ( !EC_KEY_can_sign(a5) ) { ERR_put_error(16, 249, 159, "crypto/ec/ecdsa_ossl.c", 215); return nullptr; } v11 = (int *)ECDSA_SIG_new(); if ( !v11 ) { ERR_put_error(16, 249, 65, "crypto/ec/ecdsa_ossl.c", 221); return nullptr; } *v11 = BN_new(); v12 = BN_new(); v13 = *v11 == 0; if ( *v11 ) v13 = v12 == 0; v14 = v12; v11[1] = v12; if ( v13 ) { v40 = (_BYTE *)v10; ERR_put_error(16, 249, 65, "crypto/ec/ecdsa_ossl.c", 227); v34 = (_BYTE *)v10; v36 = (int *)v10; goto LABEL_53; } v10 = BN_CTX_new(); if ( !v10 || (v34 = (_BYTE *)BN_new()) == nullptr ) { v34 = nullptr; goto LABEL_52; } v36 = (int *)BN_new(); if ( !v36 ) { LABEL_52: v40 = nullptr; ERR_put_error(16, 249, 65, "crypto/ec/ecdsa_ossl.c", 234); v36 = nullptr; goto LABEL_53; } v15 = (_DWORD *)EC_GROUP_get0_order(v7); v35 = v15; if ( !v15 ) { v40 = nullptr; ERR_put_error(16, 249, 16, "crypto/ec/ecdsa_ossl.c", 240); goto LABEL_53; } v16 = BN_num_bits(v15); v17 = v16; if ( v16 >= 8 * a2 ) { if ( BN_bin2bn(a1, a2, v36) ) goto LABEL_18; goto LABEL_96; } v30 = v16 + 7; if ( v16 + 7 < 0 ) v30 = v16 + 14; a2 = v30 >> 3; if ( !BN_bin2bn(a1, a2, v36) ) { LABEL_96: ERR_put_error(16, 249, 3, "crypto/ec/ecdsa_ossl.c", 250); v40 = nullptr; goto LABEL_53; } if ( v17 >= 8 * a2 || BN_rshift((int)v36, v36, 8 - (v17 & 7)) ) { LABEL_18: v40 = nullptr; v18 = a4 == 0; if ( a4 ) v18 = a3 == nullptr; v19 = v18; v20 = a3 == nullptr; if ( a3 ) v20 = a4 == 0; v21 = !v20; v41 = v19; v42 = v21; while ( !v41 ) { if ( !BN_copy(*v11, a4) ) { ERR_put_error(16, 249, 65, "crypto/ec/ecdsa_ossl.c", 268); goto LABEL_53; } v22 = a3; LABEL_61: if ( !BN_mod_mul(v34, v37, *v11, v35, v10) ) { ERR_put_error(16, 249, 3, "crypto/ec/ecdsa_ossl.c", 274); goto LABEL_53; } if ( !BN_mod_add_quick(v14, v34, v36, v35) ) { ERR_put_error(16, 249, 3, "crypto/ec/ecdsa_ossl.c", 278); goto LABEL_53; } if ( !BN_mod_mul(v14, v14, v22, v35, v10) ) { ERR_put_error(16, 249, 3, "crypto/ec/ecdsa_ossl.c", 282); goto LABEL_53; } if ( !BN_is_zero(v14) ) goto LABEL_54; if ( v42 ) { ERR_put_error(16, 249, 157, "crypto/ec/ecdsa_ossl.c", 291); goto LABEL_53; } } if ( a5 && (v43 = (int *)EC_KEY_get0_group(a5)) != nullptr ) { if ( EC_KEY_can_sign(a5) ) { v22 = (_DWORD *)BN_new(); v23 = BN_new(); v45 = (_BYTE *)v23; v24 = BN_new(); v25 = v22 == nullptr; if ( v22 ) v25 = v23 == 0; v26 = v25; if ( !v24 ) v26 |= 1u; v44 = (int **)v24; if ( v26 ) { ERR_put_error(16, 248, 65, "crypto/ec/ecdsa_ossl.c", 67); v46 = nullptr; goto LABEL_49; } v46 = EC_POINT_new(v43); if ( !v46 ) { ERR_put_error(16, 248, 16, "crypto/ec/ecdsa_ossl.c", 71); goto LABEL_49; } v27 = (_DWORD *)EC_GROUP_get0_order((int)v43); if ( !v27 ) { ERR_put_error(16, 248, 16, "crypto/ec/ecdsa_ossl.c", 76); goto LABEL_49; } v47 = v14; do { if ( !a1 ) { while ( BN_rand_range(v22, v27) ) { if ( !BN_is_zero((int)v22) ) goto LABEL_75; } ERR_put_error(16, 248, 158, "crypto/ec/ecdsa_ossl.c", 94); goto LABEL_49; } do { v28 = EC_KEY_get0_private_key(a5); if ( !BN_generate_dsa_nonce(v22, v27, v28, a1, a2, v10) ) { ERR_put_error(16, 248, 158, "crypto/ec/ecdsa_ossl.c", 88); goto LABEL_49; } } while ( BN_is_zero((int)v22) ); LABEL_75: if ( !BN_add(v22, v22, v27) ) goto LABEL_49; v31 = BN_num_bits(v22); if ( v31 <= BN_num_bits(v27) && !BN_add(v22, v22, v27) ) goto LABEL_49; if ( !EC_POINT_mul((int)v43) ) { ERR_put_error(16, 248, 16, "crypto/ec/ecdsa_ossl.c", 113); goto LABEL_49; } v32 = EC_GROUP_method_of((int)v43); if ( EC_METHOD_get_field_type(v32) == 406 ) { if ( !EC_POINT_get_affine_coordinates_GFp((int)v43, v46) ) { ERR_put_error(16, 248, 16, "crypto/ec/ecdsa_ossl.c", 120); goto LABEL_49; } } else if ( !EC_POINT_get_affine_coordinates_GF2m((int)v43, v46) ) { ERR_put_error(16, 248, 16, "crypto/ec/ecdsa_ossl.c", 130); goto LABEL_49; } if ( !BN_nnmod(v45, v44, v27, v10, v10, v10) ) { ERR_put_error(16, 248, 3, "crypto/ec/ecdsa_ossl.c", 136); goto LABEL_49; } } while ( BN_is_zero((int)v45) ); v14 = v47; if ( EC_GROUP_get_mont_data((int)v43) ) { if ( !BN_set_word(v44, 2) ) { ERR_put_error(16, 248, 3, "crypto/ec/ecdsa_ossl.c", 149); goto LABEL_49; } if ( !BN_mod_sub(v44, v27, v44, v27, v10) ) { ERR_put_error(16, 248, 3, "crypto/ec/ecdsa_ossl.c", 153); goto LABEL_49; } BN_set_flags((int)v44, 4); mont_data = EC_GROUP_get_mont_data((int)v43); if ( !BN_mod_exp_mont_consttime(v22, v22, v44, v27, v10, mont_data) ) { ERR_put_error(16, 248, 3, "crypto/ec/ecdsa_ossl.c", 159); goto LABEL_49; } LABEL_106: BN_clear_free((_BYTE *)*v11); BN_clear_free(v40); *v11 = (int)v45; EC_POINT_free((int)v46); BN_clear_free(v44); v40 = v22; goto LABEL_61; } if ( BN_mod_inverse(v22, v22, v27, v10) ) goto LABEL_106; ERR_put_error(16, 248, 3, "crypto/ec/ecdsa_ossl.c", 164); LABEL_49: BN_clear_free(v22); BN_clear_free(v45); EC_POINT_free((int)v46); BN_clear_free(v44); } else { ERR_put_error(16, 248, 159, "crypto/ec/ecdsa_ossl.c", 51); } } else { ERR_put_error(16, 248, 67, "crypto/ec/ecdsa_ossl.c", 46); } ERR_put_error(16, 249, 42, "crypto/ec/ecdsa_ossl.c", 261); goto LABEL_53; } v40 = nullptr; ERR_put_error(16, 249, 3, "crypto/ec/ecdsa_ossl.c", 255); LABEL_53: ECDSA_SIG_free((_BYTE **)v11); v11 = nullptr; LABEL_54: BN_CTX_free(v10); BN_clear_free(v36); BN_clear_free(v34); BN_clear_free(v40); return v11; }
GD Web Decomp Icon

GD Web Decomp

Raw Source