test/bntest.c:552: error: MEMORY_LEAK
  memory dynamically allocated by call to `BN_MONT_CTX_new()` at line 399, column 17 is not reachable after line 552, column 5.
Showing all 146 steps of the trace


test/bntest.c:384:1: start of procedure test_modexp_mont5()
382.    * x86_64 cause a different code branch to be taken.
383.    */
384. > static int test_modexp_mont5(void)
385.   {
386.       BIGNUM *a = NULL, *p = NULL, *m = NULL, *d = NULL, *e = NULL;

test/bntest.c:386:5: 
384.   static int test_modexp_mont5(void)
385.   {
386. >     BIGNUM *a = NULL, *p = NULL, *m = NULL, *d = NULL, *e = NULL;
387.       BIGNUM *b = NULL, *n = NULL, *c = NULL;
388.       BN_MONT_CTX *mont = NULL;

test/bntest.c:387:5: 
385.   {
386.       BIGNUM *a = NULL, *p = NULL, *m = NULL, *d = NULL, *e = NULL;
387. >     BIGNUM *b = NULL, *n = NULL, *c = NULL;
388.       BN_MONT_CTX *mont = NULL;
389.       int st = 0;

test/bntest.c:388:5: 
386.       BIGNUM *a = NULL, *p = NULL, *m = NULL, *d = NULL, *e = NULL;
387.       BIGNUM *b = NULL, *n = NULL, *c = NULL;
388. >     BN_MONT_CTX *mont = NULL;
389.       int st = 0;
390.   

test/bntest.c:389:5: 
387.       BIGNUM *b = NULL, *n = NULL, *c = NULL;
388.       BN_MONT_CTX *mont = NULL;
389. >     int st = 0;
390.   
391.       if (!TEST_ptr(a = BN_new())

test/bntest.c:391:10: Skipping BN_new(): empty list of specs
389.       int st = 0;
390.   
391.       if (!TEST_ptr(a = BN_new())
                ^
392.               || !TEST_ptr(p = BN_new())
393.               || !TEST_ptr(m = BN_new())

test/testutil/tests.c:228:1: start of procedure test_ptr()
  226.   }
  227.   
  228. > int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)

test/testutil/tests.c:230:9: Taking true branch
  228.   int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)
                 ^
  231.           return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:231:9: 
  229.   {
  230.       if (p != NULL)
  231. >         return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;

test/testutil/tests.c:234:1: return from a call to test_ptr
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;
  234. > }
  235.   
  236.   int test_true(const char *file, int line, const char *s, int b)

test/bntest.c:391:10: Taking false branch
389.       int st = 0;
390.   
391.       if (!TEST_ptr(a = BN_new())
                ^
392.               || !TEST_ptr(p = BN_new())
393.               || !TEST_ptr(m = BN_new())

test/bntest.c:392:17: Skipping BN_new(): empty list of specs
390.   
391.       if (!TEST_ptr(a = BN_new())
392.               || !TEST_ptr(p = BN_new())
                       ^
393.               || !TEST_ptr(m = BN_new())
394.               || !TEST_ptr(d = BN_new())

test/testutil/tests.c:228:1: start of procedure test_ptr()
  226.   }
  227.   
  228. > int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)

test/testutil/tests.c:230:9: Taking true branch
  228.   int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)
                 ^
  231.           return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:231:9: 
  229.   {
  230.       if (p != NULL)
  231. >         return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;

test/testutil/tests.c:234:1: return from a call to test_ptr
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;
  234. > }
  235.   
  236.   int test_true(const char *file, int line, const char *s, int b)

test/bntest.c:392:17: Taking false branch
390.   
391.       if (!TEST_ptr(a = BN_new())
392.               || !TEST_ptr(p = BN_new())
                       ^
393.               || !TEST_ptr(m = BN_new())
394.               || !TEST_ptr(d = BN_new())

test/bntest.c:393:17: Skipping BN_new(): empty list of specs
391.       if (!TEST_ptr(a = BN_new())
392.               || !TEST_ptr(p = BN_new())
393.               || !TEST_ptr(m = BN_new())
                       ^
394.               || !TEST_ptr(d = BN_new())
395.               || !TEST_ptr(e = BN_new())

test/testutil/tests.c:228:1: start of procedure test_ptr()
  226.   }
  227.   
  228. > int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)

test/testutil/tests.c:230:9: Taking true branch
  228.   int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)
                 ^
  231.           return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:231:9: 
  229.   {
  230.       if (p != NULL)
  231. >         return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;

test/testutil/tests.c:234:1: return from a call to test_ptr
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;
  234. > }
  235.   
  236.   int test_true(const char *file, int line, const char *s, int b)

test/bntest.c:393:17: Taking false branch
391.       if (!TEST_ptr(a = BN_new())
392.               || !TEST_ptr(p = BN_new())
393.               || !TEST_ptr(m = BN_new())
                       ^
394.               || !TEST_ptr(d = BN_new())
395.               || !TEST_ptr(e = BN_new())

test/bntest.c:394:17: Skipping BN_new(): empty list of specs
392.               || !TEST_ptr(p = BN_new())
393.               || !TEST_ptr(m = BN_new())
394.               || !TEST_ptr(d = BN_new())
                       ^
395.               || !TEST_ptr(e = BN_new())
396.               || !TEST_ptr(b = BN_new())

test/testutil/tests.c:228:1: start of procedure test_ptr()
  226.   }
  227.   
  228. > int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)

test/testutil/tests.c:230:9: Taking true branch
  228.   int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)
                 ^
  231.           return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:231:9: 
  229.   {
  230.       if (p != NULL)
  231. >         return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;

test/testutil/tests.c:234:1: return from a call to test_ptr
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;
  234. > }
  235.   
  236.   int test_true(const char *file, int line, const char *s, int b)

