diff options
Diffstat (limited to 'test/bntest.c')
-rw-r--r-- | test/bntest.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/test/bntest.c b/test/bntest.c index 6b62c05050..d315ad8432 100644 --- a/test/bntest.c +++ b/test/bntest.c @@ -502,18 +502,25 @@ int test_div(BIO *bp, BN_CTX *ctx) static void print_word(BIO *bp, BN_ULONG w) { -#ifdef SIXTY_FOUR_BIT - if (sizeof(w) > sizeof(unsigned long)) { - unsigned long h = (unsigned long)(w >> 32), l = (unsigned long)(w); - - if (h) - BIO_printf(bp, "%lX%08lX", h, l); + int i = sizeof(w) * 8; + char *fmt = NULL; + unsigned char byte; + + do { + i -= 8; + byte = (unsigned char)(w >> i); + if (fmt == NULL) + fmt = byte ? "%X" : NULL; else - BIO_printf(bp, "%lX", l); - return; - } -#endif - BIO_printf(bp, BN_HEX_FMT1, w); + fmt = "%02X"; + + if (fmt != NULL) + BIO_printf(bp, fmt, byte); + } while (i); + + /* If we haven't printed anything, at least print a zero! */ + if (fmt == NULL) + BIO_printf(bp, "0"); } int test_div_word(BIO *bp) |