I have an IRIX n32 problem with similar symptoms. IRIX -64 works fine.
I extended Mr. Tucker's changes to bntest.c to also demonstrate the
IRIX problem.

Replace Mr. Tucker's test_bn2dec with:

int test_bn2dec(BIO *bp, BN_CTX *ctx)
        {
        BIGNUM *a;
        char buf[1024], *buf2;
        BN_LONG bnlong;

        a = BN_new();
        for (bnlong = -1000; bnlong < 1000 ; bnlong++) {
                sprintf(buf, "%d", (int) bnlong);
                BN_dec2bn(&a, buf);
                buf2 = BN_bn2dec(a);
                if (strcmp(buf, buf2) != 0) {
                        fprintf(stderr,"bn2dec failed: '%s'
'%s'!\n",buf,buf2);
                        OPENSSL_free(buf2);
                        return 0;
                }
                OPENSSL_free(buf2);
        }
        BN_free(a);
        a = BN_new();
        /* these gyrations attempt to test an particular corner case w/o */
        /* breaking every other architecture */
        for ( bnlong=1; bnlong <= 10000000000000000000ULL; bnlong+=bnlong) {
                sprintf(buf, BN_DEC_FMT1, bnlong);
                BN_dec2bn(&a, buf);
                buf2 = BN_bn2dec(a);
                if (strcmp(buf, buf2) != 0) {
                        fprintf(stderr,"bn2dec failed: '%s'
'%s'!\n",buf,buf2);
                        OPENSSL_free(buf2);
                        return 0;
                }
                OPENSSL_free(buf2);
        }
        BN_free(a);
        return 1;
        }

When compiled -n32 -mips3 and run on an IRIX system which supports it
I get:
> lou.root 175> test/bntest >& out
> out:
> ...
> test BN_bn2dec
> bn2dec failed: '4294967296' '0'!
> print "test BN_bn2dec\n"
> 1
> Naturally I haven't tested this on anything other that IRIX...
> 
> in crypto/bio/b_print.c: fmtint uses LLONG for variable "value".
> LLONG appears to be defined as long rather than long long
> after the following sequence(in b_print.c):
> 
> #include <openssl/bn.h>         /* To get BN_LLONG properly defined */
> ...
> #ifdef BN_LLONG
> # ifndef HAVE_LONG_LONG
> #  define HAVE_LONG_LONG 1
> # endif
> #endif
> 
> #if HAVE_LONG_LONG
> # if defined(OPENSSL_SYS_WIN32) && !defined(__GNUC__)
> # define LLONG _int64
> # else
> # define LLONG long long
> # endif
> #else
> #define LLONG long
> #endif
> 
> 
> for SIXTY_FOUR_BIT, BN_LLONG is explicitly not defined, so LLONG
> gets defined to long by the above.
> 
> bn.h:
> /* This is where the long long data type is 64 bits, but long is 32.
>  * For machines where there are 64bit registers, this is the mode to use.
>  * IRIX, on R4000 and above should use this mode, along with the relevant
>  * assembler code :-).  Do NOT define BN_LLONG.
>  */
> #ifdef SIXTY_FOUR_BIT
> #undef BN_LLONG
> #undef BN_ULLONG
> #define BN_ULONG        unsigned long long
> #define BN_LONG         long long
> 




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

Reply via email to