test/bntest.c:394:17: Taking false branch
392.               || !TEST_ptr(p = BN_new())
393.               || !TEST_ptr(m = BN_new())
394.               || !TEST_ptr(d = BN_new())
                       ^
395.               || !TEST_ptr(e = BN_new())
396.               || !TEST_ptr(b = BN_new())

test/bntest.c:395:17: Skipping BN_new(): empty list of specs
393.               || !TEST_ptr(m = BN_new())
394.               || !TEST_ptr(d = BN_new())
395.               || !TEST_ptr(e = BN_new())
                       ^
396.               || !TEST_ptr(b = BN_new())
397.               || !TEST_ptr(n = BN_new())

test/testutil/tests.c:228:1: start of procedure test_ptr()
  226.   }
  227.   
  228. > int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)

test/testutil/tests.c:230:9: Taking true branch
  228.   int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)
                 ^
  231.           return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:231:9: 
  229.   {
  230.       if (p != NULL)
  231. >         return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;

test/testutil/tests.c:234:1: return from a call to test_ptr
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;
  234. > }
  235.   
  236.   int test_true(const char *file, int line, const char *s, int b)

test/bntest.c:395:17: Taking false branch
393.               || !TEST_ptr(m = BN_new())
394.               || !TEST_ptr(d = BN_new())
395.               || !TEST_ptr(e = BN_new())
                       ^
396.               || !TEST_ptr(b = BN_new())
397.               || !TEST_ptr(n = BN_new())

test/bntest.c:396:17: Skipping BN_new(): empty list of specs
394.               || !TEST_ptr(d = BN_new())
395.               || !TEST_ptr(e = BN_new())
396.               || !TEST_ptr(b = BN_new())
                       ^
397.               || !TEST_ptr(n = BN_new())
398.               || !TEST_ptr(c = BN_new())

test/testutil/tests.c:228:1: start of procedure test_ptr()
  226.   }
  227.   
  228. > int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)

test/testutil/tests.c:230:9: Taking true branch
  228.   int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)
                 ^
  231.           return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:231:9: 
  229.   {
  230.       if (p != NULL)
  231. >         return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;

test/testutil/tests.c:234:1: return from a call to test_ptr
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;
  234. > }
  235.   
  236.   int test_true(const char *file, int line, const char *s, int b)

test/bntest.c:396:17: Taking false branch
394.               || !TEST_ptr(d = BN_new())
395.               || !TEST_ptr(e = BN_new())
396.               || !TEST_ptr(b = BN_new())
                       ^
397.               || !TEST_ptr(n = BN_new())
398.               || !TEST_ptr(c = BN_new())

test/bntest.c:397:17: Skipping BN_new(): empty list of specs
395.               || !TEST_ptr(e = BN_new())
396.               || !TEST_ptr(b = BN_new())
397.               || !TEST_ptr(n = BN_new())
                       ^
398.               || !TEST_ptr(c = BN_new())
399.               || !TEST_ptr(mont = BN_MONT_CTX_new()))

test/testutil/tests.c:228:1: start of procedure test_ptr()
  226.   }
  227.   
  228. > int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)

test/testutil/tests.c:230:9: Taking true branch
  228.   int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)
                 ^
  231.           return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:231:9: 
  229.   {
  230.       if (p != NULL)
  231. >         return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;

test/testutil/tests.c:234:1: return from a call to test_ptr
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;
  234. > }
  235.   
  236.   int test_true(const char *file, int line, const char *s, int b)

test/bntest.c:397:17: Taking false branch
395.               || !TEST_ptr(e = BN_new())
396.               || !TEST_ptr(b = BN_new())
397.               || !TEST_ptr(n = BN_new())
                       ^
398.               || !TEST_ptr(c = BN_new())
399.               || !TEST_ptr(mont = BN_MONT_CTX_new()))

test/bntest.c:398:17: Skipping BN_new(): empty list of specs
396.               || !TEST_ptr(b = BN_new())
397.               || !TEST_ptr(n = BN_new())
398.               || !TEST_ptr(c = BN_new())
                       ^
399.               || !TEST_ptr(mont = BN_MONT_CTX_new()))
400.           goto err;

test/testutil/tests.c:228:1: start of procedure test_ptr()
  226.   }
  227.   
  228. > int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)

test/testutil/tests.c:230:9: Taking true branch
  228.   int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)
                 ^
  231.           return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:231:9: 
  229.   {
  230.       if (p != NULL)
  231. >         return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;

test/testutil/tests.c:234:1: return from a call to test_ptr
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;
  234. > }
  235.   
  236.   int test_true(const char *file, int line, const char *s, int b)

test/bntest.c:398:17: Taking false branch
396.               || !TEST_ptr(b = BN_new())
397.               || !TEST_ptr(n = BN_new())
398.               || !TEST_ptr(c = BN_new())
                       ^
399.               || !TEST_ptr(mont = BN_MONT_CTX_new()))
400.           goto err;

test/bntest.c:399:17: 
397.               || !TEST_ptr(n = BN_new())
398.               || !TEST_ptr(c = BN_new())
399. >             || !TEST_ptr(mont = BN_MONT_CTX_new()))
400.           goto err;
401.   

