{"type": "func", "start": 8850472, "end": 8850944, "name": "BN_rand_range", "pseudocode": "// \n// BN_rand_range from 0x870c28 to 0x870e00 (472 bytes)\n// \n// 10 xrefs:\n// > sub_7E01E0 @ 0x7e02d4\n// > sub_7E28B8 @ 0x7e2a8c\n// > sub_7E2D78 @ 0x7e2de4\n// > ec_key_simple_generate_key @ 0x7e8e88\n// > ossl_ecdsa_sign_setup @ 0x7edb14\n// > ossl_ecdsa_sign_sig @ 0x7ee2b4\n// > BN_BLINDING_create_param @ 0x86bbb0\n// > bn_probable_prime_dh_coprime @ 0x8caec8\n// > DSA_generate_key @ 0x8d0ee4\n// > <???> @ 0x60a9c\n// \n// This function is hookable on this platform!\n// \n// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA\n// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings\n// \n\nint __fastcall BN_rand_range(int **a1, int *a2)\n{\n  _BOOL4 is_zero; // r8\n  int v6; // r7\n  int v7; // r6\n  int v8; // r7\n  int v9; // r6\n\n  if ( a2[3] || (is_zero = BN_is_zero((int)a2)) )\n  {\n    ERR_put_error(3, 122, 115, (int)\"crypto/bn/bn_rand.c\", 120);\n    return 0;\n  }\n  else\n  {\n    v6 = BN_num_bits(a2);\n    if ( v6 == 1 )\n    {\n      BN_set_word(a1, 0);\n      return 1;\n    }\n    else if ( BN_is_bit_set(a2, v6 - 2) || BN_is_bit_set(a2, v6 - 3) )\n    {\n      v7 = 100;\n      while ( BN_rand((int *)a1, v6, -1, 0) )\n      {\n        if ( !--v7 )\n        {\n          ERR_put_error(3, 122, 113, (int)\"crypto/bn/bn_rand.c\", 166);\n          return is_zero;\n        }\n        if ( BN_cmp((int *)a1, a2) < 0 )\n          return 1;\n      }\n    }\n    else\n    {\n      v8 = v6 + 1;\n      v9 = 100;\n      while ( BN_rand((int *)a1, v8, -1, 0)\n           && (BN_cmp((int *)a1, a2) < 0\n            || BN_sub((int *)a1, (int *)a1, a2) && (BN_cmp((int *)a1, a2) < 0 || BN_sub((int *)a1, (int *)a1, a2))) )\n      {\n        if ( !--v9 )\n        {\n          is_zero = 0;\n          ERR_put_error(3, 122, 113, (int)\"crypto/bn/bn_rand.c\", 153);\n          return is_zero;\n        }\n        if ( BN_cmp((int *)a1, a2) < 0 )\n          return 1;\n      }\n    }\n  }\n  return is_zero;\n}", "assembly": "; \n; BN_rand_range from 0x870c28 to 0x870e00 (472 bytes)\n; \n; 10 xrefs:\n; > sub_7E01E0 @ 0x7e02d4\n; > sub_7E28B8 @ 0x7e2a8c\n; > sub_7E2D78 @ 0x7e2de4\n; > ec_key_simple_generate_key @ 0x7e8e88\n; > ossl_ecdsa_sign_setup @ 0x7edb14\n; > ossl_ecdsa_sign_sig @ 0x7ee2b4\n; > BN_BLINDING_create_param @ 0x86bbb0\n; > bn_probable_prime_dh_coprime @ 0x8caec8\n; > DSA_generate_key @ 0x8d0ee4\n; > <???> @ 0x60a9c\n; \n; This function is hookable on this platform!\n; \n; Using BromaIDA 8.0.0 @ https:;github.com/Stazzical/BromaIDA\n; Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https:;github.com/geode-sdk/bindings\n; \n\nLDR             R3, [R1,#0xC]                                          ; +0x0, 0x870c28\nPUSH            {R4-R8,LR}                                             ; +0x4, 0x870c2c\nCMP             R3, #0                                                 ; +0x8, 0x870c30\nSUB             SP, SP, #8                                             ; +0xc, 0x870c34\nMOV             R5, R1                                                 ; +0x10, 0x870c38\nBNE             loc_870C54                                             ; +0x14, 0x870c3c\nMOV             R4, R0                                                 ; +0x18, 0x870c40\nMOV             R0, R1                                                 ; +0x1c, 0x870c44\nBL              BN_is_zero                                             ; +0x20, 0x870c48\nSUBS            R8, R0, #0                                             ; +0x24, 0x870c4c\nBEQ             loc_870C84                                             ; +0x28, 0x870c50\nMOV             R3, #0x78 ; 'x'                                        ; +0x2c, 0x870c54\nSTR             R3, [SP,#8+var_8]                                      ; +0x30, 0x870c58\nLDR             R3, =(aCryptoBnBnRand - 0x870C74); \"crypto/bn/bn_rand.c\" ; +0x34, 0x870c5c\nMOV             R0, #3                                                 ; +0x38, 0x870c60\nMOV             R1, #0x7A ; 'z'                                        ; +0x3c, 0x870c64\nMOV             R2, #0x73 ; 's'                                        ; +0x40, 0x870c68\nADD             R3, PC, R3; \"crypto/bn/bn_rand.c\"                      ; +0x44, 0x870c6c\nBL              ERR_put_error                                          ; +0x48, 0x870c70\nMOV             R8, #0                                                 ; +0x4c, 0x870c74\nMOV             R0, R8                                                 ; +0x50, 0x870c78\nADD             SP, SP, #8                                             ; +0x54, 0x870c7c\nPOP             {R4-R8,PC}                                             ; +0x58, 0x870c80\nMOV             R0, R5                                                 ; +0x5c, 0x870c84\nBL              BN_num_bits                                            ; +0x60, 0x870c88\nCMP             R0, #1                                                 ; +0x64, 0x870c8c\nMOV             R7, R0                                                 ; +0x68, 0x870c90\nBEQ             loc_870DA0                                             ; +0x6c, 0x870c94\nMOV             R0, R5                                                 ; +0x70, 0x870c98\nSUB             R1, R7, #2                                             ; +0x74, 0x870c9c\nBL              BN_is_bit_set                                          ; +0x78, 0x870ca0\nCMP             R0, #0                                                 ; +0x7c, 0x870ca4\nBEQ             loc_870CF0                                             ; +0x80, 0x870ca8\nMOV             R6, #0x64 ; 'd'                                        ; +0x84, 0x870cac\nMOV             R1, R7                                                 ; +0x88, 0x870cb0\nMOV             R0, R4                                                 ; +0x8c, 0x870cb4\nMOV             R2, #0xFFFFFFFF                                        ; +0x90, 0x870cb8\nMOV             R3, #0                                                 ; +0x94, 0x870cbc\nBL              BN_rand                                                ; +0x98, 0x870cc0\nMOV             R1, R5                                                 ; +0x9c, 0x870cc4\nCMP             R0, #0                                                 ; +0xa0, 0x870cc8\nMOV             R0, R4                                                 ; +0xa4, 0x870ccc\nBEQ             loc_870C78                                             ; +0xa8, 0x870cd0\nSUBS            R6, R6, #1                                             ; +0xac, 0x870cd4\nBEQ             loc_870DB4                                             ; +0xb0, 0x870cd8\nBL              BN_cmp                                                 ; +0xb4, 0x870cdc\nCMP             R0, #0                                                 ; +0xb8, 0x870ce0\nBGE             loc_870CB0                                             ; +0xbc, 0x870ce4\nMOV             R8, #1                                                 ; +0xc0, 0x870ce8\nB               loc_870C78                                             ; +0xc4, 0x870cec\nMOV             R0, R5                                                 ; +0xc8, 0x870cf0\nSUB             R1, R7, #3                                             ; +0xcc, 0x870cf4\nBL              BN_is_bit_set                                          ; +0xd0, 0x870cf8\nCMP             R0, #0                                                 ; +0xd4, 0x870cfc\nBNE             loc_870CAC                                             ; +0xd8, 0x870d00\nADD             R7, R7, #1                                             ; +0xdc, 0x870d04\nMOV             R6, #0x64 ; 'd'                                        ; +0xe0, 0x870d08\nMOV             R1, R7                                                 ; +0xe4, 0x870d0c\nMOV             R0, R4                                                 ; +0xe8, 0x870d10\nMOV             R2, #0xFFFFFFFF                                        ; +0xec, 0x870d14\nMOV             R3, #0                                                 ; +0xf0, 0x870d18\nBL              BN_rand                                                ; +0xf4, 0x870d1c\nMOV             R1, R5                                                 ; +0xf8, 0x870d20\nCMP             R0, #0                                                 ; +0xfc, 0x870d24\nMOV             R0, R4                                                 ; +0x100, 0x870d28\nBEQ             loc_870C78                                             ; +0x104, 0x870d2c\nBL              BN_cmp                                                 ; +0x108, 0x870d30\nMOV             R2, R5                                                 ; +0x10c, 0x870d34\nMOV             R1, R4                                                 ; +0x110, 0x870d38\nCMP             R0, #0                                                 ; +0x114, 0x870d3c\nMOV             R0, R4                                                 ; +0x118, 0x870d40\nBLT             loc_870D80                                             ; +0x11c, 0x870d44\nBL              BN_sub                                                 ; +0x120, 0x870d48\nMOV             R1, R5                                                 ; +0x124, 0x870d4c\nCMP             R0, #0                                                 ; +0x128, 0x870d50\nMOV             R0, R4                                                 ; +0x12c, 0x870d54\nBEQ             loc_870C78                                             ; +0x130, 0x870d58\nBL              BN_cmp                                                 ; +0x134, 0x870d5c\nMOV             R1, R4                                                 ; +0x138, 0x870d60\nMOV             R2, R5                                                 ; +0x13c, 0x870d64\nCMP             R0, #0                                                 ; +0x140, 0x870d68\nMOV             R0, R4                                                 ; +0x144, 0x870d6c\nBLT             loc_870D80                                             ; +0x148, 0x870d70\nBL              BN_sub                                                 ; +0x14c, 0x870d74\nCMP             R0, #0                                                 ; +0x150, 0x870d78\nBEQ             loc_870C78                                             ; +0x154, 0x870d7c\nSUBS            R6, R6, #1                                             ; +0x158, 0x870d80\nMOV             R0, R4                                                 ; +0x15c, 0x870d84\nMOV             R1, R5                                                 ; +0x160, 0x870d88\nBEQ             loc_870DD8                                             ; +0x164, 0x870d8c\nBL              BN_cmp                                                 ; +0x168, 0x870d90\nCMP             R0, #0                                                 ; +0x16c, 0x870d94\nBGE             loc_870D0C                                             ; +0x170, 0x870d98\nB               loc_870CE8                                             ; +0x174, 0x870d9c\nMOV             R1, R8                                                 ; +0x178, 0x870da0\nMOV             R0, R4                                                 ; +0x17c, 0x870da4\nBL              BN_set_word                                            ; +0x180, 0x870da8\nMOV             R8, R7                                                 ; +0x184, 0x870dac\nB               loc_870C78                                             ; +0x188, 0x870db0\nMOV             R3, #0xA6                                              ; +0x18c, 0x870db4\nSTR             R3, [SP,#8+var_8]                                      ; +0x190, 0x870db8\nLDR             R3, =(aCryptoBnBnRand - 0x870DD4); \"crypto/bn/bn_rand.c\" ; +0x194, 0x870dbc\nMOV             R0, #3                                                 ; +0x198, 0x870dc0\nMOV             R1, #0x7A ; 'z'                                        ; +0x19c, 0x870dc4\nMOV             R2, #0x71 ; 'q'                                        ; +0x1a0, 0x870dc8\nADD             R3, PC, R3; \"crypto/bn/bn_rand.c\"                      ; +0x1a4, 0x870dcc\nBL              ERR_put_error                                          ; +0x1a8, 0x870dd0\nB               loc_870C78                                             ; +0x1ac, 0x870dd4\nMOV             R3, #0x99                                              ; +0x1b0, 0x870dd8\nSTR             R3, [SP,#8+var_8]                                      ; +0x1b4, 0x870ddc\nLDR             R3, =(aCryptoBnBnRand - 0x870DF8); \"crypto/bn/bn_rand.c\" ; +0x1b8, 0x870de0\nMOV             R0, #3                                                 ; +0x1bc, 0x870de4\nMOV             R1, #0x7A ; 'z'                                        ; +0x1c0, 0x870de8\nMOV             R2, #0x71 ; 'q'                                        ; +0x1c4, 0x870dec\nADD             R3, PC, R3; \"crypto/bn/bn_rand.c\"                      ; +0x1c8, 0x870df0\nMOV             R8, R6                                                 ; +0x1cc, 0x870df4\nBL              ERR_put_error                                          ; +0x1d0, 0x870df8\nB               loc_870C78                                             ; +0x1d4, 0x870dfc", "xrefs": ["sub_7E01E0 @ 0x7e02d4", "sub_7E28B8 @ 0x7e2a8c", "sub_7E2D78 @ 0x7e2de4", "ec_key_simple_generate_key @ 0x7e8e88", "ossl_ecdsa_sign_setup @ 0x7edb14", "ossl_ecdsa_sign_sig @ 0x7ee2b4", "BN_BLINDING_create_param @ 0x86bbb0", "bn_probable_prime_dh_coprime @ 0x8caec8", "DSA_generate_key @ 0x8d0ee4", "<???> @ 0x60a9c"], "is_objc": false, "is_arm32": false, "is_arm64": false, "bida_info": "8.0.0 @ https://github.com/Stazzical/BromaIDA", "bindings_info": "commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings"}