Ton Hospel wrote:
Using openssl 0.9.8 on linux, with the following test program:

#include <stdio.h>
#include <openssl/bn.h>

int main(void) {
    long w;
    BIGNUM bigint, *big;
    char buf[80], *result;

    big = &bigint;
    BN_init(big);
    for (w=-4; w<=4; w++) {
        sprintf(buf, "%ld", w);
        if (!BN_dec2bn(&big, buf)) return 1;
        if (!BN_sub_word(big, 1)) return 1;
        result = BN_bn2dec(big);
        if (!result) return 1;
        printf("%ld - 1 = %s\n", w, result);
    }
    BN_free(big);
    return 0;
}

Results in:

-4 - 1 = -5
-3 - 1 = -4
-2 - 1 = -3
-1 - 1 = -2
0 - 1 = 1
1 - 1 = 0
2 - 1 = 1
3 - 1 = 2
4 - 1 = 3

Notice how the result for 0 - 1 is wrong

please try a recent snapshot, this bug should already be fixed.

Thanks,
Nils
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to