crypto/bn/bn_mont.c:198:1: start of procedure BN_MONT_CTX_new()
  196.   }
  197.   
  198. > BN_MONT_CTX *BN_MONT_CTX_new(void)
  199.   {
  200.       BN_MONT_CTX *ret;

crypto/bn/bn_mont.c:202:9: 
  200.       BN_MONT_CTX *ret;
  201.   
  202. >     if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {
  203.           BNerr(BN_F_BN_MONT_CTX_NEW, ERR_R_MALLOC_FAILURE);
  204.           return NULL;

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
    190.   #endif
    191.   
    192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194.       void *ret = NULL;

crypto/mem.c:194:5: 
    192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194. >     void *ret = NULL;
    195.   
    196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking false branch
    195.   
    196.       INCREMENT(malloc_count);
    197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    198.           return malloc_impl(num, file, line);
    199.   

crypto/mem.c:200:9: Taking false branch
    198.           return malloc_impl(num, file, line);
    199.   
    200.       if (num == 0)
                   ^
    201.           return NULL;
    202.   

crypto/mem.c:204:9: Taking true branch
    202.   
    203.       FAILTEST();
    204.       if (allow_customize) {
                   ^
    205.           /*
    206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:210:9: 
    208.            * allocation.
    209.            */
    210. >         allow_customize = 0;
    211.       }
    212.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:221:5: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:221:19: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:222:5: 
    220.   #else
    221.       (void)(file); (void)(line);
    222. >     ret = malloc(num);
    223.   #endif
    224.   

crypto/mem.c:225:5: 
    223.   #endif
    224.   
    225. >     return ret;
    226.   }
    227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
    224.   
    225.       return ret;
    226. > }
    227.   
    228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/bn/bn_mont.c:202:9: Taking false branch
  200.       BN_MONT_CTX *ret;
  201.   
  202.       if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {
                 ^
  203.           BNerr(BN_F_BN_MONT_CTX_NEW, ERR_R_MALLOC_FAILURE);
  204.           return NULL;

crypto/bn/bn_mont.c:207:5: 
  205.       }
  206.   
  207. >     BN_MONT_CTX_init(ret);
  208.       ret->flags = BN_FLG_MALLOCED;
  209.       return ret;

crypto/bn/bn_mont.c:212:1: start of procedure BN_MONT_CTX_init()
    210.   }
    211.   
    212. > void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
    213.   {
    214.       ctx->ri = 0;

crypto/bn/bn_mont.c:214:5: 
    212.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)
    213.   {
    214. >     ctx->ri = 0;
    215.       bn_init(&ctx->RR);
    216.       bn_init(&ctx->N);

crypto/bn/bn_mont.c:215:5: Skipping bn_init(): empty list of specs
    213.   {
    214.       ctx->ri = 0;
    215.       bn_init(&ctx->RR);
               ^
    216.       bn_init(&ctx->N);
    217.       bn_init(&ctx->Ni);

crypto/bn/bn_mont.c:216:5: Skipping bn_init(): empty list of specs
    214.       ctx->ri = 0;
    215.       bn_init(&ctx->RR);
    216.       bn_init(&ctx->N);
               ^
    217.       bn_init(&ctx->Ni);
    218.       ctx->n0[0] = ctx->n0[1] = 0;

crypto/bn/bn_mont.c:217:5: Skipping bn_init(): empty list of specs
    215.       bn_init(&ctx->RR);
    216.       bn_init(&ctx->N);
    217.       bn_init(&ctx->Ni);
               ^
    218.       ctx->n0[0] = ctx->n0[1] = 0;
    219.       ctx->flags = 0;

crypto/bn/bn_mont.c:218:5: 
    216.       bn_init(&ctx->N);
    217.       bn_init(&ctx->Ni);
    218. >     ctx->n0[0] = ctx->n0[1] = 0;
    219.       ctx->flags = 0;
    220.   }

crypto/bn/bn_mont.c:219:5: 
    217.       bn_init(&ctx->Ni);
    218.       ctx->n0[0] = ctx->n0[1] = 0;
    219. >     ctx->flags = 0;
    220.   }
    221.   

crypto/bn/bn_mont.c:220:1: return from a call to BN_MONT_CTX_init
    218.       ctx->n0[0] = ctx->n0[1] = 0;
    219.       ctx->flags = 0;
    220. > }
    221.   
    222.   void BN_MONT_CTX_free(BN_MONT_CTX *mont)

crypto/bn/bn_mont.c:208:5: 
  206.   
  207.       BN_MONT_CTX_init(ret);
  208. >     ret->flags = BN_FLG_MALLOCED;
  209.       return ret;
  210.   }

crypto/bn/bn_mont.c:209:5: 
  207.       BN_MONT_CTX_init(ret);
  208.       ret->flags = BN_FLG_MALLOCED;
  209. >     return ret;
  210.   }
  211.   

crypto/bn/bn_mont.c:210:1: return from a call to BN_MONT_CTX_new
  208.       ret->flags = BN_FLG_MALLOCED;
  209.       return ret;
  210. > }
  211.   
  212.   void BN_MONT_CTX_init(BN_MONT_CTX *ctx)

test/testutil/tests.c:228:1: start of procedure test_ptr()
  226.   }
  227.   
  228. > int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)

test/testutil/tests.c:230:9: Taking true branch
  228.   int test_ptr(const char *file, int line, const char *s, const void *p)
  229.   {
  230.       if (p != NULL)
                 ^
  231.           return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);

test/testutil/tests.c:231:9: 
  229.   {
  230.       if (p != NULL)
  231. >         return 1;
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;

test/testutil/tests.c:234:1: return from a call to test_ptr
  232.       test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);
  233.       return 0;
  234. > }
  235.   
  236.   int test_true(const char *file, int line, const char *s, int b)

test/bntest.c:399:17: Taking false branch
397.               || !TEST_ptr(n = BN_new())
398.               || !TEST_ptr(c = BN_new())
399.               || !TEST_ptr(mont = BN_MONT_CTX_new()))
                       ^
400.           goto err;
401.   

test/bntest.c:402:5: 
400.           goto err;
401.   
402. >     BN_bntest_rand(m, 1024, 0, 1); /* must be odd for montgomery */
403.       /* Zero exponent */
404.       BN_bntest_rand(a, 1024, 0, 0);

