static int test_sub()
{
    BIGNUM *a, *b, *c;
    int i;

    a = BN_new();
    b = BN_new();
    c = BN_new();

    for (i = 0; i < NUM0 + NUM1; i++) {
        if (i < NUM1) {
            BN_bntest_rand(a, 512, 0, 0);
            BN_copy(b, a);
            if (BN_set_bit(a, i) == 0)
                return 0;
            BN_add_word(b, i);
        } else {
            BN_bntest_rand(b, 400 + i - NUM1, 0, 0);
            a->neg = rand_neg();
            b->neg = rand_neg();
        }
        BN_sub(c, a, b);
        BN_add(c, c, b);
        BN_sub(c, c, a);
        if (!BN_is_zero(c)) {
            printf("Subtract test failed!\n");
            return 0;
        }
    }
    BN_free(a);
    BN_free(b);
    BN_free(c);
    return 1;
}