]> git.sur5r.net Git - u-boot/blobdiff - lib/sha1.c
imx_lpi2c: Update lpi2c driver to support imx8
[u-boot] / lib / sha1.c
index da5bc16f3c65def17421c4042431ad500aa5111c..8154e1e1350026c07271e08d6ef2864cc29e0fd6 100644 (file)
@@ -1,23 +1,10 @@
+// SPDX-License-Identifier: LGPL-2.1
 /*
  *  Heiko Schocher, DENX Software Engineering, hs@denx.de.
  *  based on:
  *  FIPS-180-1 compliant SHA-1 implementation
  *
  *  Copyright (C) 2003-2006  Christophe Devine
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License, version 2.1 as published by the Free Software Foundation.
- *
- *  This library 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
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- *  MA  02110-1301  USA
  */
 /*
  *  The SHA-1 standard was published by NIST in 1993.
 #include <string.h>
 #endif /* USE_HOSTCC */
 #include <watchdog.h>
-#include "sha1.h"
+#include <u-boot/sha1.h>
+
+const uint8_t sha1_der_prefix[SHA1_DER_LEN] = {
+       0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e,
+       0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14
+};
 
 /*
  * 32-bit integer manipulation macros (big endian)
@@ -73,7 +65,7 @@ void sha1_starts (sha1_context * ctx)
        ctx->state[4] = 0xC3D2E1F0;
 }
 
-static void sha1_process (sha1_context * ctx, unsigned char data[64])
+static void sha1_process(sha1_context *ctx, const unsigned char data[64])
 {
        unsigned long temp, W[16], A, B, C, D, E;
 
@@ -230,7 +222,8 @@ static void sha1_process (sha1_context * ctx, unsigned char data[64])
 /*
  * SHA-1 process buffer
  */
-void sha1_update (sha1_context * ctx, unsigned char *input, int ilen)
+void sha1_update(sha1_context *ctx, const unsigned char *input,
+                unsigned int ilen)
 {
        int fill;
        unsigned long left;
@@ -305,7 +298,8 @@ void sha1_finish (sha1_context * ctx, unsigned char output[20])
 /*
  * Output = SHA-1( input buffer )
  */
-void sha1_csum (unsigned char *input, int ilen, unsigned char output[20])
+void sha1_csum(const unsigned char *input, unsigned int ilen,
+              unsigned char *output)
 {
        sha1_context ctx;
 
@@ -318,12 +312,12 @@ void sha1_csum (unsigned char *input, int ilen, unsigned char output[20])
  * 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)
+void sha1_csum_wd(const unsigned char *input, unsigned int ilen,
+                 unsigned char *output, unsigned int chunk_sz)
 {
        sha1_context ctx;
 #if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-       unsigned char *end, *curr;
+       const unsigned char *end, *curr;
        int chunk;
 #endif
 
@@ -350,8 +344,9 @@ void sha1_csum_wd (unsigned char *input, int ilen, unsigned char output[20],
 /*
  * Output = HMAC-SHA-1( input buffer, hmac key )
  */
-void sha1_hmac (unsigned char *key, int keylen,
-               unsigned char *input, int ilen, unsigned char output[20])
+void sha1_hmac(const unsigned char *key, int keylen,
+              const unsigned char *input, unsigned int ilen,
+              unsigned char *output)
 {
        int i;
        sha1_context ctx;
@@ -386,8 +381,6 @@ void sha1_hmac (unsigned char *key, int keylen,
        memset (&ctx, 0, sizeof (sha1_context));
 }
 
-static const char _sha1_src[] = "_sha1_src";
-
 #ifdef SELF_TEST
 /*
  * FIPS-180-1 test vectors