crypto/bn/bn_rand.c:102:1: start of procedure BN_bntest_rand()
  100.   }
  101.   
  102. > int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
  103.   {
  104.       return bnrand(TESTING, rnd, bits, top, bottom);

crypto/bn/bn_rand.c:104:5: Skipping bnrand(): empty list of specs
  102.   int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
  103.   {
  104.       return bnrand(TESTING, rnd, bits, top, bottom);
             ^
  105.   }
  106.   

crypto/bn/bn_rand.c:105:1: return from a call to BN_bntest_rand
  103.   {
  104.       return bnrand(TESTING, rnd, bits, top, bottom);
  105. > }
  106.   
  107.   int BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom)

test/bntest.c:404:5: 
402.       BN_bntest_rand(m, 1024, 0, 1); /* must be odd for montgomery */
403.       /* Zero exponent */
404. >     BN_bntest_rand(a, 1024, 0, 0);
405.       BN_zero(p);
406.       if (!TEST_true(BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL)))

crypto/bn/bn_rand.c:102:1: start of procedure BN_bntest_rand()
  100.   }
  101.   
  102. > int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
  103.   {
  104.       return bnrand(TESTING, rnd, bits, top, bottom);

crypto/bn/bn_rand.c:104:5: Skipping bnrand(): empty list of specs
  102.   int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
  103.   {
  104.       return bnrand(TESTING, rnd, bits, top, bottom);
             ^
  105.   }
  106.   

crypto/bn/bn_rand.c:105:1: return from a call to BN_bntest_rand
  103.   {
  104.       return bnrand(TESTING, rnd, bits, top, bottom);
  105. > }
  106.   
  107.   int BN_priv_rand(BIGNUM *rnd, int bits, int top, int bottom)

test/bntest.c:405:5: Skipping BN_set_word(): empty list of specs
403.       /* Zero exponent */
404.       BN_bntest_rand(a, 1024, 0, 0);
405.       BN_zero(p);
           ^
406.       if (!TEST_true(BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL)))
407.           goto err;

test/bntest.c:406:10: Condition is true
404.       BN_bntest_rand(a, 1024, 0, 0);
405.       BN_zero(p);
406.       if (!TEST_true(BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL)))
                ^
407.           goto err;
408.       if (!TEST_BN_eq_one(d))

test/testutil/tests.c:236:1: start of procedure test_true()
  234.   }
  235.   
  236. > int test_true(const char *file, int line, const char *s, int b)
  237.   {
  238.       if (b)

test/testutil/tests.c:238:9: Taking true branch
  236.   int test_true(const char *file, int line, const char *s, int b)
  237.   {
  238.       if (b)
                 ^
  239.           return 1;
  240.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");

test/testutil/tests.c:239:9: 
  237.   {
  238.       if (b)
  239. >         return 1;
  240.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");
  241.       return 0;

test/testutil/tests.c:242:1: return from a call to test_true
  240.       test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");
  241.       return 0;
  242. > }
  243.   
  244.   int test_false(const char *file, int line, const char *s, int b)

test/bntest.c:406:10: Taking false branch
404.       BN_bntest_rand(a, 1024, 0, 0);
405.       BN_zero(p);
406.       if (!TEST_true(BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL)))
                ^
407.           goto err;
408.       if (!TEST_BN_eq_one(d))

test/bntest.c:408:10: 
406.       if (!TEST_true(BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL)))
407.           goto err;
408. >     if (!TEST_BN_eq_one(d))
409.           goto err;
410.   

test/testutil/tests.c:364:1: start of procedure test_BN_eq_one()
  362.   DEFINE_BN_COMPARISONS(le, <=, BN_is_negative(a) || BN_is_zero(a))
  363.   
  364. > int test_BN_eq_one(const char *file, int line, const char *s, const BIGNUM *a)
  365.   {
  366.       if (a != NULL && BN_is_one(a))

test/testutil/tests.c:366:9: Taking true branch
  364.   int test_BN_eq_one(const char *file, int line, const char *s, const BIGNUM *a)
  365.   {
  366.       if (a != NULL && BN_is_one(a))
                 ^
  367.           return 1;
  368.       test_fail_bignum_mono_message(NULL, file, line, "BIGNUM", s, "1", "==", a);

test/testutil/tests.c:366:22: 
  364.   int test_BN_eq_one(const char *file, int line, const char *s, const BIGNUM *a)
  365.   {
  366. >     if (a != NULL && BN_is_one(a))
  367.           return 1;
  368.       test_fail_bignum_mono_message(NULL, file, line, "BIGNUM", s, "1", "==", a);

crypto/bn/bn_lib.c:850:1: start of procedure BN_is_one()
    848.   }
    849.   
    850. > int BN_is_one(const BIGNUM *a)
    851.   {
    852.       return BN_abs_is_word(a, 1) && !a->neg;

crypto/bn/bn_lib.c:852:12: 
    850.   int BN_is_one(const BIGNUM *a)
    851.   {
    852. >     return BN_abs_is_word(a, 1) && !a->neg;
    853.   }
    854.   

crypto/bn/bn_lib.c:840:1: start of procedure BN_abs_is_word()
      838.   }
      839.   
      840. > int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
      841.   {
      842.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));

crypto/bn/bn_lib.c:842:14: Condition is true
      840.   int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
      841.   {
      842.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
                          ^
      843.   }
      844.   

crypto/bn/bn_lib.c:842:31: Condition is true
      840.   int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
      841.   {
      842.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
                                           ^
      843.   }
      844.   

crypto/bn/bn_lib.c:842:12: 
      840.   int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
      841.   {
      842. >     return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
      843.   }
      844.   

crypto/bn/bn_lib.c:842:5: 
      840.   int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w)
      841.   {
      842. >     return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
      843.   }
      844.   

crypto/bn/bn_lib.c:843:1: return from a call to BN_abs_is_word
      841.   {
      842.       return ((a->top == 1) && (a->d[0] == w)) || ((w == 0) && (a->top == 0));
      843. > }
      844.   
      845.   int BN_is_zero(const BIGNUM *a)

