test/bntest.c:383: error: MEMORY_LEAK
  memory dynamically allocated by call to `BN_MONT_CTX_new()` at line 374, column 12 is not reachable after line 383, column 9.
Showing all 61 steps of the trace


test/bntest.c:360:1: start of procedure test_modexp_mont5()
358.    * x86_64 cause a different code branch to be taken.
359.    */
360. > static int test_modexp_mont5()
361.   {
362.       BIGNUM *a, *p, *m, *d, *e, *b, *n, *c;

test/bntest.c:366:5: Skipping BN_new(): empty list of specs
364.       char *bigstring;
365.   
366.       a = BN_new();
           ^
367.       p = BN_new();
368.       m = BN_new();

test/bntest.c:367:5: Skipping BN_new(): empty list of specs
365.   
366.       a = BN_new();
367.       p = BN_new();
           ^
368.       m = BN_new();
369.       d = BN_new();

test/bntest.c:368:5: Skipping BN_new(): empty list of specs
366.       a = BN_new();
367.       p = BN_new();
368.       m = BN_new();
           ^
369.       d = BN_new();
370.       e = BN_new();

test/bntest.c:369:5: Skipping BN_new(): empty list of specs
367.       p = BN_new();
368.       m = BN_new();
369.       d = BN_new();
           ^
370.       e = BN_new();
371.       b = BN_new();

test/bntest.c:370:5: Skipping BN_new(): empty list of specs
368.       m = BN_new();
369.       d = BN_new();
370.       e = BN_new();
           ^
371.       b = BN_new();
372.       n = BN_new();

test/bntest.c:371:5: Skipping BN_new(): empty list of specs
369.       d = BN_new();
370.       e = BN_new();
371.       b = BN_new();
           ^
372.       n = BN_new();
373.       c = BN_new();

test/bntest.c:372:5: Skipping BN_new(): empty list of specs
370.       e = BN_new();
371.       b = BN_new();
372.       n = BN_new();
           ^
373.       c = BN_new();
374.       mont = BN_MONT_CTX_new();

test/bntest.c:373:5: Skipping BN_new(): empty list of specs
371.       b = BN_new();
372.       n = BN_new();
373.       c = BN_new();
           ^
374.       mont = BN_MONT_CTX_new();
375.   

test/bntest.c:374:5: 
372.       n = BN_new();
373.       c = BN_new();
374. >     mont = BN_MONT_CTX_new();
375.   
376.       BN_bntest_rand(m, 1024, 0, 1); /* must be odd for montgomery */

crypto/bn/bn_mont.c:213:1: start of procedure BN_MONT_CTX_new()
  211.   }
  212.   
  213. > BN_MONT_CTX *BN_MONT_CTX_new(void)
  214.   {
  215.       BN_MONT_CTX *ret;

crypto/bn/bn_mont.c:217:9: 
  215.       BN_MONT_CTX *ret;
  216.   
  217. >     if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
  218.           return (NULL);
  219.   

crypto/mem.c:158:1: start of procedure CRYPTO_malloc()
    156.   #endif
    157.   
    158. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    159.   {
    160.       void *ret = NULL;

crypto/mem.c:160:5: 
    158.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    159.   {
    160. >     void *ret = NULL;
    161.   
    162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:162:9: Taking false branch
    160.       void *ret = NULL;
    161.   
    162.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    163.           return malloc_impl(num, file, line);
    164.   

crypto/mem.c:165:9: Taking false branch
    163.           return malloc_impl(num, file, line);
    164.   
    165.       if (num == 0)
                   ^
    166.           return NULL;
    167.   

crypto/mem.c:169:5: 
    167.   
    168.       FAILTEST();
    169. >     allow_customize = 0;
    170.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    171.       if (call_malloc_debug) {

crypto/mem.c:179:5: 
    177.       }
    178.   #else
    179. >     osslargused(file); osslargused(line);
    180.       ret = malloc(num);
    181.   #endif

crypto/mem.c:179:24: 
    177.       }
    178.   #else
    179. >     osslargused(file); osslargused(line);
    180.       ret = malloc(num);
    181.   #endif

crypto/mem.c:180:5: 
    178.   #else
    179.       osslargused(file); osslargused(line);
    180. >     ret = malloc(num);
    181.   #endif
    182.   

crypto/mem.c:183:5: 
    181.   #endif
    182.   
    183. >     return ret;
    184.   }
    185.   

crypto/mem.c:184:1: return from a call to CRYPTO_malloc
    182.   
    183.       return ret;
    184. > }
    185.   
    186.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/bn/bn_mont.c:217:9: Taking false branch
  215.       BN_MONT_CTX *ret;
  216.   
  217.       if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
                 ^
  218.           return (NULL);
  219.   

