<pre style='margin:0'>
Ryan Schmidt (ryandesign) pushed a commit to branch master
in repository macports-ports.
</pre>
<p><a href="https://github.com/macports/macports-ports/commit/7435ee17e45db982038b300a05a9d13a27b4ce49">https://github.com/macports/macports-ports/commit/7435ee17e45db982038b300a05a9d13a27b4ce49</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/master by this push:
<span style='display:block; white-space:pre;color:#404040;'> new 7435ee17e45 ota: Update to 20211019
</span>7435ee17e45 is described below
<span style='display:block; white-space:pre;color:#808000;'>commit 7435ee17e45db982038b300a05a9d13a27b4ce49
</span>Author: Ryan Schmidt <ryandesign@macports.org>
AuthorDate: Fri Nov 12 20:58:20 2021 -0600
<span style='display:block; white-space:pre;color:#404040;'> ota: Update to 20211019
</span>---
archivers/ota/Portfile | 19 +-
archivers/ota/files/Makefile | 2 +
archivers/ota/files/Makefile.patch | 10 -
archivers/ota/files/sha1.c | 402 +++++++++++++++++++++++++++++++++++++
archivers/ota/files/sha1.h | 61 ++++++
5 files changed, 477 insertions(+), 17 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/archivers/ota/Portfile b/archivers/ota/Portfile
</span><span style='display:block; white-space:pre;color:#808080;'>index b66f07c1463..c7d61818173 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/archivers/ota/Portfile
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/archivers/ota/Portfile
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -3,11 +3,11 @@
</span> PortSystem 1.0
name ota
<span style='display:block; white-space:pre;background:#ffe0e0;'>-version 20190807
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+version 20211019
</span> revision 0
<span style='display:block; white-space:pre;background:#ffe0e0;'>-checksums rmd160 edd60965633482d52e642facaf3e7a15882574a4 \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- sha256 cc208120d4fa4bc540de1842783a9affa094f2a3f297c57e8e1fce3986420345 \
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- size 44107
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+checksums rmd160 de53405922f23ca6db59c0d356025bff4b15df16 \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ sha256 a40eac2a6831f38c76b03b81dc494ad7ba301dac4a828399f546297154f49239 \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ size 46909
</span>
categories archivers
platforms darwin
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -16,7 +16,7 @@ license Permissive
</span>
description iOS OTA/PBZX expander/unpacker/lister/searcher
<span style='display:block; white-space:pre;background:#ffe0e0;'>-long_description ${name} is an ${description}.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+long_description ${name} is an {*}${description}.
</span>
extract.suffix .tgz
homepage http://newosxbook.com/articles/OTA8.html
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -26,7 +26,11 @@ depends_lib port:xz
</span>
extract.mkdir yes
<span style='display:block; white-space:pre;background:#ffe0e0;'>-patchfiles Makefile.patch
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+post-patch {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # The developer has failed to include these required files in the distribution.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ # Copied from the previous (20190807) version of the distribution.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ xinstall -m 0644 -W ${filespath} sha1.c sha1.h ${worksrcpath}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span>
use_configure no
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -35,7 +39,8 @@ variant universal {}
</span> build.args CC="${configure.cc} [get_canonical_archflags cc]" \
CFLAGS="${configure.cflags}" \
CPPFLAGS="${configure.cppflags}" \
<span style='display:block; white-space:pre;background:#ffe0e0;'>- LDFLAGS="${configure.ldflags}"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ LDFLAGS="${configure.ldflags}" \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ -f ${filespath}/Makefile
</span>
destroot {
xinstall ${worksrcpath}/${name} ${destroot}${prefix}/bin
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/archivers/ota/files/Makefile b/archivers/ota/files/Makefile
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 00000000000..e416c15c4c4
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/archivers/ota/files/Makefile
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,2 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+all:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $(CC) ota.c 02_decompress.c -o ota -I. $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -llzma -g2
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/archivers/ota/files/Makefile.patch b/archivers/ota/files/Makefile.patch
</span>deleted file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 9fda60d3577..00000000000
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/archivers/ota/files/Makefile.patch
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -1,10 +0,0 @@
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>---- Makefile.orig 2019-08-07 00:39:32.000000000 -0500
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+++ Makefile 2019-11-11 23:02:11.000000000 -0600
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-@@ -1,5 +1,5 @@
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- all:
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- cc ota.c 02_decompress.c -o ota.macOS -I./liblzma-master/src/liblzma/api/ -llzma -g2
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ $(CC) ota.c 02_decompress.c -o ota -I. $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -llzma -g2
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- linux:
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-- cc -DLINUX ota.c 02_decompress.c -o ota.ELF64 -I./liblzma-master/src/liblzma/api/ -llzma -g2
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-+ $(CC) -DLINUX ota.c 02_decompress.c -o ota -I. $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -llzma -g2
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>-
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/archivers/ota/files/sha1.c b/archivers/ota/files/sha1.c
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 00000000000..1666949b214
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/archivers/ota/files/sha1.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,402 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * sha1.c
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Description:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * This file implements the Secure Hashing Algorithm 1 as
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * defined in FIPS PUB 180-1 published April 17, 1995.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * The SHA-1, produces a 160-bit message digest for a given
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * data stream. It should take about 2**n steps to find a
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * message with the same digest as a given message and
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * 2**(n/2) to find any two messages with the same digest,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * when n is the digest size in bits. Therefore, this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * algorithm can serve as a means of providing a
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * "fingerprint" for a message.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Portability Issues:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * SHA-1 is defined in terms of 32-bit "words". This code
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * uses <stdint.h> (included via "sha1.h" to define 32 and 8
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * bit unsigned integer types. If your C compiler does not
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * support 32 bit unsigned integers, this code is not
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * appropriate.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Caveats:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * SHA-1 is designed to work with messages less than 2^64 bits
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * long. Although SHA-1 allows a message digest to be generated
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * for messages of any number of bits less than 2^64, this
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * implementation only works with messages with a length that is
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * a multiple of the size of an 8-bit character.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include "sha1.h"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Define the SHA1 circular left shift macro
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define SHA1CircularShift(bits,word) \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ (((word) << (bits)) | ((word) >> (32-(bits))))
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/* Local Function Prototyptes */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+void SHA1PadMessage(SHA1Context *);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+void SHA1ProcessMessageBlock(SHA1Context *);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * SHA1Reset
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Description:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * This function will initialize the SHA1Context in preparation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * for computing a new SHA1 message digest.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Parameters:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * context: [in/out]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * The context to reset.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Returns:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * sha Error Code.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int SHA1Reset(SHA1Context *context)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (!context)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return shaNull;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Length_Low = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Length_High = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block_Index = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Intermediate_Hash[0] = 0x67452301;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Intermediate_Hash[1] = 0xEFCDAB89;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Intermediate_Hash[2] = 0x98BADCFE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Intermediate_Hash[3] = 0x10325476;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Intermediate_Hash[4] = 0xC3D2E1F0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Computed = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Corrupted = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return shaSuccess;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * SHA1Result
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Description:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * This function will return the 160-bit message digest into the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Message_Digest array provided by the caller.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * NOTE: The first octet of hash is stored in the 0th element,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * the last octet of hash in the 19th element.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Parameters:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * context: [in/out]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * The context to use to calculate the SHA-1 hash.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Message_Digest: [out]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Where the digest is returned.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Returns:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * sha Error Code.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int SHA1Result( SHA1Context *context,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uint8_t Message_Digest[SHA1HashSize])
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int i;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (!context || !Message_Digest)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return shaNull;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (context->Corrupted)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return context->Corrupted;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (!context->Computed)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ SHA1PadMessage(context);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for(i=0; i<64; ++i)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* message may be sensitive, clear it out */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[i] = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Length_Low = 0; /* and clear length */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Length_High = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Computed = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for(i = 0; i < SHA1HashSize; ++i)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ Message_Digest[i] = context->Intermediate_Hash[i>>2]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ >> 8 * ( 3 - ( i & 0x03 ) );
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return shaSuccess;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * SHA1Input
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Description:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * This function accepts an array of octets as the next portion
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * of the message.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Parameters:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * context: [in/out]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * The SHA context to update
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * message_array: [in]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * An array of characters representing the next portion of
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * the message.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * length: [in]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * The length of the message in message_array
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Returns:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * sha Error Code.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int SHA1Input( SHA1Context *context,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ const uint8_t *message_array,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ unsigned length)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (!length)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return shaSuccess;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (!context || !message_array)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return shaNull;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (context->Computed)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Corrupted = shaStateError;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return shaStateError;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (context->Corrupted)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return context->Corrupted;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ while(length-- && !context->Corrupted)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[context->Message_Block_Index++] =
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ (*message_array & 0xFF);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Length_Low += 8;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (context->Length_Low == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Length_High++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (context->Length_High == 0)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* Message is too long */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Corrupted = 1;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (context->Message_Block_Index == 64)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ SHA1ProcessMessageBlock(context);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ message_array++;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ return shaSuccess;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * SHA1ProcessMessageBlock
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Description:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * This function will process the next 512 bits of the message
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * stored in the Message_Block array.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Parameters:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * None.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Returns:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Nothing.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Comments:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Many of the variable names in this code, especially the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * single character names, were used because those were the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * names used in the publication.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+void SHA1ProcessMessageBlock(SHA1Context *context)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ const uint32_t K[] = { /* Constants defined in SHA-1 */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 0x5A827999,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 0x6ED9EBA1,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 0x8F1BBCDC,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ 0xCA62C1D6
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ };
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int t; /* Loop counter */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uint32_t temp; /* Temporary word value */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uint32_t W[80]; /* Word sequence */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uint32_t A, B, C, D, E; /* Word buffers */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Initialize the first 16 words in the array W
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for(t = 0; t < 16; t++)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ W[t] = context->Message_Block[t * 4] << 24;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ W[t] |= context->Message_Block[t * 4 + 1] << 16;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ W[t] |= context->Message_Block[t * 4 + 2] << 8;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ W[t] |= context->Message_Block[t * 4 + 3];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for(t = 16; t < 80; t++)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ W[t] = SHA1CircularShift(1,W[t-3] ^ W[t-8] ^ W[t-14] ^ W[t-16]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ A = context->Intermediate_Hash[0];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ B = context->Intermediate_Hash[1];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ C = context->Intermediate_Hash[2];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ D = context->Intermediate_Hash[3];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ E = context->Intermediate_Hash[4];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for(t = 0; t < 20; t++)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ temp = SHA1CircularShift(5,A) +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ((B & C) | ((~B) & D)) + E + W[t] + K[0];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ E = D;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ D = C;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ C = SHA1CircularShift(30,B);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ B = A;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ A = temp;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for(t = 20; t < 40; t++)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[1];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ E = D;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ D = C;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ C = SHA1CircularShift(30,B);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ B = A;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ A = temp;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for(t = 40; t < 60; t++)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ temp = SHA1CircularShift(5,A) +
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ((B & C) | (B & D) | (C & D)) + E + W[t] + K[2];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ E = D;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ D = C;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ C = SHA1CircularShift(30,B);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ B = A;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ A = temp;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ for(t = 60; t < 80; t++)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ temp = SHA1CircularShift(5,A) + (B ^ C ^ D) + E + W[t] + K[3];
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ E = D;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ D = C;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ C = SHA1CircularShift(30,B);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ B = A;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ A = temp;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Intermediate_Hash[0] += A;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Intermediate_Hash[1] += B;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Intermediate_Hash[2] += C;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Intermediate_Hash[3] += D;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Intermediate_Hash[4] += E;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block_Index = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * SHA1PadMessage
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Description:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * According to the standard, the message must be padded to an even
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * 512 bits. The first padding bit must be a '1'. The last 64
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * bits represent the length of the original message. All bits in
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * between should be 0. This function will pad the message
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * according to those rules by filling the Message_Block array
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * accordingly. It will also call the ProcessMessageBlock function
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * provided appropriately. When it returns, it can be assumed that
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * the message digest has been computed.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Parameters:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * context: [in/out]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * The context to pad
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * ProcessMessageBlock: [in]
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * The appropriate SHA*ProcessMessageBlock function
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Returns:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Nothing.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+void SHA1PadMessage(SHA1Context *context)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Check to see if the current message block is too small to hold
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * the initial padding bits and length. If so, we will pad the
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * block, process it, and then continue padding into a second
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * block.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (context->Message_Block_Index > 55)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[context->Message_Block_Index++] = 0x80;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ while(context->Message_Block_Index < 64)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[context->Message_Block_Index++] = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ SHA1ProcessMessageBlock(context);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ while(context->Message_Block_Index < 56)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[context->Message_Block_Index++] = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[context->Message_Block_Index++] = 0x80;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ while(context->Message_Block_Index < 56)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[context->Message_Block_Index++] = 0;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Store the message length as the last 8 octets
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[56] = context->Length_High >> 24;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[57] = context->Length_High >> 16;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[58] = context->Length_High >> 8;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[59] = context->Length_High;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[60] = context->Length_Low >> 24;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[61] = context->Length_Low >> 16;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[62] = context->Length_Low >> 8;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ context->Message_Block[63] = context->Length_Low;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ SHA1ProcessMessageBlock(context);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int doSHA1(unsigned char *input, unsigned int len, uint8_t Message_Digest[SHA1HashSize])
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+SHA1Context sha;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+SHA1Reset (&sha);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+SHA1Input(&sha, input, len);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+SHA1Result(&sha, Message_Digest);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+return (0);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/archivers/ota/files/sha1.h b/archivers/ota/files/sha1.h
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 00000000000..0f953637352
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/archivers/ota/files/sha1.h
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1,61 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef _SHA1_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define _SHA1_H_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <stdint.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * If you do not have the ISO standard stdint.h header file, then you
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * must typdef the following:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * name meaning
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * uint32_t unsigned 32 bit integer
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * uint8_t unsigned 8 bit integer (i.e., unsigned char)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * int_least16_t integer of >= 16 bits
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ *
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifndef _SHA_enum_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define _SHA_enum_
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+enum
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ shaSuccess = 0,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ shaNull, /* Null pointer parameter */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ shaInputTooLong, /* input data too long */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ shaStateError /* called Input after Result */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+};
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define SHA1HashSize 20
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * This structure will hold context information for the SHA-1
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * hashing operation
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+typedef struct SHA1Context
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+{
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uint32_t Intermediate_Hash[SHA1HashSize/4]; /* Message Digest */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uint32_t Length_Low; /* Message length in bits */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uint32_t Length_High; /* Message length in bits */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ /* Index into message block array */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int_least16_t Message_Block_Index;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uint8_t Message_Block[64]; /* 512-bit message blocks */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int Computed; /* Is the digest computed? */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ int Corrupted; /* Is the message digest corrupted? */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+} SHA1Context;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+/*
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Function Prototypes
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ */
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int SHA1Reset( SHA1Context *);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int SHA1Input( SHA1Context *,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ const uint8_t *,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ unsigned int);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int SHA1Result( SHA1Context *,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ uint8_t Message_Digest[SHA1HashSize]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+int doSHA1(unsigned char *input, unsigned int len, uint8_t Message_Digest[SHA1HashSize]);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span></pre><pre style='margin:0'>
</pre>