crypto/bn/bn_lib.c:852:12: Condition is true
    850.   int BN_is_one(const BIGNUM *a)
    851.   {
    852.       return BN_abs_is_word(a, 1) && !a->neg;
                      ^
    853.   }
    854.   

crypto/bn/bn_lib.c:852:37: Condition is true
    850.   int BN_is_one(const BIGNUM *a)
    851.   {
    852.       return BN_abs_is_word(a, 1) && !a->neg;
                                               ^
    853.   }
    854.   

crypto/bn/bn_lib.c:852:12: 
    850.   int BN_is_one(const BIGNUM *a)
    851.   {
    852. >     return BN_abs_is_word(a, 1) && !a->neg;
    853.   }
    854.   

crypto/bn/bn_lib.c:852:5: 
    850.   int BN_is_one(const BIGNUM *a)
    851.   {
    852. >     return BN_abs_is_word(a, 1) && !a->neg;
    853.   }
    854.   

crypto/bn/bn_lib.c:853:1: return from a call to BN_is_one
    851.   {
    852.       return BN_abs_is_word(a, 1) && !a->neg;
    853. > }
    854.   
    855.   int BN_is_word(const BIGNUM *a, const BN_ULONG w)

test/testutil/tests.c:366:22: Taking true branch
  364.   int test_BN_eq_one(const char *file, int line, const char *s, const BIGNUM *a)
  365.   {
  366.       if (a != NULL && BN_is_one(a))
                              ^
  367.           return 1;
  368.       test_fail_bignum_mono_message(NULL, file, line, "BIGNUM", s, "1", "==", a);

test/testutil/tests.c:367:9: 
  365.   {
  366.       if (a != NULL && BN_is_one(a))
  367. >         return 1;
  368.       test_fail_bignum_mono_message(NULL, file, line, "BIGNUM", s, "1", "==", a);
  369.       return 0;

test/testutil/tests.c:370:1: return from a call to test_BN_eq_one
  368.       test_fail_bignum_mono_message(NULL, file, line, "BIGNUM", s, "1", "==", a);
  369.       return 0;
  370. > }
  371.   
  372.   int test_BN_odd(const char *file, int line, const char *s, const BIGNUM *a)

test/bntest.c:408:10: Taking false branch
406.       if (!TEST_true(BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL)))
407.           goto err;
408.       if (!TEST_BN_eq_one(d))
                ^
409.           goto err;
410.   

test/bntest.c:412:5: Skipping BN_hex2bn(): empty list of specs
410.   
411.       /* Regression test for carry bug in mulx4x_mont */
412.       BN_hex2bn(&a,
           ^
413.           "7878787878787878787878787878787878787878787878787878787878787878"
414.           "7878787878787878787878787878787878787878787878787878787878787878"

test/bntest.c:417:5: Skipping BN_hex2bn(): empty list of specs
415.           "7878787878787878787878787878787878787878787878787878787878787878"
416.           "7878787878787878787878787878787878787878787878787878787878787878");
417.       BN_hex2bn(&b,
           ^
418.           "095D72C08C097BA488C5E439C655A192EAFB6380073D8C2664668EDDB4060744"
419.           "E16E57FB4EDB9AE10A0CEFCDC28A894F689A128379DB279D48A2E20849D68593"

test/bntest.c:422:5: Skipping BN_hex2bn(): empty list of specs
420.           "9B7803BCF46CEBF5C533FB0DD35B080593DE5472E3FE5DB951B8BFF9B4CB8F03"
421.           "9CC638A5EE8CDD703719F8000E6A9F63BEED5F2FCD52FF293EA05A251BB4AB81");
422.       BN_hex2bn(&n,
           ^
423.           "D78AF684E71DB0C39CFF4E64FB9DB567132CB9C50CC98009FEB820B26F2DED9B"
424.           "91B9B5E2B83AE0AE4EB4E0523CA726BFBE969B89FD754F674CE99118C3F2D1C5"

test/bntest.c:427:5: Skipping BN_MONT_CTX_set(): empty list of specs
425.           "D81FDC7C54E02B60262B241D53C040E99E45826ECA37A804668E690E1AFC1CA4"
426.           "2C9A15D84D4954425F0B7642FC0BD9D7B24E2618D2DCC9B729D944BADACFDDAF");
427.       BN_MONT_CTX_set(mont, n, ctx);
           ^
428.       BN_mod_mul_montgomery(c, a, b, mont, ctx);
429.       BN_mod_mul_montgomery(d, b, a, mont, ctx);

test/bntest.c:428:5: Skipping BN_mod_mul_montgomery(): empty list of specs
426.           "2C9A15D84D4954425F0B7642FC0BD9D7B24E2618D2DCC9B729D944BADACFDDAF");
427.       BN_MONT_CTX_set(mont, n, ctx);
428.       BN_mod_mul_montgomery(c, a, b, mont, ctx);
           ^
429.       BN_mod_mul_montgomery(d, b, a, mont, ctx);
430.       if (!TEST_BN_eq(c, d))

test/bntest.c:429:5: Skipping BN_mod_mul_montgomery(): empty list of specs
427.       BN_MONT_CTX_set(mont, n, ctx);
428.       BN_mod_mul_montgomery(c, a, b, mont, ctx);
429.       BN_mod_mul_montgomery(d, b, a, mont, ctx);
           ^
430.       if (!TEST_BN_eq(c, d))
431.           goto err;

test/bntest.c:430:10: 
428.       BN_mod_mul_montgomery(c, a, b, mont, ctx);
429.       BN_mod_mul_montgomery(d, b, a, mont, ctx);
430. >     if (!TEST_BN_eq(c, d))
431.           goto err;
432.   

