static int test_smallprime()
{
    static const int kBits = 10;
    BIGNUM *r = BN_new();
    int st = 0;

    if (r == NULL
            || !BN_generate_prime_ex(r, (int)kBits, 0, NULL, NULL, NULL))
        goto err;
    if (BN_num_bits(r) != kBits) {
        fprintf(stderr, "Expected %u bit prime, got %u bit number\n",
                kBits, BN_num_bits(r));
        goto err;
    }

    st = 1;
err:
    BN_free(r);
    return st;
}