/* 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
#include "md5.h"
#include "md5_sbox.h"
- #include "uart.h"
+ #include "cli.h"
#include <stdint.h>
#include <string.h>
/* 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);
}
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];