X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=test_src%2Fnessie_mac_test.c;h=90e33de553d9ffcb14e3c2c551ee7d2485ef3f39;hb=e5a49deb52521f019e37779d6e9d81ec4f02aba4;hp=12863dfdf0ce95cb90f5365cdf44f43fcb53d75e;hpb=2159c273c9d3361571a6ff1ab63d9bc76582fbab;p=avr-crypto-lib.git diff --git a/test_src/nessie_mac_test.c b/test_src/nessie_mac_test.c index 12863df..90e33de 100644 --- a/test_src/nessie_mac_test.c +++ b/test_src/nessie_mac_test.c @@ -1,6 +1,6 @@ /* nessie_mac_test.c */ /* - This file is part of the Crypto-avr-lib/microcrypt-lib. + This file is part of the AVR-Crypto-Lib. Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) This program is free software: you can redistribute it and/or modify @@ -45,12 +45,12 @@ void ascii_mac(char* data, char* desc, uint8_t* key){ uint8_t mac[MACSIZE_B]; uint16_t sl; - uart_putstr_P(PSTR("\r\n message=")); - uart_putstr(desc); + NESSIE_PUTSTR_P(PSTR("\r\n message=")); + NESSIE_PUTSTR(desc); PRINTKEY; nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx); sl = strlen(data); - while(sl>=nessie_mac_ctx.blocksize_B){ + while(sl>nessie_mac_ctx.blocksize_B){ nessie_mac_ctx.mac_next(data, ctx); data += nessie_mac_ctx.blocksize_B; sl -= nessie_mac_ctx.blocksize_B; @@ -68,16 +68,18 @@ void amillion_mac(uint8_t* key){ uint8_t mac[MACSIZE_B]; uint8_t block[nessie_mac_ctx.blocksize_B]; uint32_t n=1000000LL; + uint16_t i=0; - uart_putstr_P(PSTR("\r\n message=")); - uart_putstr_P(PSTR("1 million times \"a\"")); + NESSIE_PUTSTR_P(PSTR("\r\n message=")); + NESSIE_PUTSTR_P(PSTR("1 million times \"a\"")); PRINTKEY; memset(block, 'a', nessie_mac_ctx.blocksize_B); nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx); - while(n>=nessie_mac_ctx.blocksize_B){ + while(n>nessie_mac_ctx.blocksize_B){ nessie_mac_ctx.mac_next(block, ctx); n -= nessie_mac_ctx.blocksize_B; + NESSIE_SEND_ALIVE_A(i++); } nessie_mac_ctx.mac_last(block, n*8, key, nessie_mac_ctx.keysize_b, ctx); nessie_mac_ctx.mac_conv(mac, ctx); @@ -91,22 +93,22 @@ void zero_mac(uint16_t n, uint8_t* key){ uint8_t mac[MACSIZE_B]; uint8_t block[nessie_mac_ctx.blocksize_B]; - uart_putstr_P(PSTR("\r\n message=")); + NESSIE_PUTSTR_P(PSTR("\r\n message=")); if(n>=10000) - uart_putc('0'+n/10000); + NESSIE_PUTC('0'+n/10000); if(n>=1000) - uart_putc('0'+(n/1000)%10); + NESSIE_PUTC('0'+(n/1000)%10); if(n>=100) - uart_putc('0'+(n/100)%10); + NESSIE_PUTC('0'+(n/100)%10); if(n>=10) - uart_putc('0'+(n/10)%10); - uart_putc('0'+n%10); - uart_putstr_P(PSTR(" zero bits")); + NESSIE_PUTC('0'+(n/10)%10); + NESSIE_PUTC('0'+n%10); + NESSIE_PUTSTR_P(PSTR(" zero bits")); PRINTKEY; memset(block, 0, nessie_mac_ctx.blocksize_B); nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b,ctx);; - while(n>=nessie_mac_ctx.blocksize_B*8){ + while(n>nessie_mac_ctx.blocksize_B*8){ nessie_mac_ctx.mac_next(block, ctx); n -= nessie_mac_ctx.blocksize_B*8; } @@ -125,35 +127,38 @@ void one_in512_mac(uint16_t pos, uint8_t* key){ "08", "04", "02", "01" }; pos&=511; - uart_putstr_P(PSTR("\r\n message=")); - uart_putstr_P(PSTR("512-bit string: ")); + NESSIE_PUTSTR_P(PSTR("\r\n message=")); + NESSIE_PUTSTR_P(PSTR("512-bit string: ")); if((pos/8) >=10){ - uart_putc('0'+(pos/8/10)%10); + NESSIE_PUTC('0'+(pos/8/10)%10); } else { - uart_putc(' '); + NESSIE_PUTC(' '); } - uart_putc('0'+(pos/8)%10); - uart_putstr_P(PSTR("*00,")); - uart_putstr(tab[pos&7]); - uart_putc(','); + NESSIE_PUTC('0'+(pos/8)%10); + NESSIE_PUTSTR_P(PSTR("*00,")); + NESSIE_PUTSTR(tab[pos&7]); + NESSIE_PUTC(','); if(63-(pos/8) >=10){ - uart_putc('0'+((63-pos/8)/10)%10); + NESSIE_PUTC('0'+((63-pos/8)/10)%10); } else { - uart_putc(' '); + NESSIE_PUTC(' '); } - uart_putc('0'+(63-pos/8)%10); - uart_putstr_P(PSTR("*00")); + NESSIE_PUTC('0'+(63-pos/8)%10); + NESSIE_PUTSTR_P(PSTR("*00")); PRINTKEY; /* now the real stuff */ memset(block, 0, 512/8); block[pos>>3] = 0x80>>(pos&0x7); - nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);; - while(n>=nessie_mac_ctx.blocksize_B*8){ - nessie_mac_ctx.mac_next(block, ctx); + uint8_t* bp; + bp = block; + nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx); + while(n>nessie_mac_ctx.blocksize_B*8){ + nessie_mac_ctx.mac_next(bp, ctx); n -= nessie_mac_ctx.blocksize_B*8; + bp += nessie_mac_ctx.blocksize_B; } - nessie_mac_ctx.mac_last(block, n, key, nessie_mac_ctx.keysize_b, ctx); + nessie_mac_ctx.mac_last(bp, n, key, nessie_mac_ctx.keysize_b, ctx); nessie_mac_ctx.mac_conv(mac, ctx); PRINTMAC; } @@ -166,12 +171,12 @@ void tv4_mac(uint8_t* key){ uint16_t n=256; uint32_t i; - uart_putstr_P(PSTR("\r\n message=")); - uart_putstr(PSTR("256 zero bits")); + NESSIE_PUTSTR_P(PSTR("\r\n message=")); + NESSIE_PUTSTR(PSTR("256 zero bits")); memset(block, 0, 256/8); nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);; - while(n>=nessie_mac_ctx.blocksize_B*8){ + while(n>nessie_mac_ctx.blocksize_B*8){ nessie_mac_ctx.mac_next(block, ctx); n -= nessie_mac_ctx.blocksize_B*8; } @@ -182,6 +187,7 @@ void tv4_mac(uint8_t* key){ nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);; nessie_mac_ctx.mac_last(mac, nessie_mac_ctx.macsize_b, key, nessie_mac_ctx.keysize_b, ctx); nessie_mac_ctx.mac_conv(mac, ctx); + NESSIE_SEND_ALIVE_A(i); } nessie_print_item("iterated 100000 times", mac, MACSIZE_B); } @@ -215,6 +221,7 @@ void nessie_mac_run(void){ {"Now is the time for all ", "\"Now is the time for all \""}, {"Now is the time for it", "\"Now is the time for it\""} }; + set=1; nessie_print_setheader(set); for(i=0; i