crypto/bn/bn_mont.c:220:5: 
  218.           return (NULL);
  219.   
  220. >     BN_MONT_CTX_init(ret);
  221.       ret->flags = BN_FLG_MALLOCED;
  222.       return (ret);

crypto/bn/bn_mont.c:225:1: start of procedure BN_MONT_CTX_init()
    223.   }
    224.   
    225. > void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
    226.   {
    227.       ctx->ri = 0;

crypto/bn/bn_mont.c:227:5: 
    225.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
    226.   {
    227. >     ctx->ri = 0;
    228.       bn_init(&(ctx->RR));
    229.       bn_init(&(ctx->N));

crypto/bn/bn_mont.c:228:5: Skipping bn_init(): empty list of specs
    226.   {
    227.       ctx->ri = 0;
    228.       bn_init(&(ctx->RR));
               ^
    229.       bn_init(&(ctx->N));
    230.       bn_init(&(ctx->Ni));

crypto/bn/bn_mont.c:229:5: Skipping bn_init(): empty list of specs
    227.       ctx->ri = 0;
    228.       bn_init(&(ctx->RR));
    229.       bn_init(&(ctx->N));
               ^
    230.       bn_init(&(ctx->Ni));
    231.       ctx->n0[0] = ctx->n0[1] = 0;

crypto/bn/bn_mont.c:230:5: Skipping bn_init(): empty list of specs
    228.       bn_init(&(ctx->RR));
    229.       bn_init(&(ctx->N));
    230.       bn_init(&(ctx->Ni));
               ^
    231.       ctx->n0[0] = ctx->n0[1] = 0;
    232.       ctx->flags = 0;

crypto/bn/bn_mont.c:231:5: 
    229.       bn_init(&(ctx->N));
    230.       bn_init(&(ctx->Ni));
    231. >     ctx->n0[0] = ctx->n0[1] = 0;
    232.       ctx->flags = 0;
    233.   }

crypto/bn/bn_mont.c:232:5: 
    230.       bn_init(&(ctx->Ni));
    231.       ctx->n0[0] = ctx->n0[1] = 0;
    232. >     ctx->flags = 0;
    233.   }
    234.   

crypto/bn/bn_mont.c:233:1: return from a call to BN_MONT_CTX_init
    231.       ctx->n0[0] = ctx->n0[1] = 0;
    232.       ctx->flags = 0;
    233. > }
    234.   
    235.   void BN_MONT_CTX_free(BN_MONT_CTX *mont)

crypto/bn/bn_mont.c:221:5: 
  219.   
  220.       BN_MONT_CTX_init(ret);
  221. >     ret->flags = BN_FLG_MALLOCED;
  222.       return (ret);
  223.   }

crypto/bn/bn_mont.c:222:5: 
  220.       BN_MONT_CTX_init(ret);
  221.       ret->flags = BN_FLG_MALLOCED;
  222. >     return (ret);
  223.   }
  224.   

crypto/bn/bn_mont.c:223:1: return from a call to BN_MONT_CTX_new
  221.       ret->flags = BN_FLG_MALLOCED;
  222.       return (ret);
  223. > }
  224.   
  225.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)

