]> git.cryptolib.org Git - avr-crypto-lib.git/blobdiff - md5.c
forgotten files
[avr-crypto-lib.git] / md5.c
diff --git a/md5.c b/md5.c
index 1ecf02aa9e3a8d6046a464cca94038a4371bcfc4..003699e5ef4ae65486bece16d9cdfbe21a4cca2b 100644 (file)
--- a/md5.c
+++ b/md5.c
@@ -1,6 +1,6 @@
 /* md5.c */
 /*
-    This file is part of the This file is part of the AVR-Crypto-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
@@ -27,7 +27,7 @@
 
  #include "md5.h"
  #include "md5_sbox.h"
- #include "uart.h" 
+ #include "cli.h" 
  #include <stdint.h>
  #include <string.h>
  
@@ -73,14 +73,15 @@ void md5_core(uint32_t* a, void* block, uint8_t as, uint8_t s, uint8_t i, uint8_
        /* a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
 #ifdef DEBUG
        char funcc[]={'*', '-', '+', '~'};
-       uart_putstr("\r\n DBG: md5_core [");
-       uart_putc(funcc[fi]);
-       uart_hexdump(&as, 1); uart_putc(' ');
-       uart_hexdump(&k, 1); uart_putc(' ');
-       uart_hexdump(&s, 1); uart_putc(' ');
-       uart_hexdump(&i, 1); uart_putc(']');
+       cli_putstr("\r\n DBG: md5_core [");
+       cli_putc(funcc[fi]);
+       cli_hexdump(&as, 1); cli_putc(' ');
+       cli_hexdump(&k, 1); cli_putc(' ');
+       cli_hexdump(&s, 1); cli_putc(' ');
+       cli_hexdump(&i, 1); cli_putc(']');
 #endif 
-       t = a[as] + funcs[fi](a[(as+1)&3], a[(as+2)&3], a[(as+3)&3]) + *((uint32_t*)block) + md5_T[i] ;
+       t = a[as] + funcs[fi](a[(as+1)&3], a[(as+2)&3], a[(as+3)&3]) 
+           + *((uint32_t*)block) + pgm_read_dword(md5_T+i) ;
        a[as]=a[(as+1)&3] + ROTL32(t, s);
 }
 
@@ -89,11 +90,11 @@ void md5_nextBlock(md5_ctx_t *state, const void* block){
        uint8_t         m,n,i=0;
        /* this requires other mixed sboxes */
 #ifdef DEBUG
-       uart_putstr("\r\n DBG: md5_nextBlock: block:\r\n");
-       uart_hexdump(block, 16);        uart_putstr("\r\n");
-       uart_hexdump(block+16, 16);     uart_putstr("\r\n");
-       uart_hexdump(block+32, 16);     uart_putstr("\r\n");
-       uart_hexdump(block+48, 16);     uart_putstr("\r\n");
+       cli_putstr("\r\n DBG: md5_nextBlock: block:\r\n");
+       cli_hexdump(block, 16); cli_putstr("\r\n");
+       cli_hexdump(block+16, 16);      cli_putstr("\r\n");
+       cli_hexdump(block+32, 16);      cli_putstr("\r\n");
+       cli_hexdump(block+48, 16);      cli_putstr("\r\n");
 #endif 
        
        a[0]=state->a[0];