X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=inline;f=lib_generic%2Fsha1.c;h=da5bc16f3c65def17421c4042431ad500aa5111c;hb=fa60edfc4c952626e048c0e065f654b3c1822fa5;hp=08ffa6b9bacb43382535b664e08334c0c84ae005;hpb=78549bbf44bd2c8d1a0730fb068836071751afaa;p=u-boot diff --git a/lib_generic/sha1.c b/lib_generic/sha1.c index 08ffa6b9ba..da5bc16f3c 100644 --- a/lib_generic/sha1.c +++ b/lib_generic/sha1.c @@ -29,7 +29,13 @@ #define _CRT_SECURE_NO_DEPRECATE 1 #endif +#ifndef USE_HOSTCC +#include #include +#else +#include +#endif /* USE_HOSTCC */ +#include #include "sha1.h" /* @@ -308,6 +314,39 @@ void sha1_csum (unsigned char *input, int ilen, unsigned char output[20]) sha1_finish (&ctx, output); } +/* + * Output = SHA-1( input buffer ). Trigger the watchdog every 'chunk_sz' + * bytes of input processed. + */ +void sha1_csum_wd (unsigned char *input, int ilen, unsigned char output[20], + unsigned int chunk_sz) +{ + sha1_context ctx; +#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG) + unsigned char *end, *curr; + int chunk; +#endif + + sha1_starts (&ctx); + +#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG) + curr = input; + end = input + ilen; + while (curr < end) { + chunk = end - curr; + if (chunk > chunk_sz) + chunk = chunk_sz; + sha1_update (&ctx, curr, chunk); + curr += chunk; + WATCHDOG_RESET (); + } +#else + sha1_update (&ctx, input, ilen); +#endif + + sha1_finish (&ctx, output); +} + /* * Output = HMAC-SHA-1( input buffer, hmac key ) */