test/bntest.c:376:5: 
374.       mont = BN_MONT_CTX_new();
375.   
376. >     BN_bntest_rand(m, 1024, 0, 1); /* must be odd for montgomery */
377.       /* Zero exponent */
378.       BN_bntest_rand(a, 1024, 0, 0);

crypto/bn/bn_rand.c:106:1: start of procedure BN_bntest_rand()
  104.   }
  105.   
  106. > int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
  107.   {
  108.       return bnrand(2, rnd, bits, top, bottom);

crypto/bn/bn_rand.c:108:5: Skipping bnrand(): empty list of specs
  106.   int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
  107.   {
  108.       return bnrand(2, rnd, bits, top, bottom);
             ^
  109.   }
  110.   

crypto/bn/bn_rand.c:109:1: return from a call to BN_bntest_rand
  107.   {
  108.       return bnrand(2, rnd, bits, top, bottom);
  109. > }
  110.   
  111.   /* random number r:  0 <= r < range */

test/bntest.c:378:5: 
376.       BN_bntest_rand(m, 1024, 0, 1); /* must be odd for montgomery */
377.       /* Zero exponent */
378. >     BN_bntest_rand(a, 1024, 0, 0);
379.       BN_zero(p);
380.       if (!BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL))

crypto/bn/bn_rand.c:106:1: start of procedure BN_bntest_rand()
  104.   }
  105.   
  106. > int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
  107.   {
  108.       return bnrand(2, rnd, bits, top, bottom);

crypto/bn/bn_rand.c:108:5: Skipping bnrand(): empty list of specs
  106.   int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
  107.   {
  108.       return bnrand(2, rnd, bits, top, bottom);
             ^
  109.   }
  110.   

crypto/bn/bn_rand.c:109:1: return from a call to BN_bntest_rand
  107.   {
  108.       return bnrand(2, rnd, bits, top, bottom);
  109. > }
  110.   
  111.   /* random number r:  0 <= r < range */

test/bntest.c:379:5: Skipping BN_set_word(): empty list of specs
377.       /* Zero exponent */
378.       BN_bntest_rand(a, 1024, 0, 0);
379.       BN_zero(p);
           ^
380.       if (!BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL))
381.           return 0;

test/bntest.c:380:10: Taking false branch
378.       BN_bntest_rand(a, 1024, 0, 0);
379.       BN_zero(p);
380.       if (!BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL))
                ^
381.           return 0;
382.       if (!BN_is_one(d)) {

test/bntest.c:382:10: 
380.       if (!BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL))
381.           return 0;
382. >     if (!BN_is_one(d)) {
383.           printf("Modular exponentiation test failed!\n");
384.           return 0;

crypto/bn/bn_lib.c:925:1: start of procedure BN_is_one()
  923.   }
  924.   
  925. > int BN_is_one(const BIGNUM *a)
  926.   {
  927.       return BN_abs_is_word(a, 1) && !a->neg;

crypto/bn/bn_lib.c:927:12: 
  925.   int BN_is_one(const BIGNUM *a)
  926.   {
  927. >     return BN_abs_is_word(a, 1) && !a->neg;
  928.   }
  929.   

crypto/bn/bn_lib.c:915:1: start of procedure BN_abs_is_word()
    913.   }
    914.   
    915. > int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
    916.   {
    917.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));

crypto/bn/bn_lib.c:917:14: Condition is true
    915.   int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
    916.   {
    917.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
                        ^
    918.   }
    919.   

crypto/bn/bn_lib.c:917:31: Condition is true
    915.   int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
    916.   {
    917.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
                                         ^
    918.   }
    919.   

crypto/bn/bn_lib.c:917:12: 
    915.   int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
    916.   {
    917. >     return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
    918.   }
    919.   

crypto/bn/bn_lib.c:917:5: 
    915.   int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
    916.   {
    917. >     return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
    918.   }
    919.   

crypto/bn/bn_lib.c:918:1: return from a call to BN_abs_is_word
    916.   {
    917.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
    918. > }
    919.   
    920.   int BN_is_zero(const BIGNUM *a)

