]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - bigint/bigint_io.c
going to remove debug stuff ...
[avr-crypto-lib.git] / bigint / bigint_io.c
index 1a2b12c27bf8feb5ebdf0f47437c8372b1afae94..221c61c0e3ffe7a810d27aea6e9fae077f7ad758 100644 (file)
 */
 
 #include "cli.h"
+#include "hexdigit_tab.h"
 #include "bigint.h"
+#include <avr/pgmspace.h>
 #include <stdlib.h>
 #include <string.h>
 
 void bigint_print_hex(const bigint_t* a){
+       if(a->length_B==0){
+               cli_putc('0');
+               return;
+       }
        if(a->info&BIGINT_NEG_MASK){
                cli_putc('-');
        }
 //     cli_putc((a->info&BIGINT_NEG_MASK)?'-':'+'); /* print sign */
-       if(a->length_B!=0){
+       if(a->wordv[a->length_B-1]<0x10){
+               cli_putc(pgm_read_byte(hexdigit_tab_uc_P+a->wordv[a->length_B-1]));
+               cli_hexdump_rev(a->wordv, a->length_B-1);
+       } else {
                cli_hexdump_rev(a->wordv, a->length_B);
-       }else{
-               cli_putc('0');
        }
 }