includes: move openssl headers to include/u-boot
authorJeroen Hofstee <jeroen@myspectrum.nl>
Thu, 12 Jun 2014 20:27:12 +0000 (22:27 +0200)
committerTom Rini <trini@ti.com>
Thu, 19 Jun 2014 15:19:04 +0000 (11:19 -0400)
commit 18b06652cd "tools: include u-boot version of sha256.h"
unconditionally forced the sha256.h from u-boot to be used
for tools instead of the host version. This is fragile though
as it will also include the host version. Therefore move it
to include/u-boot to join u-boot/md5.h etc which were renamed
for the same reason.

cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Jeroen Hofstee <jeroen@myspectrum.nl>
29 files changed:
board/gdsys/p1022/controlcenterd-id.c
board/pcs440ep/pcs440ep.c
common/cmd_sha1sum.c
common/hash.c
common/image-fit.c
common/image-sig.c
common/image.c
drivers/crypto/ace_sha.c
drivers/misc/cros_ec_sandbox.c
drivers/mmc/rpmb.c
include/image.h
include/rsa-checksum.h [deleted file]
include/rsa.h [deleted file]
include/sha1.h [deleted file]
include/sha256.h [deleted file]
include/u-boot/rsa-checksum.h [new file with mode: 0644]
include/u-boot/rsa.h [new file with mode: 0644]
include/u-boot/sha1.h [new file with mode: 0644]
include/u-boot/sha256.h [new file with mode: 0644]
lib/rsa/rsa-checksum.c
lib/rsa/rsa-verify.c
lib/sha1.c
lib/sha256.c
lib/tpm.c
tools/Makefile
tools/dumpimage.h
tools/imagetool.h
tools/mkimage.h
tools/ubsha1.c

index 3fca3c53b2e12d5af12b39af88c9c2c9c0465ec9..7e13c9051cbc815762f930df38678b8bb0770d1a 100644 (file)
@@ -30,7 +30,7 @@
 #include <i2c.h>
 #include <mmc.h>
 #include <tpm.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
 #include <pca9698.h>
index f90e809d158b4b388c54bf696af6ff8b195fbc63..267c0014359eb8d9cfde7e43fd4ade139da2025b 100644 (file)
@@ -13,7 +13,7 @@
 #include <asm/processor.h>
 #include <spd_sdram.h>
 #include <status_led.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 #include <asm/io.h>
 #include <net.h>
 #include <ata.h>
