static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
{
    BN_ULONG *a = NULL;
    if (words > (INT_MAX / (4 * BN_BITS2))) {
        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_BIGNUM_TOO_LONG);
        return NULL;
    }
    if (BN_get_flags(b, BN_FLG_STATIC_DATA)) {
        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);
        return NULL;
    }
    if (BN_get_flags(b, BN_FLG_SECURE))
        a = OPENSSL_secure_zalloc(words * sizeof(*a));
    else
        a = OPENSSL_zalloc(words * sizeof(*a));
    if (a == NULL) {
        BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);
        return NULL;
    }
    assert(b->top <= words);
    if (b->top > 0)
        memcpy(a, b->d, sizeof(*a) * b->top);
    return a;
}
['static int test_case_variant(OSSL_PARAM *params, const struct provider_dispatch_st *prov)\n{\n    BIGNUM *verify_p3 = NULL;\n    void *obj = NULL;\n    int errcnt = 0;\n    OSSL_PARAM *p;\n    if (!TEST_ptr(obj = init_object())\n        || !TEST_true(BN_hex2bn(&verify_p3, p3_init))) {\n        errcnt++;\n        goto fin;\n    }\n    init_app_variables();\n    if (!TEST_true(prov->get_params(obj, params))\n        || !TEST_int_eq(app_p1, p1_init)\n        || !TEST_double_eq(app_p2, app_p2_init)\n        || !TEST_ptr(p = OSSL_PARAM_locate(params, "p3"))\n        || !TEST_ptr(BN_native2bn(bignumbin, p->return_size, app_p3))\n        || !TEST_BN_eq(app_p3, verify_p3)\n        || !TEST_str_eq(app_p4, p4_init)\n        || !TEST_ptr(p = OSSL_PARAM_locate(params, "p5"))\n        || !TEST_size_t_eq(p->return_size, sizeof(p5_init))\n        || !TEST_str_eq(app_p5, p5_init)\n        || !TEST_ptr(p = OSSL_PARAM_locate(params, "p6"))\n        || !TEST_size_t_eq(p->return_size, sizeof(p6_init))\n        || !TEST_str_eq(app_p6, p6_init)\n        || !TEST_char_eq(foo[0], app_foo_init)\n        || !TEST_ptr(p = OSSL_PARAM_locate(params, "foo"))\n        || !TEST_int_eq(p->return_size, 0))\n        errcnt++;\n    init_app_variables();\n    if (!TEST_true(prov->set_params(obj, params))) {\n        errcnt++;\n    } else {\n        struct object_st *sneakpeek = obj;\n        if (!TEST_int_eq(sneakpeek->p1, app_p1)\n            || !TEST_double_eq(sneakpeek->p2, p2_init)\n            || !TEST_BN_eq(sneakpeek->p3, app_p3)\n            || !TEST_str_eq(sneakpeek->p4, app_p4)\n            || !TEST_str_eq(sneakpeek->p5, app_p5)\n            || !TEST_str_eq(sneakpeek->p6, app_p6))\n            errcnt++;\n    }\n    BN_free(verify_p3);\n    verify_p3 = NULL;\n    if (!TEST_true(BN_hex2bn(&verify_p3, app_p3_init))) {\n        errcnt++;\n        goto fin;\n    }\n    if (!TEST_true(prov->get_params(obj, params))\n        || !TEST_int_eq(app_p1, app_p1_init)\n        || !TEST_double_eq(app_p2, app_p2_init)\n        || !TEST_ptr(p = OSSL_PARAM_locate(params, "p3"))\n        || !TEST_ptr(BN_native2bn(bignumbin, p->return_size, app_p3))\n        || !TEST_BN_eq(app_p3, verify_p3)\n        || !TEST_str_eq(app_p4, app_p4_init)\n        || !TEST_ptr(p = OSSL_PARAM_locate(params, "p5"))\n        || !TEST_size_t_eq(p->return_size,\n                           sizeof(app_p5_init))\n        || !TEST_str_eq(app_p5, app_p5_init)\n        || !TEST_ptr(p = OSSL_PARAM_locate(params, "p6"))\n        || !TEST_size_t_eq(p->return_size,\n                           sizeof(app_p6_init))\n        || !TEST_str_eq(app_p6, app_p6_init)\n        || !TEST_char_eq(foo[0], app_foo_init)\n        || !TEST_ptr(p = OSSL_PARAM_locate(params, "foo"))\n        || !TEST_int_eq(p->return_size, 0))\n        errcnt++;\n fin:\n    BN_free(verify_p3);\n    verify_p3 = NULL;\n    cleanup_app_variables();\n    cleanup_object(obj);\n    return errcnt == 0;\n}', 'BIGNUM *BN_native2bn(const unsigned char *s, int len, BIGNUM *ret)\n{\n#ifdef B_ENDIAN\n    return BN_bin2bn(s, len, ret);\n#else\n    return BN_lebin2bn(s, len, ret);\n#endif\n}', 'BIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret)\n{\n    unsigned int i, m;\n    unsigned int n;\n    BN_ULONG l;\n    BIGNUM *bn = NULL;\n    if (ret == NULL)\n        ret = bn = BN_new();\n    if (ret == NULL)\n        return NULL;\n    bn_check_top(ret);\n    s += len;\n    for ( ; len > 0 && s[-1] == 0; s--, len--)\n        continue;\n    n = len;\n    if (n == 0) {\n        ret->top = 0;\n        return ret;\n    }\n    i = ((n - 1) / BN_BYTES) + 1;\n    m = ((n - 1) % (BN_BYTES));\n    if (bn_wexpand(ret, (int)i) == NULL) {\n        BN_free(bn);\n        return NULL;\n    }\n    ret->top = i;\n    ret->neg = 0;\n    l = 0;\n    while (n--) {\n        s--;\n        l = (l << 8L) | *s;\n        if (m-- == 0) {\n            ret->d[--i] = l;\n            l = 0;\n            m = BN_BYTES - 1;\n        }\n    }\n    bn_correct_top(ret);\n    return ret;\n}', 'BIGNUM *bn_wexpand(BIGNUM *a, int words)\n{\n    return (words <= a->dmax) ? a : bn_expand2(a, words);\n}', 'BIGNUM *bn_expand2(BIGNUM *b, int words)\n{\n    if (words > b->dmax) {\n        BN_ULONG *a = bn_expand_internal(b, words);\n        if (!a)\n            return NULL;\n        if (b->d) {\n            OPENSSL_cleanse(b->d, b->dmax * sizeof(b->d[0]));\n            bn_free_d(b);\n        }\n        b->d = a;\n        b->dmax = words;\n    }\n    return b;\n}', 'static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)\n{\n    BN_ULONG *a = NULL;\n    if (words > (INT_MAX / (4 * BN_BITS2))) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_BIGNUM_TOO_LONG);\n        return NULL;\n    }\n    if (BN_get_flags(b, BN_FLG_STATIC_DATA)) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);\n        return NULL;\n    }\n    if (BN_get_flags(b, BN_FLG_SECURE))\n        a = OPENSSL_secure_zalloc(words * sizeof(*a));\n    else\n        a = OPENSSL_zalloc(words * sizeof(*a));\n    if (a == NULL) {\n        BNerr(BN_F_BN_EXPAND_INTERNAL, ERR_R_MALLOC_FAILURE);\n        return NULL;\n    }\n    assert(b->top <= words);\n    if (b->top > 0)\n        memcpy(a, b->d, sizeof(*a) * b->top);\n    return a;\n}']