// // BN_mod_exp_recp from 0xa81978 to 0xa81d68 (1008 bytes) // // 2 xrefs: // > BN_mod_exp @ 0xa82f10 // > @ 0x8378c // // 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:50 +0000 // int __fastcall BN_mod_exp_recp(int **a1, int a2, _DWORD *a3, int a4, int ***a5) { int v9; // r11 int **v10; // r8 int **v11; // r0 bool v12; // zf int v13; // r3 int v14; // r7 int v15; // r4 int v17; // r5 _DWORD *v18; // r9 int v19; // r7 int **v20; // r0 int v21; // r11 int v22; // r5 int v23; // r8 int v24; // r9 int v25; // r7 int is_bit_set; // r0 int v27; // r1 int v28; // r5 int v29; // [sp+0h] [bp-CCh] int *v30; // [sp+8h] [bp-C4h] int v31; // [sp+8h] [bp-C4h] int i; // [sp+Ch] [bp-C0h] _BYTE v33[52]; // [sp+14h] [bp-B8h] BYREF _DWORD v34[33]; // [sp+48h] [bp-84h] BYREF if ( BN_get_flags((int)a3, 4) ) { ERR_put_error(3, 125, 66, (int)"crypto/bn/bn_exp.c", 179); return 0; } else { v9 = BN_num_bits(a3); if ( v9 ) { BN_CTX_start((int)a5); v10 = BN_CTX_get(a5); v11 = BN_CTX_get(a5); v12 = v11 == nullptr; if ( v11 ) v12 = v10 == nullptr; v13 = v12; v14 = (int)v11; v30 = (int *)v13; v34[0] = v11; if ( v12 ) goto LABEL_12; BN_RECP_CTX_init(v33); if ( *(_DWORD *)(a4 + 12) ) { if ( !BN_copy((int)v10, a4) ) goto LABEL_12; v10[3] = v30; if ( BN_RECP_CTX_set(v33, v10, a5) <= 0 ) goto LABEL_12; } else if ( BN_RECP_CTX_set(v33, a4, a5) <= 0 ) { goto LABEL_12; } if ( BN_nnmod(v14, a2, a4, a5, v29) ) { if ( BN_is_zero(v14) ) { BN_set_word(a1, 0); v15 = 1; goto LABEL_13; } if ( v9 >= 672 ) { v17 = 32; v31 = 6; } else if ( v9 > 239 ) { v17 = 16; v31 = 5; } else if ( v9 > 79 ) { v17 = 8; v31 = 4; } else { if ( v9 <= 23 ) { v31 = 1; LABEL_32: if ( BN_set_word(a1, 1) ) { v21 = v9 - 1; for ( i = 1; ; i = 0 ) { while ( !BN_is_bit_set(a3, v21) ) { if ( !i && !BN_mod_mul_reciprocal(a1, a1, a1, v33, a5) ) goto LABEL_12; if ( !v21 ) { LABEL_58: v15 = 1; goto LABEL_13; } --v21; } if ( v31 == 1 ) { v23 = 1; v25 = 0; } else { v22 = v21 - 1; if ( v21 - 1 < 0 ) { v23 = 1; v25 = 0; } else { v23 = 1; v24 = 1; v25 = 0; do { is_bit_set = BN_is_bit_set(a3, v22); v27 = v23 << (v24 - v25); --v22; if ( is_bit_set ) v25 = v24; ++v24; if ( is_bit_set ) v23 = v27 | 1; } while ( v24 != v31 && v22 != -1 ); } } if ( !i ) break; LABEL_50: if ( !BN_mod_mul_reciprocal(a1, a1, v34[v23 >> 1], v33, a5) ) goto LABEL_12; v21 += ~v25; if ( v21 < 0 ) goto LABEL_58; } v28 = 0; while ( 1 ) { ++v28; if ( !BN_mod_mul_reciprocal(a1, a1, a1, v33, a5) ) break; if ( v28 > v25 ) goto LABEL_50; } } goto LABEL_12; } v17 = 4; v31 = 3; } if ( BN_mod_mul_reciprocal(v10, v14, v14, v33, a5) ) { v18 = v34; v19 = 1; while ( 1 ) { v20 = BN_CTX_get(a5); ++v19; v18[1] = v20; ++v18; if ( !v20 || !BN_mod_mul_reciprocal(v20, *(v18 - 1), v10, v33, a5) ) break; if ( v19 >= v17 ) goto LABEL_32; } } } LABEL_12: v15 = 0; LABEL_13: BN_CTX_end(a5); BN_RECP_CTX_free(v33); return v15; } if ( BN_is_one(a4) ) { BN_set_word(a1, 0); return 1; } else { return BN_set_word(a1, 1); } } }
GD Web Decomp Icon

GD Web Decomp

Raw Source