X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=hfal%2Fhfal-test.c;fp=hfal%2Fhfal-test.c;h=f78375d9b497dfc179c2228ebcc09043e9b8e915;hb=d70d1d77bab1a5f5278227d674bc59da0378fe15;hp=0000000000000000000000000000000000000000;hpb=d00ed9a275c69fa3512007452e479abd98dbe745;p=arm-crypto-lib.git diff --git a/hfal/hfal-test.c b/hfal/hfal-test.c new file mode 100644 index 0000000..f78375d --- /dev/null +++ b/hfal/hfal-test.c @@ -0,0 +1,48 @@ +/* hfal-test.c */ +/* + This file is part of the ARM-Crypto-Lib. + Copyright (C) 2006-2010 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 + +void hfal_test(const hfdesc_t* hd, const void* msg, uint32_t length_b){ + if(hd->type!=HFDESC_TYPE_HASHFUNCTION) + return; + uint16_t dlen = (hd->hashsize_b+7)/8; + uint8_t digest[dlen]; + cli_putstr("\r\n=== "); + cli_putstr(hd->name); + cli_putstr(" ===\r\n message:"); + cli_hexdump_block(msg, (length_b+7)/8, 4, 16); + hfal_hash_mem(hd, digest, msg, length_b); + cli_putstr(" \r\n digest:"); + cli_hexdump_block(digest, dlen, 4, 16); + cli_putstr("\r\n"); +} + +