index 644b9a0e668e661b4add6f3eab5c90705edc5f48..783ea2e32db3725909d13e76b843aeb7e5f92bc3 100644 (file)
@@ -11,7 +11,7 @@
 #include <common.h>
 #include <command.h>
 #include <hash.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 
 int do_sha1sum(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
index 3d953784af59e23920f228114fcf27bf4642d278..12d67594abe0c6f912f5dcd80f5b0f4d1c3cd867 100644 (file)
@@ -15,8 +15,8 @@
 #include <malloc.h>
 #include <hw_sha.h>
 #include <hash.h>
-#include <sha1.h>
-#include <sha256.h>
+#include <u-boot/sha1.h>
+#include <u-boot/sha256.h>
 #include <asm/io.h>
 #include <asm/errno.h>
 
index 3311343be6de070ad780f949116bca43268a4cdd..c61be651334a0240cf81607f6624b0d770ef6fb7 100644 (file)
@@ -21,10 +21,10 @@ DECLARE_GLOBAL_DATA_PTR;
 #endif /* !USE_HOSTCC*/
 
 #include <bootstage.h>
-#include <sha1.h>
-#include <sha256.h>
 #include <u-boot/crc.h>
 #include <u-boot/md5.h>
+#include <u-boot/sha1.h>
+#include <u-boot/sha256.h>
 
 /*****************************************************************************/
 /* New uImage format routines */
index 48788f9100023bc4a41ce345c8d04cfbde45e816..8601edaca35f41d0c996e15fb7f447179a8255b3 100644 (file)
@@ -13,8 +13,8 @@
 DECLARE_GLOBAL_DATA_PTR;
 #endif /* !USE_HOSTCC*/
 #include <image.h>
-#include <rsa.h>
-#include <rsa-checksum.h>
+#include <u-boot/rsa.h>
+#include <u-boot/rsa-checksum.h>
 
 #define IMAGE_MAX_HASHED_NODES         100
 
index 828b0af6d2235e40541bdf56e69d1dfc65003766..11b3cf58e6fe197c48e724bbcd02532ea30cf5ae 100644 (file)
@@ -34,7 +34,7 @@
 #endif
 
 #include <u-boot/md5.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 #include <asm/errno.h>
 #include <asm/io.h>
 
index ed4f5418238c710d34da4751ffdb769df6d195d9..efef4911233adafe60df7065b719b2adbdd23d93 100644 (file)
@@ -8,8 +8,8 @@
 #include "ace_sha.h"
 
 #ifdef CONFIG_SHA_HW_ACCEL
-#include <sha256.h>
-#include <sha1.h>
+#include <u-boot/sha256.h>
+#include <u-boot/sha1.h>
 #include <asm/errno.h>
 
 /* SHA1 value for the message of zero length */
index 4bb1d60e5a9964c6d8415d015deb03a605565f26..8a04af557d035e6211865e4f2e1662d105d4447d 100644 (file)
@@ -13,7 +13,7 @@
 #include <hash.h>
 #include <malloc.h>
 #include <os.h>
-#include <sha256.h>
+#include <u-boot/sha256.h>
 #include <spi.h>
 #include <asm/state.h>
 #include <asm/sdl.h>
index 05936f5d1f344e7928c19ba116581cdae172b7aa..9d0b8bc0c8f9b41fd91185729e87c3777e8c7a23 100644 (file)
@@ -11,7 +11,7 @@
 #include <config.h>
 #include <common.h>
 #include <mmc.h>
-#include <sha256.h>
+#include <u-boot/sha256.h>
 #include "mmc_private.h"
 
 /* Request codes */
index ab93eb633396ab76cf653e7138a8cc5dcf60ed09..0a072f5336c7f24fe1e81a9838c7565b3606820b 100644 (file)
@@ -886,7 +886,7 @@ struct image_region {
 };
 
 #if IMAGE_ENABLE_VERIFY
-# include <rsa-checksum.h>
+# include <u-boot/rsa-checksum.h>
 #endif
 struct checksum_algo {
        const char *name;
diff --git a/include/rsa-checksum.h b/include/rsa-checksum.h
deleted file mode 100644 (file)
index 612db85..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2013, Andreas Oetken.
- *
- * SPDX-License-Identifier:    GPL-2.0+
-*/
-
-#ifndef _RSA_CHECKSUM_H
-#define _RSA_CHECKSUM_H
-
-#include <errno.h>
-#include <image.h>
-#include <sha1.h>
-#include <sha256.h>
-
-extern const uint8_t padding_sha256_rsa4096[];
-extern const uint8_t padding_sha256_rsa2048[];
-extern const uint8_t padding_sha1_rsa2048[];
-
-void sha256_calculate(const struct image_region region[], int region_count,
-                     uint8_t *checksum);
-void sha1_calculate(const struct image_region region[], int region_count,
-                   uint8_t *checksum);
-
-#endif
diff --git a/include/rsa.h b/include/rsa.h
deleted file mode 100644 (file)
index 325751a..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2013, Google Inc.
- *
- * (C) Copyright 2008 Semihalf
- *
- * (C) Copyright 2000-2006
- * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#ifndef _RSA_H
-#define _RSA_H
-
-#include <errno.h>
-#include <image.h>
-
-/**
- * struct rsa_public_key - holder for a public key
- *
- * An RSA public key consists of a modulus (typically called N), the inverse
- * and R^2, where R is 2^(# key bits).
- */
-
-struct rsa_public_key {
-       uint len;               /* len of modulus[] in number of uint32_t */
-       uint32_t n0inv;         /* -1 / modulus[0] mod 2^32 */
-       uint32_t *modulus;      /* modulus as little endian array */
-       uint32_t *rr;           /* R^2 as little endian array */
-};
-
-#if IMAGE_ENABLE_SIGN
-/**
- * sign() - calculate and return signature for given input data
- *
- * @info:      Specifies key and FIT information
- * @data:      Pointer to the input data
- * @data_len:  Data length
- * @sigp:      Set to an allocated buffer holding the signature
- * @sig_len:   Set to length of the calculated hash
- *
- * This computes input data signature according to selected algorithm.
- * Resulting signature value is placed in an allocated buffer, the
- * pointer is returned as *sigp. The length of the calculated
- * signature is returned via the sig_len pointer argument. The caller
- * should free *sigp.
- *
- * @return: 0, on success, -ve on error
- */
-int rsa_sign(struct image_sign_info *info,
-            const struct image_region region[],
-            int region_count, uint8_t **sigp, uint *sig_len);
-
-/**
- * add_verify_data() - Add verification information to FDT
- *
- * Add public key information to the FDT node, suitable for
- * verification at run-time. The information added depends on the
- * algorithm being used.
- *
- * @info:      Specifies key and FIT information
- * @keydest:   Destination FDT blob for public key data
- * @return: 0, on success, -ENOSPC if the keydest FDT blob ran out of space,
-               other -ve value on error
-*/
-int rsa_add_verify_data(struct image_sign_info *info, void *keydest);
-#else
-static inline int rsa_sign(struct image_sign_info *info,
-               const struct image_region region[], int region_count,
-               uint8_t **sigp, uint *sig_len)
-{
-       return -ENXIO;
-}
-
-static inline int rsa_add_verify_data(struct image_sign_info *info,
-                                     void *keydest)
-{
-       return -ENXIO;
-}
-#endif
-
-#if IMAGE_ENABLE_VERIFY
-/**
- * rsa_verify() - Verify a signature against some data
- *
- * Verify a RSA PKCS1.5 signature against an expected hash.
- *
- * @info:      Specifies key and FIT information
- * @data:      Pointer to the input data
- * @data_len:  Data length
- * @sig:       Signature
- * @sig_len:   Number of bytes in signature
- * @return 0 if verified, -ve on error
- */
-int rsa_verify(struct image_sign_info *info,
-              const struct image_region region[], int region_count,
-              uint8_t *sig, uint sig_len);
-#else
-static inline int rsa_verify(struct image_sign_info *info,
-               const struct image_region region[], int region_count,
-               uint8_t *sig, uint sig_len)
-{
-       return -ENXIO;
-}
-#endif
-
-#define RSA2048_BYTES  (2048 / 8)
-#define RSA4096_BYTES  (4096 / 8)
-
-/* This is the minimum/maximum key size we support, in bits */
-#define RSA_MIN_KEY_BITS       2048
-#define RSA_MAX_KEY_BITS       4096
-
-/* This is the maximum signature length that we support, in bits */
-#define RSA_MAX_SIG_BITS       4096
-
-#endif
diff --git a/include/sha1.h b/include/sha1.h
deleted file mode 100644 (file)
index da09dab..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/**
- * \file sha1.h
- * based from http://xyssl.org/code/source/sha1/
- *  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.
- *
- *  http://www.itl.nist.gov/fipspubs/fip180-1.htm
- */
-#ifndef _SHA1_H
-#define _SHA1_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define SHA1_SUM_POS   -0x20
-#define SHA1_SUM_LEN   20
-
-/**
- * \brief         SHA-1 context structure
- */
-typedef struct
-{
-    unsigned long total[2];    /*!< number of bytes processed  */
-    unsigned long state[5];    /*!< intermediate digest state  */
-    unsigned char buffer[64];  /*!< data block being processed */
-}
-sha1_context;
-
-/**
- * \brief         SHA-1 context setup
- *
- * \param ctx     SHA-1 context to be initialized
- */
-void sha1_starts( sha1_context *ctx );
-
-/**
- * \brief         SHA-1 process buffer
- *
- * \param ctx     SHA-1 context
- * \param input    buffer holding the  data
- * \param ilen    length of the input data
- */
-void sha1_update(sha1_context *ctx, const unsigned char *input,
-                unsigned int ilen);
-
-/**
- * \brief         SHA-1 final digest
- *
- * \param ctx     SHA-1 context
- * \param output   SHA-1 checksum result
- */
-void sha1_finish( sha1_context *ctx, unsigned char output[20] );
-
-/**
- * \brief         Output = SHA-1( input buffer )
- *
- * \param input    buffer holding the  data
- * \param ilen    length of the input data
- * \param output   SHA-1 checksum result
- */
-void sha1_csum(const unsigned char *input, unsigned int ilen,
-               unsigned char *output);
-
-/**
- * \brief         Output = SHA-1( input buffer ), with watchdog triggering
- *
- * \param input    buffer holding the  data
- * \param ilen    length of the input data
- * \param output   SHA-1 checksum result
- * \param chunk_sz watchdog triggering period (in bytes of input processed)
- */
-void sha1_csum_wd(const unsigned char *input, unsigned int ilen,
-               unsigned char *output, unsigned int chunk_sz);
-
-/**
- * \brief         Output = HMAC-SHA-1( input buffer, hmac key )
- *
- * \param key     HMAC secret key
- * \param keylen   length of the HMAC key
- * \param input    buffer holding the  data
- * \param ilen    length of the input data
- * \param output   HMAC-SHA-1 result
- */
-void sha1_hmac(const unsigned char *key, int keylen,
-               const unsigned char *input, unsigned int ilen,
-               unsigned char *output);
-
-/**
- * \brief         Checkup routine
- *
- * \return        0 if successful, or 1 if the test failed
- */
-int sha1_self_test( void );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* sha1.h */
diff --git a/include/sha256.h b/include/sha256.h
deleted file mode 100644 (file)
index beadab3..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef _SHA256_H
-#define _SHA256_H
-
-#define SHA256_SUM_LEN 32
-
-/* Reset watchdog each time we process this many bytes */
-#define CHUNKSZ_SHA256 (64 * 1024)
-
-typedef struct {
-       uint32_t total[2];
-       uint32_t state[8];
-       uint8_t buffer[64];
-} sha256_context;
-
-void sha256_starts(sha256_context * ctx);
-void sha256_update(sha256_context *ctx, const uint8_t *input, uint32_t length);
-void sha256_finish(sha256_context * ctx, uint8_t digest[SHA256_SUM_LEN]);
-
-void sha256_csum_wd(const unsigned char *input, unsigned int ilen,
-               unsigned char *output, unsigned int chunk_sz);
-
-#endif /* _SHA256_H */
diff --git a/include/u-boot/rsa-checksum.h b/include/u-boot/rsa-checksum.h
new file mode 100644 (file)
index 0000000..c996fb3
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2013, Andreas Oetken.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+*/
+
+#ifndef _RSA_CHECKSUM_H
+#define _RSA_CHECKSUM_H
+
+#include <errno.h>
+#include <image.h>
+#include <u-boot/sha1.h>
+#include <u-boot/sha256.h>
+
+extern const uint8_t padding_sha256_rsa4096[];
+extern const uint8_t padding_sha256_rsa2048[];
+extern const uint8_t padding_sha1_rsa2048[];
+
+void sha256_calculate(const struct image_region region[], int region_count,
+                     uint8_t *checksum);
+void sha1_calculate(const struct image_region region[], int region_count,
+                   uint8_t *checksum);
+
+#endif
diff --git a/include/u-boot/rsa.h b/include/u-boot/rsa.h
new file mode 100644 (file)
index 0000000..325751a
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2013, Google Inc.
+ *
+ * (C) Copyright 2008 Semihalf
+ *
+ * (C) Copyright 2000-2006
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef _RSA_H
+#define _RSA_H
+
+#include <errno.h>
+#include <image.h>
+
+/**
+ * struct rsa_public_key - holder for a public key
+ *
+ * An RSA public key consists of a modulus (typically called N), the inverse
+ * and R^2, where R is 2^(# key bits).
+ */
+
+struct rsa_public_key {
+       uint len;               /* len of modulus[] in number of uint32_t */
+       uint32_t n0inv;         /* -1 / modulus[0] mod 2^32 */
+       uint32_t *modulus;      /* modulus as little endian array */
+       uint32_t *rr;           /* R^2 as little endian array */
+};
+
+#if IMAGE_ENABLE_SIGN
+/**
+ * sign() - calculate and return signature for given input data
+ *
+ * @info:      Specifies key and FIT information
+ * @data:      Pointer to the input data
+ * @data_len:  Data length
+ * @sigp:      Set to an allocated buffer holding the signature
+ * @sig_len:   Set to length of the calculated hash
+ *
+ * This computes input data signature according to selected algorithm.
+ * Resulting signature value is placed in an allocated buffer, the
+ * pointer is returned as *sigp. The length of the calculated
+ * signature is returned via the sig_len pointer argument. The caller
+ * should free *sigp.
+ *
+ * @return: 0, on success, -ve on error
+ */
+int rsa_sign(struct image_sign_info *info,
+            const struct image_region region[],
+            int region_count, uint8_t **sigp, uint *sig_len);
+
+/**
+ * add_verify_data() - Add verification information to FDT
+ *
+ * Add public key information to the FDT node, suitable for
+ * verification at run-time. The information added depends on the
+ * algorithm being used.
+ *
+ * @info:      Specifies key and FIT information
+ * @keydest:   Destination FDT blob for public key data
+ * @return: 0, on success, -ENOSPC if the keydest FDT blob ran out of space,
+               other -ve value on error
+*/
+int rsa_add_verify_data(struct image_sign_info *info, void *keydest);
+#else
+static inline int rsa_sign(struct image_sign_info *info,
+               const struct image_region region[], int region_count,
+               uint8_t **sigp, uint *sig_len)
+{
+       return -ENXIO;
+}
+
+static inline int rsa_add_verify_data(struct image_sign_info *info,
+                                     void *keydest)
+{
+       return -ENXIO;
+}
+#endif
+
+#if IMAGE_ENABLE_VERIFY
+/**
+ * rsa_verify() - Verify a signature against some data
+ *
+ * Verify a RSA PKCS1.5 signature against an expected hash.
+ *
+ * @info:      Specifies key and FIT information
+ * @data:      Pointer to the input data
+ * @data_len:  Data length
+ * @sig:       Signature
+ * @sig_len:   Number of bytes in signature
+ * @return 0 if verified, -ve on error
+ */
+int rsa_verify(struct image_sign_info *info,
+              const struct image_region region[], int region_count,
+              uint8_t *sig, uint sig_len);
+#else
+static inline int rsa_verify(struct image_sign_info *info,
+               const struct image_region region[], int region_count,
+               uint8_t *sig, uint sig_len)
+{
+       return -ENXIO;
+}
+#endif
+
+#define RSA2048_BYTES  (2048 / 8)
+#define RSA4096_BYTES  (4096 / 8)
+
+/* This is the minimum/maximum key size we support, in bits */
+#define RSA_MIN_KEY_BITS       2048
+#define RSA_MAX_KEY_BITS       4096
+
+/* This is the maximum signature length that we support, in bits */
+#define RSA_MAX_SIG_BITS       4096
+
+#endif
diff --git a/include/u-boot/sha1.h b/include/u-boot/sha1.h
new file mode 100644 (file)
index 0000000..da09dab
--- /dev/null
@@ -0,0 +1,118 @@
+/**
+ * \file sha1.h
+ * based from http://xyssl.org/code/source/sha1/
+ *  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.
+ *
+ *  http://www.itl.nist.gov/fipspubs/fip180-1.htm
+ */
+#ifndef _SHA1_H
+#define _SHA1_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SHA1_SUM_POS   -0x20
+#define SHA1_SUM_LEN   20
+
+/**
+ * \brief         SHA-1 context structure
+ */
+typedef struct
+{
+    unsigned long total[2];    /*!< number of bytes processed  */
+    unsigned long state[5];    /*!< intermediate digest state  */
+    unsigned char buffer[64];  /*!< data block being processed */
+}
+sha1_context;
+
+/**
+ * \brief         SHA-1 context setup
+ *
+ * \param ctx     SHA-1 context to be initialized
+ */
+void sha1_starts( sha1_context *ctx );
+
+/**
+ * \brief         SHA-1 process buffer
+ *
+ * \param ctx     SHA-1 context
+ * \param input    buffer holding the  data
+ * \param ilen    length of the input data
+ */
+void sha1_update(sha1_context *ctx, const unsigned char *input,
+                unsigned int ilen);
+
+/**
+ * \brief         SHA-1 final digest
+ *
+ * \param ctx     SHA-1 context
+ * \param output   SHA-1 checksum result
+ */
+void sha1_finish( sha1_context *ctx, unsigned char output[20] );
+
+/**
+ * \brief         Output = SHA-1( input buffer )
+ *
+ * \param input    buffer holding the  data
+ * \param ilen    length of the input data
+ * \param output   SHA-1 checksum result
+ */
+void sha1_csum(const unsigned char *input, unsigned int ilen,
+               unsigned char *output);
+
+/**
+ * \brief         Output = SHA-1( input buffer ), with watchdog triggering
+ *
+ * \param input    buffer holding the  data
+ * \param ilen    length of the input data
+ * \param output   SHA-1 checksum result
+ * \param chunk_sz watchdog triggering period (in bytes of input processed)
+ */
+void sha1_csum_wd(const unsigned char *input, unsigned int ilen,
+               unsigned char *output, unsigned int chunk_sz);
+
+/**
+ * \brief         Output = HMAC-SHA-1( input buffer, hmac key )
+ *
+ * \param key     HMAC secret key
+ * \param keylen   length of the HMAC key
+ * \param input    buffer holding the  data
+ * \param ilen    length of the input data
+ * \param output   HMAC-SHA-1 result
+ */
+void sha1_hmac(const unsigned char *key, int keylen,
+               const unsigned char *input, unsigned int ilen,
+               unsigned char *output);
+
+/**
+ * \brief         Checkup routine
+ *
+ * \return        0 if successful, or 1 if the test failed
+ */
+int sha1_self_test( void );
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* sha1.h */
diff --git a/include/u-boot/sha256.h b/include/u-boot/sha256.h
new file mode 100644 (file)
index 0000000..beadab3
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef _SHA256_H
+#define _SHA256_H
+
+#define SHA256_SUM_LEN 32
+
+/* Reset watchdog each time we process this many bytes */
+#define CHUNKSZ_SHA256 (64 * 1024)
+
+typedef struct {
+       uint32_t total[2];
+       uint32_t state[8];
+       uint8_t buffer[64];
+} sha256_context;
+
+void sha256_starts(sha256_context * ctx);
+void sha256_update(sha256_context *ctx, const uint8_t *input, uint32_t length);
+void sha256_finish(sha256_context * ctx, uint8_t digest[SHA256_SUM_LEN]);
+
+void sha256_csum_wd(const unsigned char *input, unsigned int ilen,
+               unsigned char *output, unsigned int chunk_sz);
+
+#endif /* _SHA256_H */
index 32d6602e9758ef553b7a20a06dc0ff581c33a071..8d8b59f779a2bd7d5d9eeb413706c86b5307d9ff 100644 (file)
@@ -13,9 +13,9 @@
 #else
 #include "fdt_host.h"
 #endif
-#include <rsa.h>
-#include <sha1.h>
-#include <sha256.h>
+#include <u-boot/rsa.h>
+#include <u-boot/sha1.h>
+#include <u-boot/sha256.h>
 
 /* PKCS 1.5 paddings as described in the RSA PKCS#1 v2.1 standard. */
 
index 587da5b470685de78ebc86bf611c0abf8fd0c387..bcb906368d0dc273eb462a023a8d0477f2c51795 100644 (file)
@@ -17,9 +17,9 @@
 #include "mkimage.h"
 #include <fdt_support.h>
 #endif
-#include <rsa.h>
-#include <sha1.h>
-#include <sha256.h>
+#include <u-boot/rsa.h>
+#include <u-boot/sha1.h>
+#include <u-boot/sha256.h>
 
 #define UINT64_MULT32(v, multby)  (((uint64_t)(v)) * ((uint32_t)(multby)))
 
index a121224855f4786f9ca92de5396bd1262301c6bc..0a5f68864c74cd6c1e6fa59443ae10706e62b0f9 100644 (file)
@@ -36,7 +36,7 @@
 #include <string.h>
 #endif /* USE_HOSTCC */
 #include <watchdog.h>
-#include "sha1.h"
+#include <u-boot/sha1.h>
 
 /*
  * 32-bit integer manipulation macros (big endian)
index b1085ea791759128dad36cc338bb8430d5389a32..bb338baefa836a6a73d5872c9f7412536b0a25f2 100644 (file)
@@ -13,7 +13,7 @@
 #include <string.h>
 #endif /* USE_HOSTCC */
 #include <watchdog.h>
-#include <sha256.h>
+#include <u-boot/sha256.h>
 
 /*
  * 32-bit integer manipulation macros (big endian)
index 967c8e65150a354a098db3c8196db6e4cc129f5c..d9789b022ab3e9c507f4d2983da1bb6c746c90a9 100644 (file)
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -7,7 +7,7 @@
 
 #include <common.h>
 #include <stdarg.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 #include <tpm.h>
 #include <asm/unaligned.h>
 
index 949b6c6c38baaa5a51c714c186538dfb1f1457e0..3a1180f433c929890c87205c6615c941bc17b6bb 100644 (file)
@@ -192,7 +192,6 @@ endif # !LOGO_BMP
 # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
 #
 HOST_EXTRACFLAGS += -include $(srctree)/include/libfdt_env.h \
-               -include $(srctree)/include/sha256.h \
                $(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \
                -I$(srctree)/lib/libfdt \
                -I$(srctree)/tools \
index d78523ded7231e869f29193cf15bb072ffc86333..e415f14e147ed8729dae2f44a0c9f7192944135a 100644 (file)
@@ -18,7 +18,7 @@
 #include <sys/stat.h>
 #include <time.h>
 #include <unistd.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 #include "fdt_host.h"
 #include "imagetool.h"
 
index c480687ec13884c43cb99ac39a977847198aa375..c8af0e82f8b7247d5acdcbfd7db7d242ca8401e1 100644 (file)
@@ -18,7 +18,7 @@
 #include <sys/stat.h>
 #include <time.h>
 #include <unistd.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 #include "fdt_host.h"
 
 #define ARRAY_SIZE(x)          (sizeof(x) / sizeof((x)[0]))
index d5491b6e60ae8eddcbbf8d6e67db8ed19ab4db5c..3f369b748ed19ed4896a0a529f86052717080c52 100644 (file)
@@ -18,7 +18,7 @@
 #include <sys/stat.h>
 #include <time.h>
 #include <unistd.h>
-#include <sha1.h>
+#include <u-boot/sha1.h>
 #include "fdt_host.h"
 #include "imagetool.h"
 
index 1041588d0b037aa7bdd5909644d352c5b20bab25..4a17246da78f1832876771000127c61183827232 100644 (file)
@@ -13,7 +13,7 @@
 #include <errno.h>
 #include <string.h>
 #include <sys/stat.h>
-#include "sha1.h"
+#include <u-boot/sha1.h>
 
 int main (int argc, char **argv)
 {