-
- uint8_t diggest[pgm_read_word(shavs_algo->hashsize_b)/8];
- if(length && length%(buffersize_B*8)==0)
- hfal_hash_nextBlock(&ctx, buffer);
- hfal_hash_lastBlock(&ctx, buffer, length%(buffersize_B*8));
- hfal_hash_ctx2hash(diggest, &ctx);
- hfal_hash_free(&ctx);
+#if DEBUG
+ cli_putstr_P(PSTR("\r\n starting finalisation"));
+ cli_putstr_P(PSTR("\r\n\tblocks == "));
+ cli_hexdump_rev(&(shavs_ctx.blocks),4);
+ cli_putstr_P(PSTR("\r\n\tbuffer_idx == "));
+ cli_hexdump_rev(&(shavs_ctx.buffer_idx),2);
+ cli_putstr_P(PSTR("\r\n\tin_byte == "));
+ cli_hexdump_rev(&(shavs_ctx.in_byte),1);
+ _delay_ms(500);
+
+ cli_putstr_P(PSTR("\r\n starting last block"));
+ cli_putstr_P(PSTR("\r\n\tlength == "));
+ cli_hexdump_rev(&length,4);
+ cli_putstr_P(PSTR("\r\n\tbuffersize_B == "));
+ cli_hexdump_rev(&(shavs_ctx.buffersize_B),2);
+ uint16_t temp=length-(shavs_ctx.blocks)*((shavs_ctx.buffersize_B)*8);
+ cli_putstr_P(PSTR("\r\n\t (temp) == "));
+ cli_hexdump_rev(&temp,2);
+ _delay_ms(500);
+#endif
+#if !DEBUG
+ uint16_t temp=length-(shavs_ctx.blocks)*((shavs_ctx.buffersize_B)*8);
+// cli_putstr_P(PSTR("\r\n\t (temp) == "));
+ cli_hexdump_rev(&temp,2);
+#endif
+ hfal_hash_lastBlock( &(shavs_ctx.ctx), buffer, /* be aware of freaking compilers!!! */
+// length-(shavs_ctx.blocks)*((shavs_ctx.buffersize_B)*8));
+ temp );
+#if DEBUG
+ cli_putstr_P(PSTR("\r\n starting ctx2hash"));
+ _delay_ms(500);
+#endif
+ hfal_hash_ctx2hash(diggest, &(shavs_ctx.ctx));
+#if DEBUG
+ cli_putstr_P(PSTR("\r\n starting hash free"));
+#endif
+ hfal_hash_free(&(shavs_ctx.ctx));