X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=hfal%2Fhfal-test.c;fp=hfal%2Fhfal-test.c;h=9efce38e3e49e370adc2e9958ca8a278063b51cb;hb=924aa320bef6f192feecdb67d209c790bd49ea49;hp=0000000000000000000000000000000000000000;hpb=fb4cf7b5c6e5f28d886bd4216f09b8052c7bd013;p=avr-crypto-lib.git
diff --git a/hfal/hfal-test.c b/hfal/hfal-test.c
new file mode 100644
index 0000000..9efce38
--- /dev/null
+++ b/hfal/hfal-test.c
@@ -0,0 +1,49 @@
+/* hfal-test.c */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see .
+*/
+/*
+ * \file hfal-test.c
+ * \author Daniel Otte
+ * \email daniel.otte@rub.de
+ * \date 2009-05-10
+ * \license GPLv3 or later
+ *
+ */
+
+#include "hfal-basic.h"
+#include "hashfunction_descriptor.h"
+#include "cli.h"
+#include
+#include
+
+void hfal_test(const hfdesc_t* hd, void* msg, uint32_t length_b){
+ if(pgm_read_byte(&(hd->type))!=HFDESC_TYPE_HASHFUNCTION)
+ return;
+ uint16_t dlen = (pgm_read_word(&(hd->hashsize_b))+7)/8;
+ uint8_t digest[dlen];
+ cli_putstr_P(PSTR("\r\n=== "));
+ cli_putstr_P((void*)pgm_read_word(&(hd->name)));
+ cli_putstr_P(PSTR(" ===\r\n message:"));
+ cli_hexdump_block(msg, (length_b+7)/8, 4, 16);
+ hfal_hash_mem(hd, digest, msg, length_b);
+ cli_putstr_P(PSTR(" \r\n digest:"));
+ cli_hexdump_block(digest, dlen, 4, 16);
+ cli_putstr_P(PSTR("\r\n"));
+}
+
+