crypto/bn/bn_lib.c:927:12: Condition is true
  925.   int BN_is_one(const BIGNUM *a)
  926.   {
  927.       return BN_abs_is_word(a, 1) && !a->neg;
                    ^
  928.   }
  929.   

crypto/bn/bn_lib.c:927:37: Condition is false
  925.   int BN_is_one(const BIGNUM *a)
  926.   {
  927.       return BN_abs_is_word(a, 1) && !a->neg;
                                             ^
  928.   }
  929.   

crypto/bn/bn_lib.c:927:12: 
  925.   int BN_is_one(const BIGNUM *a)
  926.   {
  927. >     return BN_abs_is_word(a, 1) && !a->neg;
  928.   }
  929.   

crypto/bn/bn_lib.c:927:5: 
  925.   int BN_is_one(const BIGNUM *a)
  926.   {
  927. >     return BN_abs_is_word(a, 1) && !a->neg;
  928.   }
  929.   

crypto/bn/bn_lib.c:928:1: return from a call to BN_is_one
  926.   {
  927.       return BN_abs_is_word(a, 1) && !a->neg;
  928. > }
  929.   
  930.   int BN_is_word(const BIGNUM *a, const BN_ULONG w)

test/bntest.c:382:10: Taking true branch
380.       if (!BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL))
381.           return 0;
382.       if (!BN_is_one(d)) {
                ^
383.           printf("Modular exponentiation test failed!\n");
384.           return 0;

test/bntest.c:383:9: 
381.           return 0;
382.       if (!BN_is_one(d)) {
383. >         printf("Modular exponentiation test failed!\n");
384.           return 0;
385.       }

static int test_modexp_mont5()
{
    BIGNUM *a, *p, *m, *d, *e, *b, *n, *c;
    BN_MONT_CTX *mont;
    char *bigstring;
    a = BN_new();
    p = BN_new();
    m = BN_new();
    d = BN_new();
    e = BN_new();
    b = BN_new();
    n = BN_new();
    c = BN_new();
    mont = BN_MONT_CTX_new();
    BN_bntest_rand(m, 1024, 0, 1);
    BN_bntest_rand(a, 1024, 0, 0);
    BN_zero(p);
    if (!BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL))
        return 0;
    if (!BN_is_one(d)) {
        printf("Modular exponentiation test failed!\n");
        return 0;
    }
    BN_hex2bn(&a,
        "7878787878787878787878787878787878787878787878787878787878787878"
        "7878787878787878787878787878787878787878787878787878787878787878"
        "7878787878787878787878787878787878787878787878787878787878787878"
        "7878787878787878787878787878787878787878787878787878787878787878");
    BN_hex2bn(&b,
        "095D72C08C097BA488C5E439C655A192EAFB6380073D8C2664668EDDB4060744"
        "E16E57FB4EDB9AE10A0CEFCDC28A894F689A128379DB279D48A2E20849D68593"
        "9B7803BCF46CEBF5C533FB0DD35B080593DE5472E3FE5DB951B8BFF9B4CB8F03"
        "9CC638A5EE8CDD703719F8000E6A9F63BEED5F2FCD52FF293EA05A251BB4AB81");
    BN_hex2bn(&n,
        "D78AF684E71DB0C39CFF4E64FB9DB567132CB9C50CC98009FEB820B26F2DED9B"
        "91B9B5E2B83AE0AE4EB4E0523CA726BFBE969B89FD754F674CE99118C3F2D1C5"
        "D81FDC7C54E02B60262B241D53C040E99E45826ECA37A804668E690E1AFC1CA4"
        "2C9A15D84D4954425F0B7642FC0BD9D7B24E2618D2DCC9B729D944BADACFDDAF");
    BN_MONT_CTX_set(mont, n, ctx);
    BN_mod_mul_montgomery(c, a, b, mont, ctx);
    BN_mod_mul_montgomery(d, b, a, mont, ctx);
    if (BN_cmp(c, d)) {
        fprintf(stderr, "Montgomery multiplication test failed:"
                        " a*b != b*a.\n");
        return 0;
    }
    bigstring = glue(bn1strings);
    BN_hex2bn(&n, bigstring);
    OPENSSL_free(bigstring);
    bigstring = glue(bn2strings);
    BN_hex2bn(&a, bigstring);
    OPENSSL_free(bigstring);
    BN_free(b);
    b = BN_dup(a);
    BN_MONT_CTX_set(mont, n, ctx);
    BN_mod_mul_montgomery(c, a, a, mont, ctx);
    BN_mod_mul_montgomery(d, a, b, mont, ctx);
    if (BN_cmp(c, d)) {
        fprintf(stderr, "Montgomery multiplication test failed:"
                        " a**2 != a*a.\n");
        return 0;
    }
    BN_bntest_rand(p, 1024, 0, 0);
    BN_zero(a);
    if (!BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL))
        return 0;
    if (!BN_is_zero(d)) {
        fprintf(stderr, "Modular exponentiation test failed!\n");
        return 0;
    }
    BN_one(a);
    BN_MONT_CTX_set(mont, m, ctx);
    if (!BN_from_montgomery(e, a, mont, ctx))
        return 0;
    if (!BN_mod_exp_mont_consttime(d, e, p, m, ctx, NULL))
        return 0;
    if (!BN_mod_exp_simple(a, e, p, m, ctx))
        return 0;
    if (BN_cmp(a, d) != 0) {
        printf("Modular exponentiation test failed!\n");
        return 0;
    }
    BN_bntest_rand(e, 1024, 0, 0);
    if (!BN_mod_exp_mont_consttime(d, e, p, m, ctx, NULL))
        return 0;
    if (!BN_mod_exp_simple(a, e, p, m, ctx))
        return 0;
    if (BN_cmp(a, d) != 0) {
        printf("Modular exponentiation test failed!\n");
        return 0;
    }
    BN_MONT_CTX_free(mont);
    BN_free(a);
    BN_free(p);
    BN_free(m);
    BN_free(d);
    BN_free(e);
    BN_free(b);
    BN_free(n);
    BN_free(c);
    return 1;
}
['static int test_modexp_mont5()\n{\n    BIGNUM *a, *p, *m, *d, *e, *b, *n, *c;\n    BN_MONT_CTX *mont;\n    char *bigstring;\n    a = BN_new();\n    p = BN_new();\n    m = BN_new();\n    d = BN_new();\n    e = BN_new();\n    b = BN_new();\n    n = BN_new();\n    c = BN_new();\n    mont = BN_MONT_CTX_new();\n    BN_bntest_rand(m, 1024, 0, 1);\n    BN_bntest_rand(a, 1024, 0, 0);\n    BN_zero(p);\n    if (!BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL))\n        return 0;\n    if (!BN_is_one(d)) {\n        printf("Modular exponentiation test failed!\\n");\n        return 0;\n    }\n    BN_hex2bn(&a,\n        "7878787878787878787878787878787878787878787878787878787878787878"\n        "7878787878787878787878787878787878787878787878787878787878787878"\n        "7878787878787878787878787878787878787878787878787878787878787878"\n        "7878787878787878787878787878787878787878787878787878787878787878");\n    BN_hex2bn(&b,\n        "095D72C08C097BA488C5E439C655A192EAFB6380073D8C2664668EDDB4060744"\n        "E16E57FB4EDB9AE10A0CEFCDC28A894F689A128379DB279D48A2E20849D68593"\n        "9B7803BCF46CEBF5C533FB0DD35B080593DE5472E3FE5DB951B8BFF9B4CB8F03"\n        "9CC638A5EE8CDD703719F8000E6A9F63BEED5F2FCD52FF293EA05A251BB4AB81");\n    BN_hex2bn(&n,\n        "D78AF684E71DB0C39CFF4E64FB9DB567132CB9C50CC98009FEB820B26F2DED9B"\n        "91B9B5E2B83AE0AE4EB4E0523CA726BFBE969B89FD754F674CE99118C3F2D1C5"\n        "D81FDC7C54E02B60262B241D53C040E99E45826ECA37A804668E690E1AFC1CA4"\n        "2C9A15D84D4954425F0B7642FC0BD9D7B24E2618D2DCC9B729D944BADACFDDAF");\n    BN_MONT_CTX_set(mont, n, ctx);\n    BN_mod_mul_montgomery(c, a, b, mont, ctx);\n    BN_mod_mul_montgomery(d, b, a, mont, ctx);\n    if (BN_cmp(c, d)) {\n        fprintf(stderr, "Montgomery multiplication test failed:"\n                        " a*b != b*a.\\n");\n        return 0;\n    }\n    bigstring = glue(bn1strings);\n    BN_hex2bn(&n, bigstring);\n    OPENSSL_free(bigstring);\n    bigstring = glue(bn2strings);\n    BN_hex2bn(&a, bigstring);\n    OPENSSL_free(bigstring);\n    BN_free(b);\n    b = BN_dup(a);\n    BN_MONT_CTX_set(mont, n, ctx);\n    BN_mod_mul_montgomery(c, a, a, mont, ctx);\n    BN_mod_mul_montgomery(d, a, b, mont, ctx);\n    if (BN_cmp(c, d)) {\n        fprintf(stderr, "Montgomery multiplication test failed:"\n                        " a**2 != a*a.\\n");\n        return 0;\n    }\n    BN_bntest_rand(p, 1024, 0, 0);\n    BN_zero(a);\n    if (!BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL))\n        return 0;\n    if (!BN_is_zero(d)) {\n        fprintf(stderr, "Modular exponentiation test failed!\\n");\n        return 0;\n    }\n    BN_one(a);\n    BN_MONT_CTX_set(mont, m, ctx);\n    if (!BN_from_montgomery(e, a, mont, ctx))\n        return 0;\n    if (!BN_mod_exp_mont_consttime(d, e, p, m, ctx, NULL))\n        return 0;\n    if (!BN_mod_exp_simple(a, e, p, m, ctx))\n        return 0;\n    if (BN_cmp(a, d) != 0) {\n        printf("Modular exponentiation test failed!\\n");\n        return 0;\n    }\n    BN_bntest_rand(e, 1024, 0, 0);\n    if (!BN_mod_exp_mont_consttime(d, e, p, m, ctx, NULL))\n        return 0;\n    if (!BN_mod_exp_simple(a, e, p, m, ctx))\n        return 0;\n    if (BN_cmp(a, d) != 0) {\n        printf("Modular exponentiation test failed!\\n");\n        return 0;\n    }\n    BN_MONT_CTX_free(mont);\n    BN_free(a);\n    BN_free(p);\n    BN_free(m);\n    BN_free(d);\n    BN_free(e);\n    BN_free(b);\n    BN_free(n);\n    BN_free(c);\n    return 1;\n}', 'BN_MONT_CTX *BN_MONT_CTX_new(void)\n{\n    BN_MONT_CTX *ret;\n    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)\n        return (NULL);\n    BN_MONT_CTX_init(ret);\n    ret->flags = BN_FLG_MALLOCED;\n    return (ret);\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'void BN_MONT_CTX_init(BN_MONT_CTX *ctx)\n{\n    ctx->ri = 0;\n    bn_init(&(ctx->RR));\n    bn_init(&(ctx->N));\n    bn_init(&(ctx->Ni));\n    ctx->n0[0] = ctx->n0[1] = 0;\n    ctx->flags = 0;\n}', 'int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)\n{\n    return bnrand(2, rnd, bits, top, bottom);\n}', 'int BN_is_one(const BIGNUM *a)\n{\n    return BN_abs_is_word(a, 1) && !a->neg;\n}', 'int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)\n{\n    return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));\n}']