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_crt_components(void)\n{\n    const int P = 15;\n    const int Q = 17;\n    const int E = 5;\n    const int N = P*Q;\n    const int DP = 3;\n    const int DQ = 13;\n    const int QINV = 8;\n    int ret = 0;\n    RSA *key = NULL;\n    BN_CTX *ctx = NULL;\n    BIGNUM *p = NULL, *q = NULL, *e = NULL;\n    ret = TEST_ptr(key = RSA_new())\n          && TEST_ptr(ctx = BN_CTX_new())\n          && TEST_ptr(p = BN_new())\n          && TEST_ptr(q = BN_new())\n          && TEST_ptr(e = BN_new())\n          && TEST_true(BN_set_word(p, P))\n          && TEST_true(BN_set_word(q, Q))\n          && TEST_true(BN_set_word(e, E))\n          && TEST_true(RSA_set0_factors(key, p, q));\n    if (!ret) {\n        BN_free(p);\n        BN_free(q);\n        goto end;\n    }\n    ret = TEST_true(rsa_sp800_56b_derive_params_from_pq(key, 8, e, ctx))\n          && TEST_BN_eq_word(key->n, N)\n          && TEST_BN_eq_word(key->dmp1, DP)\n          && TEST_BN_eq_word(key->dmq1, DQ)\n          && TEST_BN_eq_word(key->iqmp, QINV)\n          && TEST_true(rsa_check_crt_components(key, ctx))\n          && TEST_true(BN_set_word(key->dmp1, 1))\n          && TEST_false(rsa_check_crt_components(key, ctx))\n          && TEST_true(BN_set_word(key->dmp1, P-1))\n          && TEST_false(rsa_check_crt_components(key, ctx))\n          && TEST_true(BN_set_word(key->dmp1, DP))\n          && TEST_true(BN_set_word(key->dmq1, 1))\n          && TEST_false(rsa_check_crt_components(key, ctx))\n          && TEST_true(BN_set_word(key->dmq1, Q-1))\n          && TEST_false(rsa_check_crt_components(key, ctx))\n          && TEST_true(BN_set_word(key->dmq1, DQ))\n          && TEST_true(BN_set_word(key->iqmp, 1))\n          && TEST_false(rsa_check_crt_components(key, ctx))\n          && TEST_true(BN_set_word(key->iqmp, P))\n          && TEST_false(rsa_check_crt_components(key, ctx))\n          && TEST_true(BN_set_word(key->iqmp, QINV))\n          && TEST_true(BN_set_word(key->dmp1, DP+1))\n          && TEST_false(rsa_check_crt_components(key, ctx))\n          && TEST_true(BN_set_word(key->dmp1, DP))\n          && TEST_true(BN_set_word(key->dmq1, DQ-1))\n          && TEST_false(rsa_check_crt_components(key, ctx))\n          && TEST_true(BN_set_word(key->dmq1, DQ))\n          && TEST_true(BN_set_word(key->iqmp, QINV+1))\n          && TEST_false(rsa_check_crt_components(key, ctx))\n          && TEST_true(BN_set_word(key->iqmp, QINV))\n          && TEST_true(rsa_check_crt_components(key, ctx));\nend:\n    BN_free(e);\n    RSA_free(key);\n    BN_CTX_free(ctx);\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}']