test/testutil/tests.c:357:1: start of procedure test_BN_eq()
  355.       }
  356.   
  357. > DEFINE_BN_COMPARISONS(eq, ==, BN_is_zero(a))
  358.   DEFINE_BN_COMPARISONS(ne, !=, !BN_is_zero(a))
  359.   DEFINE_BN_COMPARISONS(gt, >,  !BN_is_negative(a) && !BN_is_zero(a))

test/testutil/tests.c:357:1: Taking false branch
  355.       }
  356.   
  357. > DEFINE_BN_COMPARISONS(eq, ==, BN_is_zero(a))
  358.   DEFINE_BN_COMPARISONS(ne, !=, !BN_is_zero(a))
  359.   DEFINE_BN_COMPARISONS(gt, >,  !BN_is_negative(a) && !BN_is_zero(a))

test/testutil/format_output.c:363:1: start of procedure test_fail_bignum_message()
    361.    * fails.  The third is the user's call to dump a bignum.
    362.    */
    363. > void test_fail_bignum_message(const char *prefix, const char *file,
    364.                                 int line, const char *type,
    365.                                 const char *left, const char *right,

test/testutil/format_output.c:369:5: Skipping test_fail_bignum_common(): empty list of specs
    367.                                 const BIGNUM *bn1, const BIGNUM *bn2)
    368.   {
    369.       test_fail_bignum_common(prefix, file, line, type, left, right, op, bn1, bn2);
               ^
    370.       test_printf_stderr("\n");
    371.   }

test/testutil/format_output.c:370:5: Skipping test_printf_stderr(): empty list of specs
    368.   {
    369.       test_fail_bignum_common(prefix, file, line, type, left, right, op, bn1, bn2);
    370.       test_printf_stderr("\n");
               ^
    371.   }
    372.   

test/testutil/format_output.c:371:1: return from a call to test_fail_bignum_message
    369.       test_fail_bignum_common(prefix, file, line, type, left, right, op, bn1, bn2);
    370.       test_printf_stderr("\n");
    371. > }
    372.   
    373.   void test_fail_bignum_mono_message(const char *prefix, const char *file,

test/testutil/tests.c:357:1: return from a call to test_BN_eq
  355.       }
  356.   
  357. > DEFINE_BN_COMPARISONS(eq, ==, BN_is_zero(a))
  358.   DEFINE_BN_COMPARISONS(ne, !=, !BN_is_zero(a))
  359.   DEFINE_BN_COMPARISONS(gt, >,  !BN_is_negative(a) && !BN_is_zero(a))

test/bntest.c:430:10: Taking true branch
428.       BN_mod_mul_montgomery(c, a, b, mont, ctx);
429.       BN_mod_mul_montgomery(d, b, a, mont, ctx);
430.       if (!TEST_BN_eq(c, d))
                ^
431.           goto err;
432.   

test/bntest.c:551:1: 
549.       st = 1;
550.   
551. > err:
552.       BN_MONT_CTX_free(mont);
553.       BN_free(a);

test/bntest.c:552:5: 
550.   
551.   err:
552. >     BN_MONT_CTX_free(mont);
553.       BN_free(a);
554.       BN_free(p);

crypto/bn/bn_mont.c:222:1: start of procedure BN_MONT_CTX_free()
  220.   }
  221.   
  222. > void BN_MONT_CTX_free(BN_MONT_CTX *mont)
  223.   {
  224.       if (mont == NULL)

crypto/bn/bn_mont.c:224:9: Taking false branch
  222.   void BN_MONT_CTX_free(BN_MONT_CTX *mont)
  223.   {
  224.       if (mont == NULL)
                 ^
  225.           return;
  226.       BN_clear_free(&mont->RR);

crypto/bn/bn_mont.c:226:5: Skipping BN_clear_free(): empty list of specs
  224.       if (mont == NULL)
  225.           return;
  226.       BN_clear_free(&mont->RR);
             ^
  227.       BN_clear_free(&mont->N);
  228.       BN_clear_free(&mont->Ni);

crypto/bn/bn_mont.c:227:5: Skipping BN_clear_free(): empty list of specs
  225.           return;
  226.       BN_clear_free(&mont->RR);
  227.       BN_clear_free(&mont->N);
             ^
  228.       BN_clear_free(&mont->Ni);
  229.       if (mont->flags & BN_FLG_MALLOCED)

crypto/bn/bn_mont.c:228:5: Skipping BN_clear_free(): empty list of specs
  226.       BN_clear_free(&mont->RR);
  227.       BN_clear_free(&mont->N);
  228.       BN_clear_free(&mont->Ni);
             ^
  229.       if (mont->flags & BN_FLG_MALLOCED)
  230.           OPENSSL_free(mont);

crypto/bn/bn_mont.c:229:9: Taking false branch
  227.       BN_clear_free(&mont->N);
  228.       BN_clear_free(&mont->Ni);
  229.       if (mont->flags & BN_FLG_MALLOCED)
                 ^
  230.           OPENSSL_free(mont);
  231.   }

crypto/bn/bn_mont.c:229:5: 
  227.       BN_clear_free(&mont->N);
  228.       BN_clear_free(&mont->Ni);
  229. >     if (mont->flags & BN_FLG_MALLOCED)
  230.           OPENSSL_free(mont);
  231.   }

crypto/bn/bn_mont.c:231:1: return from a call to BN_MONT_CTX_free
  229.       if (mont->flags & BN_FLG_MALLOCED)
  230.           OPENSSL_free(mont);
  231. > }
  232.   
  233.   int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)

