static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['static int test_invalid_keypair(void)\n{\n    int ret = 0;\n    RSA *key = NULL;\n    BN_CTX *ctx = NULL;\n    BIGNUM *p = NULL, *q = NULL, *n = NULL, *e = NULL, *d = NULL;\n    ret = TEST_ptr(key = RSA_new())\n          && TEST_ptr(ctx = BN_CTX_new())\n          && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, -1, 2048))\n          && TEST_ptr(p = bn_load_new(cav_p, sizeof(cav_p)))\n          && TEST_ptr(q = bn_load_new(cav_q, sizeof(cav_q)))\n          && TEST_ptr(e = bn_load_new(cav_e, sizeof(cav_e)))\n          && TEST_ptr(n = bn_load_new(cav_n, sizeof(cav_n)))\n          && TEST_ptr(d = bn_load_new(cav_d, sizeof(cav_d)))\n          && TEST_true(RSA_set0_key(key, n, e, d))\n          && TEST_true(RSA_set0_factors(key, p, q))\n          && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, 100, 2048))\n          && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, 112, 1024))\n          && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, 128, 2048))\n          && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, 140, 3072))\n          && TEST_false(rsa_sp800_56b_check_keypair(key, BN_value_one(), -1,\n                        2048))\n          && TEST_true(BN_add_word(e, 1))\n          && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, -1,\n                                                    2048))\n          && TEST_true(BN_sub_word(e, 1))\n          && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, -1, 3072))\n          && TEST_true(rsa_sp800_56b_check_keypair(key, e, 112, 2048))\n          && TEST_true(BN_add_word(n, 1))\n          && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, -1, 2048))\n          && TEST_true(BN_sub_word(n, 1))\n          && TEST_true(BN_sub_word(p, 2))\n          && TEST_true(BN_mul(n, p, q, ctx))\n          && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, -1, 2048))\n          && TEST_true(BN_add_word(p, 2))\n          && TEST_true(BN_mul(n, p, q, ctx))\n          && TEST_true(BN_sub_word(q, 2))\n          && TEST_true(BN_mul(n, p, q, ctx))\n          && TEST_false(rsa_sp800_56b_check_keypair(key, NULL, -1, 2048))\n          && TEST_true(BN_add_word(q, 2))\n          && TEST_true(BN_mul(n, p, q, ctx));\n    RSA_free(key);\n    BN_CTX_free(ctx);\n    return ret;\n}', 'int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)\n{\n    int ret = bn_mul_fixed_top(r, a, b, ctx);\n    bn_correct_top(r);\n    bn_check_top(r);\n    return ret;\n}', 'int bn_mul_fixed_top(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)\n{\n    int ret = 0;\n    int top, al, bl;\n    BIGNUM *rr;\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n    int i;\n#endif\n#ifdef BN_RECURSION\n    BIGNUM *t = NULL;\n    int j = 0, k;\n#endif\n    bn_check_top(a);\n    bn_check_top(b);\n    bn_check_top(r);\n    al = a->top;\n    bl = b->top;\n    if ((al == 0) || (bl == 0)) {\n        BN_zero(r);\n        return 1;\n    }\n    top = al + bl;\n    BN_CTX_start(ctx);\n    if ((r == a) || (r == b)) {\n        if ((rr = BN_CTX_get(ctx)) == NULL)\n            goto err;\n    } else\n        rr = r;\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n    i = al - bl;\n#endif\n#ifdef BN_MUL_COMBA\n    if (i == 0) {\n# if 0\n        if (al == 4) {\n            if (bn_wexpand(rr, 8) == NULL)\n                goto err;\n            rr->top = 8;\n            bn_mul_comba4(rr->d, a->d, b->d);\n            goto end;\n        }\n# endif\n        if (al == 8) {\n            if (bn_wexpand(rr, 16) == NULL)\n                goto err;\n            rr->top = 16;\n            bn_mul_comba8(rr->d, a->d, b->d);\n            goto end;\n        }\n    }\n#endif\n#ifdef BN_RECURSION\n    if ((al >= BN_MULL_SIZE_NORMAL) && (bl >= BN_MULL_SIZE_NORMAL)) {\n        if (i >= -1 && i <= 1) {\n            if (i >= 0) {\n                j = BN_num_bits_word((BN_ULONG)al);\n            }\n            if (i == -1) {\n                j = BN_num_bits_word((BN_ULONG)bl);\n            }\n            j = 1 << (j - 1);\n            assert(j <= al || j <= bl);\n            k = j + j;\n            t = BN_CTX_get(ctx);\n            if (t == NULL)\n                goto err;\n            if (al > j || bl > j) {\n                if (bn_wexpand(t, k * 4) == NULL)\n                    goto err;\n                if (bn_wexpand(rr, k * 4) == NULL)\n                    goto err;\n                bn_mul_part_recursive(rr->d, a->d, b->d,\n                                      j, al - j, bl - j, t->d);\n            } else {\n                if (bn_wexpand(t, k * 2) == NULL)\n                    goto err;\n                if (bn_wexpand(rr, k * 2) == NULL)\n                    goto err;\n                bn_mul_recursive(rr->d, a->d, b->d, j, al - j, bl - j, t->d);\n            }\n            rr->top = top;\n            goto end;\n        }\n    }\n#endif\n    if (bn_wexpand(rr, top) == NULL)\n        goto err;\n    rr->top = top;\n    bn_mul_normal(rr->d, a->d, al, b->d, bl);\n#if defined(BN_MUL_COMBA) || defined(BN_RECURSION)\n end:\n#endif\n    rr->neg = a->neg ^ b->neg;\n    rr->flags |= BN_FLG_FIXED_TOP;\n    if (r != rr && BN_copy(r, rr) == NULL)\n        goto err;\n    ret = 1;\n err:\n    bn_check_top(r);\n    BN_CTX_end(ctx);\n    return ret;\n}', 'void BN_CTX_start(BN_CTX *ctx)\n{\n    CTXDBG("ENTER BN_CTX_start()", ctx);\n    if (ctx->err_stack || ctx->too_many)\n        ctx->err_stack++;\n    else if (!BN_STACK_push(&ctx->stack, ctx->used)) {\n        BNerr(BN_F_BN_CTX_START, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        ctx->err_stack++;\n    }\n    CTXDBG("LEAVE BN_CTX_start()", ctx);\n}', 'void BN_CTX_end(BN_CTX *ctx)\n{\n    CTXDBG("ENTER BN_CTX_end()", ctx);\n    if (ctx->err_stack)\n        ctx->err_stack--;\n    else {\n        unsigned int fp = BN_STACK_pop(&ctx->stack);\n        if (fp < ctx->used)\n            BN_POOL_release(&ctx->pool, ctx->used - fp);\n        ctx->used = fp;\n        ctx->too_many = 0;\n    }\n    CTXDBG("LEAVE BN_CTX_end()", ctx);\n}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']