]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - lib_generic/sha1.c
Make getenv_IPaddr() global
[karo-tx-uboot.git] / lib_generic / sha1.c
index 08ffa6b9bacb43382535b664e08334c0c84ae005..da5bc16f3c65def17421c4042431ad500aa5111c 100644 (file)
 #define _CRT_SECURE_NO_DEPRECATE 1
 #endif
 
+#ifndef USE_HOSTCC
+#include <common.h>
 #include <linux/string.h>
+#else
+#include <string.h>
+#endif /* USE_HOSTCC */
+#include <watchdog.h>
 #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 )
  */