static int test_modexp_mont5(void)
{
    BIGNUM *a = NULL, *p = NULL, *m = NULL, *d = NULL, *e = NULL;
    BIGNUM *b = NULL, *n = NULL, *c = NULL;
    BN_MONT_CTX *mont = NULL;
    int st = 0;
    if (!TEST_ptr(a = BN_new())
            || !TEST_ptr(p = BN_new())
            || !TEST_ptr(m = BN_new())
            || !TEST_ptr(d = BN_new())
            || !TEST_ptr(e = BN_new())
            || !TEST_ptr(b = BN_new())
            || !TEST_ptr(n = BN_new())
            || !TEST_ptr(c = BN_new())
            || !TEST_ptr(mont = BN_MONT_CTX_new()))
        goto err;
    BN_bntest_rand(m, 1024, 0, 1);
    BN_bntest_rand(a, 1024, 0, 0);
    BN_zero(p);
    if (!TEST_true(BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL)))
        goto err;
    if (!TEST_BN_eq_one(d))
        goto err;
    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 (!TEST_BN_eq(c, d))
        goto err;
    parse_bigBN(&n, bn1strings);
    parse_bigBN(&a, bn2strings);
    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 (!TEST_BN_eq(c, d))
        goto err;
    {
        static const char *ahex[] = {
                      "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8FFEADBCFC4DAE7FFF908E92820306B",
            "9544D954000000006C0000000000000000000000000000000000000000000000",
            "00000000000000000000FF030202FFFFF8FFEBDBCFC4DAE7FFF908E92820306B",
            "9544D954000000006C000000FF0302030000000000FFFFFFFFFFFFFFFFFFFFFF",
            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF01FC00FF02FFFFFFFF",
            "00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FCFD",
            "FCFFFFFFFFFF000000000000000000FF0302030000000000FFFFFFFFFFFFFFFF",
            "FF00FCFDFDFF030202FF00000000FFFFFFFFFFFFFFFFFF00FCFDFCFFFFFFFFFF",
            NULL
        };
        static const char *nhex[] = {
                      "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8F8F8F8000000",
            "00000010000000006C0000000000000000000000000000000000000000000000",
            "00000000000000000000000000000000000000FFFFFFFFFFFFF8F8F8F8000000",
            "00000010000000006C000000000000000000000000FFFFFFFFFFFFFFFFFFFFFF",
            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
            "00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
            "FFFFFFFFFFFF000000000000000000000000000000000000FFFFFFFFFFFFFFFF",
            "FFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
            NULL
        };
        parse_bigBN(&a, ahex);
        parse_bigBN(&n, nhex);
    }
    BN_free(b);
    b = BN_dup(a);
    BN_MONT_CTX_set(mont, n, ctx);
    if (!TEST_true(BN_mod_mul_montgomery(c, a, a, mont, ctx))
            || !TEST_true(BN_mod_mul_montgomery(d, a, b, mont, ctx))
            || !TEST_BN_eq(c, d))
        goto err;
    BN_hex2bn(&a,
        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
    BN_hex2bn(&n,
        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
    BN_MONT_CTX_set(mont, n, ctx);
    if (!TEST_false(BN_mod_mul_montgomery(d, a, a, mont, ctx)))
        goto err;
    BN_hex2bn(&a,
        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2020202020DF");
    BN_hex2bn(&b,
        "2020202020202020202020202020202020202020202020202020202020202020"
        "2020202020202020202020202020202020202020202020202020202020202020"
        "20202020202020FF202020202020202020202020202020202020202020202020"
        "2020202020202020202020202020202020202020202020202020202020202020");
    BN_hex2bn(&n,
        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2020202020FF");
    BN_MONT_CTX_set(mont, n, ctx);
    BN_mod_exp_mont_consttime(c, a, b, n, ctx, mont);
    BN_mod_exp_mont(d, a, b, n, ctx, mont);
    if (!TEST_BN_eq(c, d))
        goto err;
    BN_bntest_rand(p, 1024, 0, 0);
    BN_zero(a);
    if (!TEST_true(BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL))
            || !TEST_BN_eq_zero(d))
        goto err;
    BN_one(a);
    BN_MONT_CTX_set(mont, m, ctx);
    if (!TEST_true(BN_from_montgomery(e, a, mont, ctx))
            || !TEST_true(BN_mod_exp_mont_consttime(d, e, p, m, ctx, NULL))
            || !TEST_true(BN_mod_exp_simple(a, e, p, m, ctx))
            || !TEST_BN_eq(a, d))
        goto err;
    BN_bntest_rand(e, 1024, 0, 0);
    if (!TEST_true(BN_mod_exp_mont_consttime(d, e, p, m, ctx, NULL))
            || !TEST_true(BN_mod_exp_simple(a, e, p, m, ctx))
            || !TEST_BN_eq(a, d))
        goto err;
    st = 1;
err:
    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 st;
}
['static int test_modexp_mont5(void)\n{\n    BIGNUM *a = NULL, *p = NULL, *m = NULL, *d = NULL, *e = NULL;\n    BIGNUM *b = NULL, *n = NULL, *c = NULL;\n    BN_MONT_CTX *mont = NULL;\n    int st = 0;\n    if (!TEST_ptr(a = BN_new())\n            || !TEST_ptr(p = BN_new())\n            || !TEST_ptr(m = BN_new())\n            || !TEST_ptr(d = BN_new())\n            || !TEST_ptr(e = BN_new())\n            || !TEST_ptr(b = BN_new())\n            || !TEST_ptr(n = BN_new())\n            || !TEST_ptr(c = BN_new())\n            || !TEST_ptr(mont = BN_MONT_CTX_new()))\n        goto err;\n    BN_bntest_rand(m, 1024, 0, 1);\n    BN_bntest_rand(a, 1024, 0, 0);\n    BN_zero(p);\n    if (!TEST_true(BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL)))\n        goto err;\n    if (!TEST_BN_eq_one(d))\n        goto err;\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 (!TEST_BN_eq(c, d))\n        goto err;\n    parse_bigBN(&n, bn1strings);\n    parse_bigBN(&a, bn2strings);\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 (!TEST_BN_eq(c, d))\n        goto err;\n    {\n        static const char *ahex[] = {\n                      "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",\n            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",\n            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",\n            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",\n            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8FFEADBCFC4DAE7FFF908E92820306B",\n            "9544D954000000006C0000000000000000000000000000000000000000000000",\n            "00000000000000000000FF030202FFFFF8FFEBDBCFC4DAE7FFF908E92820306B",\n            "9544D954000000006C000000FF0302030000000000FFFFFFFFFFFFFFFFFFFFFF",\n            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF01FC00FF02FFFFFFFF",\n            "00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00FCFD",\n            "FCFFFFFFFFFF000000000000000000FF0302030000000000FFFFFFFFFFFFFFFF",\n            "FF00FCFDFDFF030202FF00000000FFFFFFFFFFFFFFFFFF00FCFDFCFFFFFFFFFF",\n            NULL\n        };\n        static const char *nhex[] = {\n                      "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",\n            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",\n            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",\n            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",\n            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8F8F8F8000000",\n            "00000010000000006C0000000000000000000000000000000000000000000000",\n            "00000000000000000000000000000000000000FFFFFFFFFFFFF8F8F8F8000000",\n            "00000010000000006C000000000000000000000000FFFFFFFFFFFFFFFFFFFFFF",\n            "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",\n            "00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",\n            "FFFFFFFFFFFF000000000000000000000000000000000000FFFFFFFFFFFFFFFF",\n            "FFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",\n            NULL\n        };\n        parse_bigBN(&a, ahex);\n        parse_bigBN(&n, nhex);\n    }\n    BN_free(b);\n    b = BN_dup(a);\n    BN_MONT_CTX_set(mont, n, ctx);\n    if (!TEST_true(BN_mod_mul_montgomery(c, a, a, mont, ctx))\n            || !TEST_true(BN_mod_mul_montgomery(d, a, b, mont, ctx))\n            || !TEST_BN_eq(c, d))\n        goto err;\n    BN_hex2bn(&a,\n        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");\n    BN_hex2bn(&n,\n        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");\n    BN_MONT_CTX_set(mont, n, ctx);\n    if (!TEST_false(BN_mod_mul_montgomery(d, a, a, mont, ctx)))\n        goto err;\n    BN_hex2bn(&a,\n        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2020202020DF");\n    BN_hex2bn(&b,\n        "2020202020202020202020202020202020202020202020202020202020202020"\n        "2020202020202020202020202020202020202020202020202020202020202020"\n        "20202020202020FF202020202020202020202020202020202020202020202020"\n        "2020202020202020202020202020202020202020202020202020202020202020");\n    BN_hex2bn(&n,\n        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"\n        "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2020202020FF");\n    BN_MONT_CTX_set(mont, n, ctx);\n    BN_mod_exp_mont_consttime(c, a, b, n, ctx, mont);\n    BN_mod_exp_mont(d, a, b, n, ctx, mont);\n    if (!TEST_BN_eq(c, d))\n        goto err;\n    BN_bntest_rand(p, 1024, 0, 0);\n    BN_zero(a);\n    if (!TEST_true(BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL))\n            || !TEST_BN_eq_zero(d))\n        goto err;\n    BN_one(a);\n    BN_MONT_CTX_set(mont, m, ctx);\n    if (!TEST_true(BN_from_montgomery(e, a, mont, ctx))\n            || !TEST_true(BN_mod_exp_mont_consttime(d, e, p, m, ctx, NULL))\n            || !TEST_true(BN_mod_exp_simple(a, e, p, m, ctx))\n            || !TEST_BN_eq(a, d))\n        goto err;\n    BN_bntest_rand(e, 1024, 0, 0);\n    if (!TEST_true(BN_mod_exp_mont_consttime(d, e, p, m, ctx, NULL))\n            || !TEST_true(BN_mod_exp_simple(a, e, p, m, ctx))\n            || !TEST_BN_eq(a, d))\n        goto err;\n    st = 1;\nerr:\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 st;\n}', 'int test_ptr(const char *file, int line, const char *s, const void *p)\n{\n    if (p != NULL)\n        return 1;\n    test_fail_message(NULL, file, line, "ptr", s, "NULL", "!=", "%p", p);\n    return 0;\n}', 'BN_MONT_CTX *BN_MONT_CTX_new(void)\n{\n    BN_MONT_CTX *ret;\n    if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL) {\n        BNerr(BN_F_BN_MONT_CTX_NEW, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\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    INCREMENT(malloc_count);\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    if (allow_customize) {\n        allow_customize = 0;\n    }\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    (void)(file); (void)(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(TESTING, rnd, bits, top, bottom);\n}', 'int test_true(const char *file, int line, const char *s, int b)\n{\n    if (b)\n        return 1;\n    test_fail_message(NULL, file, line, "bool", s, "true", "==", "false");\n    return 0;\n}', 'int test_BN_eq_one(const char *file, int line, const char *s, const BIGNUM *a)\n{\n    if (a != NULL && BN_is_one(a))\n        return 1;\n    test_fail_bignum_mono_message(NULL, file, line, "BIGNUM", s, "1", "==", a);\n    return 0;\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}', 'DEFINE_BN_COMPARISONS(eq, ==, BN_is_zero(a))', 'void test_fail_bignum_message(const char *prefix, const char *file,\n                              int line, const char *type,\n                              const char *left, const char *right,\n                              const char *op,\n                              const BIGNUM *bn1, const BIGNUM *bn2)\n{\n    test_fail_bignum_common(prefix, file, line, type, left, right, op, bn1, bn2);\n    test_printf_stderr("\\n");\n}', 'void BN_MONT_CTX_free(BN_MONT_CTX *mont)\n{\n    if (mont == NULL)\n        return;\n    BN_clear_free(&mont->RR);\n    BN_clear_free(&mont->N);\n    BN_clear_free(&mont->Ni);\n    if (mont->flags & BN_FLG_MALLOCED)\n        OPENSSL_free(mont);\n}']