int BN_set_word(BIGNUM *a, BN_ULONG w)
{
    bn_check_top(a);
    if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)
        return 0;
    a->neg = 0;
    a->d[0] = w;
    a->top = (w ? 1 : 0);
    a->flags &= ~BN_FLG_FIXED_TOP;
    bn_check_top(a);
    return 1;
}
['static int test_check_prime_factor(void)\n{\n    int ret = 0;\n    BN_CTX *ctx = NULL;\n    BIGNUM *p = NULL, *e = NULL;\n    BIGNUM *bn_p1 = NULL, *bn_p2 = NULL, *bn_p3 = NULL;\n    static const unsigned char p1[] = { 0x0B, 0x50, 0x4f, 0x33, 0x73 };\n    static const unsigned char p2[] = { 0x0B, 0x50, 0x4f, 0x33, 0x75 };\n    static const unsigned char p3[] = { 0x0F, 0x50, 0x00, 0x03, 0x75 };\n    ret = TEST_ptr(p = BN_new())\n          && TEST_ptr(bn_p1 = bn_load_new(p1, sizeof(p1)))\n          && TEST_ptr(bn_p2 = bn_load_new(p2, sizeof(p2)))\n          && TEST_ptr(bn_p3 = bn_load_new(p3, sizeof(p3)))\n          && TEST_ptr(e = BN_new())\n          && TEST_ptr(ctx = BN_CTX_new())\n          && TEST_true(BN_set_word(e, 0x1))\n          && TEST_false(rsa_check_prime_factor(bn_p1, e, 72, ctx))\n          && TEST_true(rsa_check_prime_factor(bn_p2, e, 72, ctx))\n          && TEST_true(BN_set_word(e, 0x2))\n          && TEST_false(rsa_check_prime_factor(p, e, 72, ctx))\n          && TEST_true(BN_set_word(e, 0x1))\n          && TEST_false(rsa_check_prime_factor(bn_p3, e, 72, ctx));\n    BN_free(bn_p3);\n    BN_free(bn_p2);\n    BN_free(bn_p1);\n    BN_free(e);\n    BN_free(p);\n    BN_CTX_free(ctx);\n    return ret;\n}', 'static BIGNUM *bn_load_new(const unsigned char *data, int sz)\n{\n    BIGNUM *ret = BN_new();\n    if (ret != NULL)\n        BN_bin2bn(data, sz, ret);\n    return ret;\n}', 'BIGNUM *BN_bin2bn(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    for ( ; len > 0 && *s == 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        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}', 'int BN_set_word(BIGNUM *a, BN_ULONG w)\n{\n    bn_check_top(a);\n    if (bn_expand(a, (int)sizeof(BN_ULONG) * 8) == NULL)\n        return 0;\n    a->neg = 0;\n    a->d[0] = w;\n    a->top = (w ? 1 : 0);\n    a->flags &= ~BN_FLG_FIXED_TOP;\n    bn_check_top(a);\n    return 1;\n}', 'static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits)\n{\n    if (bits > (INT_MAX - BN_BITS2 + 1))\n        return NULL;\n    if (((bits+BN_BITS2-1)/BN_BITS2) <= (a)->dmax)\n        return a;\n    return bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2);\n}']