3 This file is part of the AVR-Crypto-Lib.
4 Copyright (C) 2010 Daniel Otte (daniel.otte@rub.de)
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 void bigint_print_hex(const bigint_t* a){
26 if(a->info&BIGINT_NEG_MASK){
29 // cli_putc((a->info&BIGINT_NEG_MASK)?'-':'+'); /* print sign */
31 cli_hexdump_rev(a->wordv, a->length_B);
39 static uint8_t char2nibble(char c){
40 if(c>='0' && c <='9'){
43 c |= 'A'^'a'; /* to lower case */
44 if(c>='a' && c <='f'){
50 static uint16_t read_byte(void){
69 uint8_t bigint_read_hex_echo(bigint_t* a){
77 if(allocated-a->length_B < 1){
79 p = realloc(a->wordv, allocated+=BLOCKSIZE);
81 cli_putstr_P(PSTR("\r\nERROR: Out of memory!"));
91 a->info |= BIGINT_NEG_MASK;
102 a->wordv[a->length_B++] = (uint8_t)t;
106 a->wordv[a->length_B++] = (uint8_t)((t&0x0f)<<4);
111 /* we have to reverse the byte array */
115 q = a->wordv+a->length_B-1;
124 bigint_shiftright(a, 4);