{"type": "func", "start": 11032616, "end": 11033088, "name": "BN_rand_range", "pseudocode": "// \n// BN_rand_range from 0xa85828 to 0xa85a00 (472 bytes)\n// \n// 10 xrefs:\n// > sub_9F4DE0 @ 0x9f4ed4\n// > sub_9F74B8 @ 0x9f768c\n// > sub_9F7978 @ 0x9f79e4\n// > ec_key_simple_generate_key @ 0x9fda88\n// > ossl_ecdsa_sign_setup @ 0xa02714\n// > ossl_ecdsa_sign_sig @ 0xa02eb4\n// > BN_BLINDING_create_param @ 0xa807b0\n// > bn_probable_prime_dh_coprime @ 0xadfec8\n// > DSA_generate_key @ 0xae5ee4\n// > <???> @ 0x7a51c\n// \n// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!\n// \n// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA\n// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings\n// Generated at Fri, 27 Nov 2026 12:08:51 +0000\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 0xa85828 to 0xa85a00 (472 bytes)\n; \n; 10 xrefs:\n; > sub_9F4DE0 @ 0x9f4ed4\n; > sub_9F74B8 @ 0x9f768c\n; > sub_9F7978 @ 0x9f79e4\n; > ec_key_simple_generate_key @ 0x9fda88\n; > ossl_ecdsa_sign_setup @ 0xa02714\n; > ossl_ecdsa_sign_sig @ 0xa02eb4\n; > BN_BLINDING_create_param @ 0xa807b0\n; > bn_probable_prime_dh_coprime @ 0xadfec8\n; > DSA_generate_key @ 0xae5ee4\n; > <???> @ 0x7a51c\n; \n; This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!\n; \n; Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA\n; Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings\n; Generated at Fri, 27 Nov 2026 12:08:51 +0000\n; \nLDR             R3, [R1,#0xC]                                          ; +0x0, 0xa85828\nPUSH            {R4-R8,LR}                                             ; +0x4, 0xa8582c\nCMP             R3, #0                                                 ; +0x8, 0xa85830\nSUB             SP, SP, #8                                             ; +0xc, 0xa85834\nMOV             R5, R1                                                 ; +0x10, 0xa85838\nBNE             loc_A85854                                             ; +0x14, 0xa8583c\nMOV             R4, R0                                                 ; +0x18, 0xa85840\nMOV             R0, R1                                                 ; +0x1c, 0xa85844\nBL              BN_is_zero                                             ; +0x20, 0xa85848\nSUBS            R8, R0, #0                                             ; +0x24, 0xa8584c\nBEQ             loc_A85884                                             ; +0x28, 0xa85850\nMOV             R3, #0x78 ; 'x'                                        ; +0x2c, 0xa85854\nSTR             R3, [SP,#8+var_8]                                      ; +0x30, 0xa85858\nLDR             R3, =(aCryptoBnBnRand - 0xA85874); \"crypto/bn/bn_rand.c\" ; +0x34, 0xa8585c\nMOV             R0, #3                                                 ; +0x38, 0xa85860\nMOV             R1, #0x7A ; 'z'                                        ; +0x3c, 0xa85864\nMOV             R2, #0x73 ; 's'                                        ; +0x40, 0xa85868\nADD             R3, PC, R3; \"crypto/bn/bn_rand.c\"                      ; +0x44, 0xa8586c\nBL              ERR_put_error                                          ; +0x48, 0xa85870\nMOV             R8, #0                                                 ; +0x4c, 0xa85874\nMOV             R0, R8                                                 ; +0x50, 0xa85878\nADD             SP, SP, #8                                             ; +0x54, 0xa8587c\nPOP             {R4-R8,PC}                                             ; +0x58, 0xa85880\nMOV             R0, R5                                                 ; +0x5c, 0xa85884\nBL              BN_num_bits                                            ; +0x60, 0xa85888\nCMP             R0, #1                                                 ; +0x64, 0xa8588c\nMOV             R7, R0                                                 ; +0x68, 0xa85890\nBEQ             loc_A859A0                                             ; +0x6c, 0xa85894\nMOV             R0, R5                                                 ; +0x70, 0xa85898\nSUB             R1, R7, #2                                             ; +0x74, 0xa8589c\nBL              BN_is_bit_set                                          ; +0x78, 0xa858a0\nCMP             R0, #0                                                 ; +0x7c, 0xa858a4\nBEQ             loc_A858F0                                             ; +0x80, 0xa858a8\nMOV             R6, #0x64 ; 'd'                                        ; +0x84, 0xa858ac\nMOV             R1, R7                                                 ; +0x88, 0xa858b0\nMOV             R0, R4                                                 ; +0x8c, 0xa858b4\nMOV             R2, #0xFFFFFFFF                                        ; +0x90, 0xa858b8\nMOV             R3, #0                                                 ; +0x94, 0xa858bc\nBL              BN_rand                                                ; +0x98, 0xa858c0\nMOV             R1, R5                                                 ; +0x9c, 0xa858c4\nCMP             R0, #0                                                 ; +0xa0, 0xa858c8\nMOV             R0, R4                                                 ; +0xa4, 0xa858cc\nBEQ             loc_A85878                                             ; +0xa8, 0xa858d0\nSUBS            R6, R6, #1                                             ; +0xac, 0xa858d4\nBEQ             loc_A859B4                                             ; +0xb0, 0xa858d8\nBL              BN_cmp                                                 ; +0xb4, 0xa858dc\nCMP             R0, #0                                                 ; +0xb8, 0xa858e0\nBGE             loc_A858B0                                             ; +0xbc, 0xa858e4\nMOV             R8, #1                                                 ; +0xc0, 0xa858e8\nB               loc_A85878                                             ; +0xc4, 0xa858ec\nMOV             R0, R5                                                 ; +0xc8, 0xa858f0\nSUB             R1, R7, #3                                             ; +0xcc, 0xa858f4\nBL              BN_is_bit_set                                          ; +0xd0, 0xa858f8\nCMP             R0, #0                                                 ; +0xd4, 0xa858fc\nBNE             loc_A858AC                                             ; +0xd8, 0xa85900\nADD             R7, R7, #1                                             ; +0xdc, 0xa85904\nMOV             R6, #0x64 ; 'd'                                        ; +0xe0, 0xa85908\nMOV             R1, R7                                                 ; +0xe4, 0xa8590c\nMOV             R0, R4                                                 ; +0xe8, 0xa85910\nMOV             R2, #0xFFFFFFFF                                        ; +0xec, 0xa85914\nMOV             R3, #0                                                 ; +0xf0, 0xa85918\nBL              BN_rand                                                ; +0xf4, 0xa8591c\nMOV             R1, R5                                                 ; +0xf8, 0xa85920\nCMP             R0, #0                                                 ; +0xfc, 0xa85924\nMOV             R0, R4                                                 ; +0x100, 0xa85928\nBEQ             loc_A85878                                             ; +0x104, 0xa8592c\nBL              BN_cmp                                                 ; +0x108, 0xa85930\nMOV             R2, R5                                                 ; +0x10c, 0xa85934\nMOV             R1, R4                                                 ; +0x110, 0xa85938\nCMP             R0, #0                                                 ; +0x114, 0xa8593c\nMOV             R0, R4                                                 ; +0x118, 0xa85940\nBLT             loc_A85980                                             ; +0x11c, 0xa85944\nBL              BN_sub                                                 ; +0x120, 0xa85948\nMOV             R1, R5                                                 ; +0x124, 0xa8594c\nCMP             R0, #0                                                 ; +0x128, 0xa85950\nMOV             R0, R4                                                 ; +0x12c, 0xa85954\nBEQ             loc_A85878                                             ; +0x130, 0xa85958\nBL              BN_cmp                                                 ; +0x134, 0xa8595c\nMOV             R1, R4                                                 ; +0x138, 0xa85960\nMOV             R2, R5                                                 ; +0x13c, 0xa85964\nCMP             R0, #0                                                 ; +0x140, 0xa85968\nMOV             R0, R4                                                 ; +0x144, 0xa8596c\nBLT             loc_A85980                                             ; +0x148, 0xa85970\nBL              BN_sub                                                 ; +0x14c, 0xa85974\nCMP             R0, #0                                                 ; +0x150, 0xa85978\nBEQ             loc_A85878                                             ; +0x154, 0xa8597c\nSUBS            R6, R6, #1                                             ; +0x158, 0xa85980\nMOV             R0, R4                                                 ; +0x15c, 0xa85984\nMOV             R1, R5                                                 ; +0x160, 0xa85988\nBEQ             loc_A859D8                                             ; +0x164, 0xa8598c\nBL              BN_cmp                                                 ; +0x168, 0xa85990\nCMP             R0, #0                                                 ; +0x16c, 0xa85994\nBGE             loc_A8590C                                             ; +0x170, 0xa85998\nB               loc_A858E8                                             ; +0x174, 0xa8599c\nMOV             R1, R8                                                 ; +0x178, 0xa859a0\nMOV             R0, R4                                                 ; +0x17c, 0xa859a4\nBL              BN_set_word                                            ; +0x180, 0xa859a8\nMOV             R8, R7                                                 ; +0x184, 0xa859ac\nB               loc_A85878                                             ; +0x188, 0xa859b0\nMOV             R3, #0xA6                                              ; +0x18c, 0xa859b4\nSTR             R3, [SP,#8+var_8]                                      ; +0x190, 0xa859b8\nLDR             R3, =(aCryptoBnBnRand - 0xA859D4); \"crypto/bn/bn_rand.c\" ; +0x194, 0xa859bc\nMOV             R0, #3                                                 ; +0x198, 0xa859c0\nMOV             R1, #0x7A ; 'z'                                        ; +0x19c, 0xa859c4\nMOV             R2, #0x71 ; 'q'                                        ; +0x1a0, 0xa859c8\nADD             R3, PC, R3; \"crypto/bn/bn_rand.c\"                      ; +0x1a4, 0xa859cc\nBL              ERR_put_error                                          ; +0x1a8, 0xa859d0\nB               loc_A85878                                             ; +0x1ac, 0xa859d4\nMOV             R3, #0x99                                              ; +0x1b0, 0xa859d8\nSTR             R3, [SP,#8+var_8]                                      ; +0x1b4, 0xa859dc\nLDR             R3, =(aCryptoBnBnRand - 0xA859F8); \"crypto/bn/bn_rand.c\" ; +0x1b8, 0xa859e0\nMOV             R0, #3                                                 ; +0x1bc, 0xa859e4\nMOV             R1, #0x7A ; 'z'                                        ; +0x1c0, 0xa859e8\nMOV             R2, #0x71 ; 'q'                                        ; +0x1c4, 0xa859ec\nADD             R3, PC, R3; \"crypto/bn/bn_rand.c\"                      ; +0x1c8, 0xa859f0\nMOV             R8, R6                                                 ; +0x1cc, 0xa859f4\nBL              ERR_put_error                                          ; +0x1d0, 0xa859f8\nB               loc_A85878                                             ; +0x1d4, 0xa859fc", "xrefs": ["sub_9F4DE0 @ 0x9f4ed4", "sub_9F74B8 @ 0x9f768c", "sub_9F7978 @ 0x9f79e4", "ec_key_simple_generate_key @ 0x9fda88", "ossl_ecdsa_sign_setup @ 0xa02714", "ossl_ecdsa_sign_sig @ 0xa02eb4", "BN_BLINDING_create_param @ 0xa807b0", "bn_probable_prime_dh_coprime @ 0xadfec8", "DSA_generate_key @ 0xae5ee4", "<???> @ 0x7a51c"], "is_objc": false, "is_32_bit": true, "is_64_bit": false, "idp_name": "arm", "bida_info": "8.3.0 @ https://github.com/Stazzical/BromaIDA", "bindings_info": "commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings"}