Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/808097/?format=api
{ "id": 808097, "url": "http://patchwork.ozlabs.org/api/patches/808097/?format=api", "web_url": "http://patchwork.ozlabs.org/project/skiboot/patch/1504164285-15095-9-git-send-email-cclaudio@linux.vnet.ibm.com/", "project": { "id": 44, "url": "http://patchwork.ozlabs.org/api/projects/44/?format=api", "name": "skiboot firmware development", "link_name": "skiboot", "list_id": "skiboot.lists.ozlabs.org", "list_email": "skiboot@lists.ozlabs.org", "web_url": "http://github.com/open-power/skiboot", "scm_url": "http://github.com/open-power/skiboot", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<1504164285-15095-9-git-send-email-cclaudio@linux.vnet.ibm.com>", "list_archive_url": null, "date": "2017-08-31T07:24:39", "name": "[v2,08/14] libstb: move drivers/sha512.* to mbedtls/sha512.*", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "fcf646f82a8ff5fad9ca3faa0de06b858b8e595f", "submitter": { "id": 69305, "url": "http://patchwork.ozlabs.org/api/people/69305/?format=api", "name": "Claudio Carvalho", "email": "cclaudio@linux.vnet.ibm.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/skiboot/patch/1504164285-15095-9-git-send-email-cclaudio@linux.vnet.ibm.com/mbox/", "series": [ { "id": 760, "url": "http://patchwork.ozlabs.org/api/series/760/?format=api", "web_url": "http://patchwork.ozlabs.org/project/skiboot/list/?series=760", "date": "2017-08-31T07:24:31", "name": "libstb: simplify the initialization of cvc drivers", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/760/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/808097/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/808097/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "skiboot@lists.ozlabs.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "skiboot@lists.ozlabs.org" ], "Received": [ "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xjYqN4KG8z9sNc\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 17:27:28 +1000 (AEST)", "from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xjYqN2nNCzDqgB\n\tfor <incoming@patchwork.ozlabs.org>;\n\tThu, 31 Aug 2017 17:27:28 +1000 (AEST)", "from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com\n\t[148.163.158.5])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xjYmt1dwgzDqT0\n\tfor <skiboot@lists.ozlabs.org>; Thu, 31 Aug 2017 17:25:17 +1000 (AEST)", "from pps.filterd (m0098420.ppops.net [127.0.0.1])\n\tby mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv7V7Nh23086326\n\tfor <skiboot@lists.ozlabs.org>; Thu, 31 Aug 2017 03:25:12 -0400", "from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208])\n\tby mx0b-001b2d01.pphosted.com with ESMTP id 2cpdd69sh6-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <skiboot@lists.ozlabs.org>; Thu, 31 Aug 2017 03:25:12 -0400", "from localhost\n\tby e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <skiboot@lists.ozlabs.org> from <cclaudio@linux.vnet.ibm.com>;\n\tThu, 31 Aug 2017 03:25:11 -0400", "from b01cxnp22036.gho.pok.ibm.com (9.57.198.26)\n\tby e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tThu, 31 Aug 2017 03:25:10 -0400", "from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com\n\t[9.57.199.109])\n\tby b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP\n\tid v7V7PAlj30670898\n\tfor <skiboot@lists.ozlabs.org>; Thu, 31 Aug 2017 07:25:10 GMT", "from localhost (unknown [127.0.0.1])\n\tby IMSVA (Postfix) with SMTP id F057F112051\n\tfor <skiboot@lists.ozlabs.org>; Thu, 31 Aug 2017 03:24:55 -0400 (EDT)", "from legolas.ibm.com (unknown [9.85.193.48])\n\tby b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id EAF6F112034;\n\tThu, 31 Aug 2017 03:24:52 -0400 (EDT)" ], "X-IMSS-HAND-OFF-DIRECTIVE": "127.0.0.1:10026", "From": "Claudio Carvalho <cclaudio@linux.vnet.ibm.com>", "To": "skiboot@lists.ozlabs.org", "Date": "Thu, 31 Aug 2017 04:24:39 -0300", "X-Mailer": "git-send-email 2.7.4", "In-Reply-To": "<1504164285-15095-1-git-send-email-cclaudio@linux.vnet.ibm.com>", "References": "<1504164285-15095-1-git-send-email-cclaudio@linux.vnet.ibm.com>", "X-TM-AS-GCONF": "00", "x-cbid": "17083107-0044-0000-0000-00000385D466", "X-IBM-SpamModules-Scores": "", "X-IBM-SpamModules-Versions": "BY=3.00007640; HX=3.00000241; KW=3.00000007;\n\tPH=3.00000004; SC=3.00000226; SDB=6.00910098; UDB=6.00456511;\n\tIPR=6.00690378; \n\tBA=6.00005562; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009;\n\tZB=6.00000000; \n\tZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016938;\n\tXFM=3.00000015; UTC=2017-08-31 07:25:11", "X-IBM-AV-DETECTION": "SAVI=unused REMOTE=unused XFE=unused", "x-cbparentid": "17083107-0045-0000-0000-000007B3ED73", "Message-Id": "<1504164285-15095-9-git-send-email-cclaudio@linux.vnet.ibm.com>", "X-Proofpoint-Virus-Version": "vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-08-31_02:, , signatures=0", "X-Proofpoint-Spam-Details": "rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=3\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1708310114", "Subject": "[Skiboot] [PATCH v2 08/14] libstb: move drivers/sha512.* to\n\tmbedtls/sha512.*", "X-BeenThere": "skiboot@lists.ozlabs.org", "X-Mailman-Version": "2.1.23", "Precedence": "list", "List-Id": "Mailing list for skiboot development <skiboot.lists.ozlabs.org>", "List-Unsubscribe": "<https://lists.ozlabs.org/options/skiboot>,\n\t<mailto:skiboot-request@lists.ozlabs.org?subject=unsubscribe>", "List-Archive": "<http://lists.ozlabs.org/pipermail/skiboot/>", "List-Post": "<mailto:skiboot@lists.ozlabs.org>", "List-Help": "<mailto:skiboot-request@lists.ozlabs.org?subject=help>", "List-Subscribe": "<https://lists.ozlabs.org/listinfo/skiboot>,\n\t<mailto:skiboot-request@lists.ozlabs.org?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Errors-To": "skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org", "Sender": "\"Skiboot\"\n\t<skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>" }, "content": "This gives a better name to the drivers/sha512.* files and moves them to\na better place.\n\nThe sha512.* files were imported from the mbedtls project. If we want to\nimport any other file from mbedtls for a purpose that is not necessarily\nCVC emulation, it would be easy to add the new file to the mbedtls\ndirectory.\n\nSigned-off-by: Claudio Carvalho <cclaudio@linux.vnet.ibm.com>\n---\n libstb/Makefile.inc | 3 +-\n libstb/cvc/c1vc_mbedtls.c | 2 +-\n libstb/drivers/Makefile.inc | 2 +-\n libstb/drivers/sha512.c | 480 --------------------------------------------\n libstb/drivers/sha512.h | 141 -------------\n libstb/mbedtls/Makefile.inc | 11 +\n libstb/mbedtls/sha512.c | 480 ++++++++++++++++++++++++++++++++++++++++++++\n libstb/mbedtls/sha512.h | 141 +++++++++++++\n 8 files changed, 636 insertions(+), 624 deletions(-)\n delete mode 100644 libstb/drivers/sha512.c\n delete mode 100644 libstb/drivers/sha512.h\n create mode 100644 libstb/mbedtls/Makefile.inc\n create mode 100644 libstb/mbedtls/sha512.c\n create mode 100644 libstb/mbedtls/sha512.h", "diff": "diff --git a/libstb/Makefile.inc b/libstb/Makefile.inc\nindex 5389fac..8a78fb6 100644\n--- a/libstb/Makefile.inc\n+++ b/libstb/Makefile.inc\n@@ -9,10 +9,11 @@ LIBSTB_OBJS = $(LIBSTB_SRCS:%.c=%.o)\n LIBSTB = $(LIBSTB_DIR)/built-in.o\n \n include $(SRC)/$(LIBSTB_DIR)/cvc/Makefile.inc\n+include $(SRC)/$(LIBSTB_DIR)/mbedtls/Makefile.inc\n include $(SRC)/$(LIBSTB_DIR)/drivers/Makefile.inc\n include $(SRC)/$(LIBSTB_DIR)/tss/Makefile.inc\n \n-$(LIBSTB): $(LIBSTB_OBJS:%=$(LIBSTB_DIR)/%) $(DRIVERS) $(TSS) $(CVC)\n+$(LIBSTB): $(LIBSTB_OBJS:%=$(LIBSTB_DIR)/%) $(DRIVERS) $(TSS) $(CVC) $(MBEDTLS)\n \n libstb/create-container: libstb/create-container.c\n \t$(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) \\\ndiff --git a/libstb/cvc/c1vc_mbedtls.c b/libstb/cvc/c1vc_mbedtls.c\nindex 8a7c404..4cf8e13 100644\n--- a/libstb/cvc/c1vc_mbedtls.c\n+++ b/libstb/cvc/c1vc_mbedtls.c\n@@ -18,7 +18,7 @@\n #include <string.h>\n #include <skiboot.h>\n #include \"../rom.h\"\n-#include \"sha512.h\"\n+#include \"../mbedtls/sha512.h\"\n #include \"c1vc_mbedtls.h\"\n \n static sha2_hash_t *hw_key_hash = NULL;\ndiff --git a/libstb/drivers/Makefile.inc b/libstb/drivers/Makefile.inc\nindex 4ea867f..3b8ed0f 100644\n--- a/libstb/drivers/Makefile.inc\n+++ b/libstb/drivers/Makefile.inc\n@@ -4,7 +4,7 @@ DRIVERS_DIR = libstb/drivers\n \n SUBDIRS += $(DRIVERS_DIR)\n \n-DRIVERS_SRCS = tpm_i2c_interface.c tpm_i2c_nuvoton.c sha512.c\n+DRIVERS_SRCS = tpm_i2c_interface.c tpm_i2c_nuvoton.c\n DRIVERS_OBJS = $(DRIVERS_SRCS:%.c=%.o)\n DRIVERS = $(DRIVERS_DIR)/built-in.o\n \ndiff --git a/libstb/drivers/sha512.c b/libstb/drivers/sha512.c\ndeleted file mode 100644\nindex a133795..0000000\n--- a/libstb/drivers/sha512.c\n+++ /dev/null\n@@ -1,480 +0,0 @@\n-/*\n- * FIPS-180-2 compliant SHA-384/512 implementation\n- *\n- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved\n- * SPDX-License-Identifier: Apache-2.0\n- *\n- * Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n- * not use this file except in compliance with the License.\n- * You may obtain a copy of the License at\n- *\n- * http://www.apache.org/licenses/LICENSE-2.0\n- *\n- * Unless required by applicable law or agreed to in writing, software\n- * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n- * See the License for the specific language governing permissions and\n- * limitations under the License.\n- *\n- * This file is part of mbed TLS (https://tls.mbed.org)\n- */\n-/*\n- * The SHA-512 Secure Hash Standard was published by NIST in 2002.\n- *\n- * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf\n- */\n-\n-#include \"sha512.h\"\n-\n-#define UL64(x) x\n-\n-#include <string.h>\n-#include <stdio.h>\n-#define mbedtls_printf printf\n-\n-#if !defined(MBEDTLS_SHA512_ALT)\n-\n-/* Implementation that should never be optimized out by the compiler */\n-static void mbedtls_zeroize( void *v, size_t n ) {\n- volatile unsigned char *p = v; while( n-- ) *p++ = 0;\n-}\n-\n-/*\n- * 64-bit integer manipulation macros (big endian)\n- */\n-#ifndef GET_UINT64_BE\n-#define GET_UINT64_BE(n,b,i) \\\n-{ \\\n- (n) = ( (uint64_t) (b)[(i) ] << 56 ) \\\n- | ( (uint64_t) (b)[(i) + 1] << 48 ) \\\n- | ( (uint64_t) (b)[(i) + 2] << 40 ) \\\n- | ( (uint64_t) (b)[(i) + 3] << 32 ) \\\n- | ( (uint64_t) (b)[(i) + 4] << 24 ) \\\n- | ( (uint64_t) (b)[(i) + 5] << 16 ) \\\n- | ( (uint64_t) (b)[(i) + 6] << 8 ) \\\n- | ( (uint64_t) (b)[(i) + 7] ); \\\n-}\n-#endif /* GET_UINT64_BE */\n-\n-#ifndef PUT_UINT64_BE\n-#define PUT_UINT64_BE(n,b,i) \\\n-{ \\\n- (b)[(i) ] = (unsigned char) ( (n) >> 56 ); \\\n- (b)[(i) + 1] = (unsigned char) ( (n) >> 48 ); \\\n- (b)[(i) + 2] = (unsigned char) ( (n) >> 40 ); \\\n- (b)[(i) + 3] = (unsigned char) ( (n) >> 32 ); \\\n- (b)[(i) + 4] = (unsigned char) ( (n) >> 24 ); \\\n- (b)[(i) + 5] = (unsigned char) ( (n) >> 16 ); \\\n- (b)[(i) + 6] = (unsigned char) ( (n) >> 8 ); \\\n- (b)[(i) + 7] = (unsigned char) ( (n) ); \\\n-}\n-#endif /* PUT_UINT64_BE */\n-\n-void mbedtls_sha512_init( mbedtls_sha512_context *ctx )\n-{\n- memset( ctx, 0, sizeof( mbedtls_sha512_context ) );\n-}\n-\n-void mbedtls_sha512_free( mbedtls_sha512_context *ctx )\n-{\n- if( ctx == NULL )\n- return;\n-\n- mbedtls_zeroize( ctx, sizeof( mbedtls_sha512_context ) );\n-}\n-\n-void mbedtls_sha512_clone( mbedtls_sha512_context *dst,\n- const mbedtls_sha512_context *src )\n-{\n- *dst = *src;\n-}\n-\n-/*\n- * SHA-512 context setup\n- */\n-void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 )\n-{\n- ctx->total[0] = 0;\n- ctx->total[1] = 0;\n-\n- if( is384 == 0 )\n- {\n- /* SHA-512 */\n- ctx->state[0] = UL64(0x6A09E667F3BCC908);\n- ctx->state[1] = UL64(0xBB67AE8584CAA73B);\n- ctx->state[2] = UL64(0x3C6EF372FE94F82B);\n- ctx->state[3] = UL64(0xA54FF53A5F1D36F1);\n- ctx->state[4] = UL64(0x510E527FADE682D1);\n- ctx->state[5] = UL64(0x9B05688C2B3E6C1F);\n- ctx->state[6] = UL64(0x1F83D9ABFB41BD6B);\n- ctx->state[7] = UL64(0x5BE0CD19137E2179);\n- }\n- else\n- {\n- /* SHA-384 */\n- ctx->state[0] = UL64(0xCBBB9D5DC1059ED8);\n- ctx->state[1] = UL64(0x629A292A367CD507);\n- ctx->state[2] = UL64(0x9159015A3070DD17);\n- ctx->state[3] = UL64(0x152FECD8F70E5939);\n- ctx->state[4] = UL64(0x67332667FFC00B31);\n- ctx->state[5] = UL64(0x8EB44A8768581511);\n- ctx->state[6] = UL64(0xDB0C2E0D64F98FA7);\n- ctx->state[7] = UL64(0x47B5481DBEFA4FA4);\n- }\n-\n- ctx->is384 = is384;\n-}\n-\n-#if !defined(MBEDTLS_SHA512_PROCESS_ALT)\n-\n-/*\n- * Round constants\n- */\n-static const uint64_t K[80] =\n-{\n- UL64(0x428A2F98D728AE22), UL64(0x7137449123EF65CD),\n- UL64(0xB5C0FBCFEC4D3B2F), UL64(0xE9B5DBA58189DBBC),\n- UL64(0x3956C25BF348B538), UL64(0x59F111F1B605D019),\n- UL64(0x923F82A4AF194F9B), UL64(0xAB1C5ED5DA6D8118),\n- UL64(0xD807AA98A3030242), UL64(0x12835B0145706FBE),\n- UL64(0x243185BE4EE4B28C), UL64(0x550C7DC3D5FFB4E2),\n- UL64(0x72BE5D74F27B896F), UL64(0x80DEB1FE3B1696B1),\n- UL64(0x9BDC06A725C71235), UL64(0xC19BF174CF692694),\n- UL64(0xE49B69C19EF14AD2), UL64(0xEFBE4786384F25E3),\n- UL64(0x0FC19DC68B8CD5B5), UL64(0x240CA1CC77AC9C65),\n- UL64(0x2DE92C6F592B0275), UL64(0x4A7484AA6EA6E483),\n- UL64(0x5CB0A9DCBD41FBD4), UL64(0x76F988DA831153B5),\n- UL64(0x983E5152EE66DFAB), UL64(0xA831C66D2DB43210),\n- UL64(0xB00327C898FB213F), UL64(0xBF597FC7BEEF0EE4),\n- UL64(0xC6E00BF33DA88FC2), UL64(0xD5A79147930AA725),\n- UL64(0x06CA6351E003826F), UL64(0x142929670A0E6E70),\n- UL64(0x27B70A8546D22FFC), UL64(0x2E1B21385C26C926),\n- UL64(0x4D2C6DFC5AC42AED), UL64(0x53380D139D95B3DF),\n- UL64(0x650A73548BAF63DE), UL64(0x766A0ABB3C77B2A8),\n- UL64(0x81C2C92E47EDAEE6), UL64(0x92722C851482353B),\n- UL64(0xA2BFE8A14CF10364), UL64(0xA81A664BBC423001),\n- UL64(0xC24B8B70D0F89791), UL64(0xC76C51A30654BE30),\n- UL64(0xD192E819D6EF5218), UL64(0xD69906245565A910),\n- UL64(0xF40E35855771202A), UL64(0x106AA07032BBD1B8),\n- UL64(0x19A4C116B8D2D0C8), UL64(0x1E376C085141AB53),\n- UL64(0x2748774CDF8EEB99), UL64(0x34B0BCB5E19B48A8),\n- UL64(0x391C0CB3C5C95A63), UL64(0x4ED8AA4AE3418ACB),\n- UL64(0x5B9CCA4F7763E373), UL64(0x682E6FF3D6B2B8A3),\n- UL64(0x748F82EE5DEFB2FC), UL64(0x78A5636F43172F60),\n- UL64(0x84C87814A1F0AB72), UL64(0x8CC702081A6439EC),\n- UL64(0x90BEFFFA23631E28), UL64(0xA4506CEBDE82BDE9),\n- UL64(0xBEF9A3F7B2C67915), UL64(0xC67178F2E372532B),\n- UL64(0xCA273ECEEA26619C), UL64(0xD186B8C721C0C207),\n- UL64(0xEADA7DD6CDE0EB1E), UL64(0xF57D4F7FEE6ED178),\n- UL64(0x06F067AA72176FBA), UL64(0x0A637DC5A2C898A6),\n- UL64(0x113F9804BEF90DAE), UL64(0x1B710B35131C471B),\n- UL64(0x28DB77F523047D84), UL64(0x32CAAB7B40C72493),\n- UL64(0x3C9EBE0A15C9BEBC), UL64(0x431D67C49C100D4C),\n- UL64(0x4CC5D4BECB3E42B6), UL64(0x597F299CFC657E2A),\n- UL64(0x5FCB6FAB3AD6FAEC), UL64(0x6C44198C4A475817)\n-};\n-\n-void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] )\n-{\n- int i;\n- uint64_t temp1, temp2, W[80];\n- uint64_t A, B, C, D, E, F, G, H;\n-\n-#define SHR(x,n) (x >> n)\n-#define ROTR(x,n) (SHR(x,n) | (x << (64 - n)))\n-\n-#define S0(x) (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x, 7))\n-#define S1(x) (ROTR(x,19) ^ ROTR(x,61) ^ SHR(x, 6))\n-\n-#define S2(x) (ROTR(x,28) ^ ROTR(x,34) ^ ROTR(x,39))\n-#define S3(x) (ROTR(x,14) ^ ROTR(x,18) ^ ROTR(x,41))\n-\n-#define F0(x,y,z) ((x & y) | (z & (x | y)))\n-#define F1(x,y,z) (z ^ (x & (y ^ z)))\n-\n-#define P(a,b,c,d,e,f,g,h,x,K) \\\n-{ \\\n- temp1 = h + S3(e) + F1(e,f,g) + K + x; \\\n- temp2 = S2(a) + F0(a,b,c); \\\n- d += temp1; h = temp1 + temp2; \\\n-}\n-\n- for( i = 0; i < 16; i++ )\n- {\n- GET_UINT64_BE( W[i], data, i << 3 );\n- }\n-\n- for( ; i < 80; i++ )\n- {\n- W[i] = S1(W[i - 2]) + W[i - 7] +\n- S0(W[i - 15]) + W[i - 16];\n- }\n-\n- A = ctx->state[0];\n- B = ctx->state[1];\n- C = ctx->state[2];\n- D = ctx->state[3];\n- E = ctx->state[4];\n- F = ctx->state[5];\n- G = ctx->state[6];\n- H = ctx->state[7];\n- i = 0;\n-\n- do\n- {\n- P( A, B, C, D, E, F, G, H, W[i], K[i] ); i++;\n- P( H, A, B, C, D, E, F, G, W[i], K[i] ); i++;\n- P( G, H, A, B, C, D, E, F, W[i], K[i] ); i++;\n- P( F, G, H, A, B, C, D, E, W[i], K[i] ); i++;\n- P( E, F, G, H, A, B, C, D, W[i], K[i] ); i++;\n- P( D, E, F, G, H, A, B, C, W[i], K[i] ); i++;\n- P( C, D, E, F, G, H, A, B, W[i], K[i] ); i++;\n- P( B, C, D, E, F, G, H, A, W[i], K[i] ); i++;\n- }\n- while( i < 80 );\n-\n- ctx->state[0] += A;\n- ctx->state[1] += B;\n- ctx->state[2] += C;\n- ctx->state[3] += D;\n- ctx->state[4] += E;\n- ctx->state[5] += F;\n- ctx->state[6] += G;\n- ctx->state[7] += H;\n-}\n-#endif /* !MBEDTLS_SHA512_PROCESS_ALT */\n-\n-/*\n- * SHA-512 process buffer\n- */\n-void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input,\n- size_t ilen )\n-{\n- size_t fill;\n- unsigned int left;\n-\n- if( ilen == 0 )\n- return;\n-\n- left = (unsigned int) (ctx->total[0] & 0x7F);\n- fill = 128 - left;\n-\n- ctx->total[0] += (uint64_t) ilen;\n-\n- if( ctx->total[0] < (uint64_t) ilen )\n- ctx->total[1]++;\n-\n- if( left && ilen >= fill )\n- {\n- memcpy( (void *) (ctx->buffer + left), input, fill );\n- mbedtls_sha512_process( ctx, ctx->buffer );\n- input += fill;\n- ilen -= fill;\n- left = 0;\n- }\n-\n- while( ilen >= 128 )\n- {\n- mbedtls_sha512_process( ctx, input );\n- input += 128;\n- ilen -= 128;\n- }\n-\n- if( ilen > 0 )\n- memcpy( (void *) (ctx->buffer + left), input, ilen );\n-}\n-\n-static const unsigned char sha512_padding[128] =\n-{\n- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n-};\n-\n-/*\n- * SHA-512 final digest\n- */\n-void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] )\n-{\n- size_t last, padn;\n- uint64_t high, low;\n- unsigned char msglen[16];\n-\n- high = ( ctx->total[0] >> 61 )\n- | ( ctx->total[1] << 3 );\n- low = ( ctx->total[0] << 3 );\n-\n- PUT_UINT64_BE( high, msglen, 0 );\n- PUT_UINT64_BE( low, msglen, 8 );\n-\n- last = (size_t)( ctx->total[0] & 0x7F );\n- padn = ( last < 112 ) ? ( 112 - last ) : ( 240 - last );\n-\n- mbedtls_sha512_update( ctx, sha512_padding, padn );\n- mbedtls_sha512_update( ctx, msglen, 16 );\n-\n- PUT_UINT64_BE( ctx->state[0], output, 0 );\n- PUT_UINT64_BE( ctx->state[1], output, 8 );\n- PUT_UINT64_BE( ctx->state[2], output, 16 );\n- PUT_UINT64_BE( ctx->state[3], output, 24 );\n- PUT_UINT64_BE( ctx->state[4], output, 32 );\n- PUT_UINT64_BE( ctx->state[5], output, 40 );\n-\n- if( ctx->is384 == 0 )\n- {\n- PUT_UINT64_BE( ctx->state[6], output, 48 );\n- PUT_UINT64_BE( ctx->state[7], output, 56 );\n- }\n-}\n-\n-#endif /* !MBEDTLS_SHA512_ALT */\n-\n-/*\n- * output = SHA-512( input buffer )\n- */\n-void mbedtls_sha512( const unsigned char *input, size_t ilen,\n- unsigned char output[64], int is384 )\n-{\n- mbedtls_sha512_context ctx;\n-\n- mbedtls_sha512_init( &ctx );\n- mbedtls_sha512_starts( &ctx, is384 );\n- mbedtls_sha512_update( &ctx, input, ilen );\n- mbedtls_sha512_finish( &ctx, output );\n- mbedtls_sha512_free( &ctx );\n-}\n-\n-#if defined(MBEDTLS_SELF_TEST)\n-\n-/*\n- * FIPS-180-2 test vectors\n- */\n-static const unsigned char sha512_test_buf[3][113] =\n-{\n- { \"abc\" },\n- { \"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn\"\n- \"hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu\" },\n- { \"\" }\n-};\n-\n-static const int sha512_test_buflen[3] =\n-{\n- 3, 112, 1000\n-};\n-\n-static const unsigned char sha512_test_sum[6][64] =\n-{\n- /*\n- * SHA-384 test vectors\n- */\n- { 0xCB, 0x00, 0x75, 0x3F, 0x45, 0xA3, 0x5E, 0x8B,\n- 0xB5, 0xA0, 0x3D, 0x69, 0x9A, 0xC6, 0x50, 0x07,\n- 0x27, 0x2C, 0x32, 0xAB, 0x0E, 0xDE, 0xD1, 0x63,\n- 0x1A, 0x8B, 0x60, 0x5A, 0x43, 0xFF, 0x5B, 0xED,\n- 0x80, 0x86, 0x07, 0x2B, 0xA1, 0xE7, 0xCC, 0x23,\n- 0x58, 0xBA, 0xEC, 0xA1, 0x34, 0xC8, 0x25, 0xA7 },\n- { 0x09, 0x33, 0x0C, 0x33, 0xF7, 0x11, 0x47, 0xE8,\n- 0x3D, 0x19, 0x2F, 0xC7, 0x82, 0xCD, 0x1B, 0x47,\n- 0x53, 0x11, 0x1B, 0x17, 0x3B, 0x3B, 0x05, 0xD2,\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88, 0x90, 0x18,\n- 0x50, 0x1D, 0x28, 0x9E, 0x49, 0x00, 0xF7, 0xE4,\n- 0x33, 0x1B, 0x99, 0xDE, 0xC4, 0xB5, 0x43, 0x3A,\n- 0xC7, 0xD3, 0x29, 0xEE, 0xB6, 0xDD, 0x26, 0x54,\n- 0x5E, 0x96, 0xE5, 0x5B, 0x87, 0x4B, 0xE9, 0x09 },\n- { 0xE7, 0x18, 0x48, 0x3D, 0x0C, 0xE7, 0x69, 0x64,\n- 0x4E, 0x2E, 0x42, 0xC7, 0xBC, 0x15, 0xB4, 0x63,\n- 0x8E, 0x1F, 0x98, 0xB1, 0x3B, 0x20, 0x44, 0x28,\n- 0x56, 0x32, 0xA8, 0x03, 0xAF, 0xA9, 0x73, 0xEB,\n- 0xDE, 0x0F, 0xF2, 0x44, 0x87, 0x7E, 0xA6, 0x0A,\n- 0x4C, 0xB0, 0x43, 0x2C, 0xE5, 0x77, 0xC3, 0x1B,\n- 0xEB, 0x00, 0x9C, 0x5C, 0x2C, 0x49, 0xAA, 0x2E,\n- 0x4E, 0xAD, 0xB2, 0x17, 0xAD, 0x8C, 0xC0, 0x9B }\n-};\n-\n-/*\n- * Checkup routine\n- */\n-int mbedtls_sha512_self_test( int verbose )\n-{\n- int i, j, k, buflen, ret = 0;\n- unsigned char buf[1024];\n- unsigned char sha512sum[64];\n- mbedtls_sha512_context ctx;\n-\n- mbedtls_sha512_init( &ctx );\n-\n- for( i = 0; i < 6; i++ )\n- {\n- j = i % 3;\n- k = i < 3;\n-\n- if( verbose != 0 )\n- mbedtls_printf( \" SHA-%d test #%d: \", 512 - k * 128, j + 1 );\n-\n- mbedtls_sha512_starts( &ctx, k );\n-\n- if( j == 2 )\n- {\n- memset( buf, 'a', buflen = 1000 );\n-\n- for( j = 0; j < 1000; j++ )\n- mbedtls_sha512_update( &ctx, buf, buflen );\n- }\n- else\n- mbedtls_sha512_update( &ctx, sha512_test_buf[j],\n- sha512_test_buflen[j] );\n-\n- mbedtls_sha512_finish( &ctx, sha512sum );\n-\n- if( memcmp( sha512sum, sha512_test_sum[i], 64 - k * 16 ) != 0 )\n- {\n- if( verbose != 0 )\n- mbedtls_printf( \"failed\\n\" );\n-\n- ret = 1;\n- goto exit;\n- }\n-\n- if( verbose != 0 )\n- mbedtls_printf( \"passed\\n\" );\n- }\n-\n- if( verbose != 0 )\n- mbedtls_printf( \"\\n\" );\n-\n-exit:\n- mbedtls_sha512_free( &ctx );\n-\n- return( ret );\n-}\n-\n-#endif /* MBEDTLS_SELF_TEST */\ndiff --git a/libstb/drivers/sha512.h b/libstb/drivers/sha512.h\ndeleted file mode 100644\nindex 627694f..0000000\n--- a/libstb/drivers/sha512.h\n+++ /dev/null\n@@ -1,141 +0,0 @@\n-/**\n- * \\file sha512.h\n- *\n- * \\brief SHA-384 and SHA-512 cryptographic hash function\n- *\n- * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved\n- * SPDX-License-Identifier: Apache-2.0\n- *\n- * Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n- * not use this file except in compliance with the License.\n- * You may obtain a copy of the License at\n- *\n- * http://www.apache.org/licenses/LICENSE-2.0\n- *\n- * Unless required by applicable law or agreed to in writing, software\n- * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n- * See the License for the specific language governing permissions and\n- * limitations under the License.\n- *\n- * This file is part of mbed TLS (https://tls.mbed.org)\n- */\n-#ifndef MBEDTLS_SHA512_H\n-#define MBEDTLS_SHA512_H\n-\n-#if !defined(MBEDTLS_CONFIG_FILE)\n-#include \"config.h\"\n-#else\n-#include MBEDTLS_CONFIG_FILE\n-#endif\n-\n-#include <stddef.h>\n-#include <stdint.h>\n-\n-#if !defined(MBEDTLS_SHA512_ALT)\n-// Regular implementation\n-//\n-\n-#ifdef __cplusplus\n-extern \"C\" {\n-#endif\n-\n-/**\n- * \\brief SHA-512 context structure\n- */\n-typedef struct\n-{\n- uint64_t total[2]; /*!< number of bytes processed */\n- uint64_t state[8]; /*!< intermediate digest state */\n- unsigned char buffer[128]; /*!< data block being processed */\n- int is384; /*!< 0 => SHA-512, else SHA-384 */\n-}\n-mbedtls_sha512_context;\n-\n-/**\n- * \\brief Initialize SHA-512 context\n- *\n- * \\param ctx SHA-512 context to be initialized\n- */\n-void mbedtls_sha512_init( mbedtls_sha512_context *ctx );\n-\n-/**\n- * \\brief Clear SHA-512 context\n- *\n- * \\param ctx SHA-512 context to be cleared\n- */\n-void mbedtls_sha512_free( mbedtls_sha512_context *ctx );\n-\n-/**\n- * \\brief Clone (the state of) a SHA-512 context\n- *\n- * \\param dst The destination context\n- * \\param src The context to be cloned\n- */\n-void mbedtls_sha512_clone( mbedtls_sha512_context *dst,\n- const mbedtls_sha512_context *src );\n-\n-/**\n- * \\brief SHA-512 context setup\n- *\n- * \\param ctx context to be initialized\n- * \\param is384 0 = use SHA512, 1 = use SHA384\n- */\n-void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 );\n-\n-/**\n- * \\brief SHA-512 process buffer\n- *\n- * \\param ctx SHA-512 context\n- * \\param input buffer holding the data\n- * \\param ilen length of the input data\n- */\n-void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input,\n- size_t ilen );\n-\n-/**\n- * \\brief SHA-512 final digest\n- *\n- * \\param ctx SHA-512 context\n- * \\param output SHA-384/512 checksum result\n- */\n-void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] );\n-\n-#ifdef __cplusplus\n-}\n-#endif\n-\n-#else /* MBEDTLS_SHA512_ALT */\n-#include \"sha512_alt.h\"\n-#endif /* MBEDTLS_SHA512_ALT */\n-\n-#ifdef __cplusplus\n-extern \"C\" {\n-#endif\n-\n-/**\n- * \\brief Output = SHA-512( input buffer )\n- *\n- * \\param input buffer holding the data\n- * \\param ilen length of the input data\n- * \\param output SHA-384/512 checksum result\n- * \\param is384 0 = use SHA512, 1 = use SHA384\n- */\n-void mbedtls_sha512( const unsigned char *input, size_t ilen,\n- unsigned char output[64], int is384 );\n-\n-/**\n- * \\brief Checkup routine\n- *\n- * \\return 0 if successful, or 1 if the test failed\n- */\n-int mbedtls_sha512_self_test( int verbose );\n-\n-/* Internal use */\n-void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] );\n-\n-#ifdef __cplusplus\n-}\n-#endif\n-\n-#endif /* mbedtls_sha512.h */\ndiff --git a/libstb/mbedtls/Makefile.inc b/libstb/mbedtls/Makefile.inc\nnew file mode 100644\nindex 0000000..07aa26a\n--- /dev/null\n+++ b/libstb/mbedtls/Makefile.inc\n@@ -0,0 +1,11 @@\n+# -*-Makefile-*-\n+\n+MBEDTLS_DIR = libstb/mbedtls\n+\n+SUBDIRS += $(MBEDTLS_DIR)\n+\n+MBEDTLS_SRCS = sha512.c\n+MBEDTLS_OBJS = $(MBEDTLS_SRCS:%.c=%.o)\n+MBEDTLS = $(MBEDTLS_DIR)/built-in.o\n+\n+$(MBEDTLS): $(MBEDTLS_OBJS:%=$(MBEDTLS_DIR)/%)\ndiff --git a/libstb/mbedtls/sha512.c b/libstb/mbedtls/sha512.c\nnew file mode 100644\nindex 0000000..a133795\n--- /dev/null\n+++ b/libstb/mbedtls/sha512.c\n@@ -0,0 +1,480 @@\n+/*\n+ * FIPS-180-2 compliant SHA-384/512 implementation\n+ *\n+ * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved\n+ * SPDX-License-Identifier: Apache-2.0\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n+ * not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ *\n+ * This file is part of mbed TLS (https://tls.mbed.org)\n+ */\n+/*\n+ * The SHA-512 Secure Hash Standard was published by NIST in 2002.\n+ *\n+ * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf\n+ */\n+\n+#include \"sha512.h\"\n+\n+#define UL64(x) x\n+\n+#include <string.h>\n+#include <stdio.h>\n+#define mbedtls_printf printf\n+\n+#if !defined(MBEDTLS_SHA512_ALT)\n+\n+/* Implementation that should never be optimized out by the compiler */\n+static void mbedtls_zeroize( void *v, size_t n ) {\n+ volatile unsigned char *p = v; while( n-- ) *p++ = 0;\n+}\n+\n+/*\n+ * 64-bit integer manipulation macros (big endian)\n+ */\n+#ifndef GET_UINT64_BE\n+#define GET_UINT64_BE(n,b,i) \\\n+{ \\\n+ (n) = ( (uint64_t) (b)[(i) ] << 56 ) \\\n+ | ( (uint64_t) (b)[(i) + 1] << 48 ) \\\n+ | ( (uint64_t) (b)[(i) + 2] << 40 ) \\\n+ | ( (uint64_t) (b)[(i) + 3] << 32 ) \\\n+ | ( (uint64_t) (b)[(i) + 4] << 24 ) \\\n+ | ( (uint64_t) (b)[(i) + 5] << 16 ) \\\n+ | ( (uint64_t) (b)[(i) + 6] << 8 ) \\\n+ | ( (uint64_t) (b)[(i) + 7] ); \\\n+}\n+#endif /* GET_UINT64_BE */\n+\n+#ifndef PUT_UINT64_BE\n+#define PUT_UINT64_BE(n,b,i) \\\n+{ \\\n+ (b)[(i) ] = (unsigned char) ( (n) >> 56 ); \\\n+ (b)[(i) + 1] = (unsigned char) ( (n) >> 48 ); \\\n+ (b)[(i) + 2] = (unsigned char) ( (n) >> 40 ); \\\n+ (b)[(i) + 3] = (unsigned char) ( (n) >> 32 ); \\\n+ (b)[(i) + 4] = (unsigned char) ( (n) >> 24 ); \\\n+ (b)[(i) + 5] = (unsigned char) ( (n) >> 16 ); \\\n+ (b)[(i) + 6] = (unsigned char) ( (n) >> 8 ); \\\n+ (b)[(i) + 7] = (unsigned char) ( (n) ); \\\n+}\n+#endif /* PUT_UINT64_BE */\n+\n+void mbedtls_sha512_init( mbedtls_sha512_context *ctx )\n+{\n+ memset( ctx, 0, sizeof( mbedtls_sha512_context ) );\n+}\n+\n+void mbedtls_sha512_free( mbedtls_sha512_context *ctx )\n+{\n+ if( ctx == NULL )\n+ return;\n+\n+ mbedtls_zeroize( ctx, sizeof( mbedtls_sha512_context ) );\n+}\n+\n+void mbedtls_sha512_clone( mbedtls_sha512_context *dst,\n+ const mbedtls_sha512_context *src )\n+{\n+ *dst = *src;\n+}\n+\n+/*\n+ * SHA-512 context setup\n+ */\n+void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 )\n+{\n+ ctx->total[0] = 0;\n+ ctx->total[1] = 0;\n+\n+ if( is384 == 0 )\n+ {\n+ /* SHA-512 */\n+ ctx->state[0] = UL64(0x6A09E667F3BCC908);\n+ ctx->state[1] = UL64(0xBB67AE8584CAA73B);\n+ ctx->state[2] = UL64(0x3C6EF372FE94F82B);\n+ ctx->state[3] = UL64(0xA54FF53A5F1D36F1);\n+ ctx->state[4] = UL64(0x510E527FADE682D1);\n+ ctx->state[5] = UL64(0x9B05688C2B3E6C1F);\n+ ctx->state[6] = UL64(0x1F83D9ABFB41BD6B);\n+ ctx->state[7] = UL64(0x5BE0CD19137E2179);\n+ }\n+ else\n+ {\n+ /* SHA-384 */\n+ ctx->state[0] = UL64(0xCBBB9D5DC1059ED8);\n+ ctx->state[1] = UL64(0x629A292A367CD507);\n+ ctx->state[2] = UL64(0x9159015A3070DD17);\n+ ctx->state[3] = UL64(0x152FECD8F70E5939);\n+ ctx->state[4] = UL64(0x67332667FFC00B31);\n+ ctx->state[5] = UL64(0x8EB44A8768581511);\n+ ctx->state[6] = UL64(0xDB0C2E0D64F98FA7);\n+ ctx->state[7] = UL64(0x47B5481DBEFA4FA4);\n+ }\n+\n+ ctx->is384 = is384;\n+}\n+\n+#if !defined(MBEDTLS_SHA512_PROCESS_ALT)\n+\n+/*\n+ * Round constants\n+ */\n+static const uint64_t K[80] =\n+{\n+ UL64(0x428A2F98D728AE22), UL64(0x7137449123EF65CD),\n+ UL64(0xB5C0FBCFEC4D3B2F), UL64(0xE9B5DBA58189DBBC),\n+ UL64(0x3956C25BF348B538), UL64(0x59F111F1B605D019),\n+ UL64(0x923F82A4AF194F9B), UL64(0xAB1C5ED5DA6D8118),\n+ UL64(0xD807AA98A3030242), UL64(0x12835B0145706FBE),\n+ UL64(0x243185BE4EE4B28C), UL64(0x550C7DC3D5FFB4E2),\n+ UL64(0x72BE5D74F27B896F), UL64(0x80DEB1FE3B1696B1),\n+ UL64(0x9BDC06A725C71235), UL64(0xC19BF174CF692694),\n+ UL64(0xE49B69C19EF14AD2), UL64(0xEFBE4786384F25E3),\n+ UL64(0x0FC19DC68B8CD5B5), UL64(0x240CA1CC77AC9C65),\n+ UL64(0x2DE92C6F592B0275), UL64(0x4A7484AA6EA6E483),\n+ UL64(0x5CB0A9DCBD41FBD4), UL64(0x76F988DA831153B5),\n+ UL64(0x983E5152EE66DFAB), UL64(0xA831C66D2DB43210),\n+ UL64(0xB00327C898FB213F), UL64(0xBF597FC7BEEF0EE4),\n+ UL64(0xC6E00BF33DA88FC2), UL64(0xD5A79147930AA725),\n+ UL64(0x06CA6351E003826F), UL64(0x142929670A0E6E70),\n+ UL64(0x27B70A8546D22FFC), UL64(0x2E1B21385C26C926),\n+ UL64(0x4D2C6DFC5AC42AED), UL64(0x53380D139D95B3DF),\n+ UL64(0x650A73548BAF63DE), UL64(0x766A0ABB3C77B2A8),\n+ UL64(0x81C2C92E47EDAEE6), UL64(0x92722C851482353B),\n+ UL64(0xA2BFE8A14CF10364), UL64(0xA81A664BBC423001),\n+ UL64(0xC24B8B70D0F89791), UL64(0xC76C51A30654BE30),\n+ UL64(0xD192E819D6EF5218), UL64(0xD69906245565A910),\n+ UL64(0xF40E35855771202A), UL64(0x106AA07032BBD1B8),\n+ UL64(0x19A4C116B8D2D0C8), UL64(0x1E376C085141AB53),\n+ UL64(0x2748774CDF8EEB99), UL64(0x34B0BCB5E19B48A8),\n+ UL64(0x391C0CB3C5C95A63), UL64(0x4ED8AA4AE3418ACB),\n+ UL64(0x5B9CCA4F7763E373), UL64(0x682E6FF3D6B2B8A3),\n+ UL64(0x748F82EE5DEFB2FC), UL64(0x78A5636F43172F60),\n+ UL64(0x84C87814A1F0AB72), UL64(0x8CC702081A6439EC),\n+ UL64(0x90BEFFFA23631E28), UL64(0xA4506CEBDE82BDE9),\n+ UL64(0xBEF9A3F7B2C67915), UL64(0xC67178F2E372532B),\n+ UL64(0xCA273ECEEA26619C), UL64(0xD186B8C721C0C207),\n+ UL64(0xEADA7DD6CDE0EB1E), UL64(0xF57D4F7FEE6ED178),\n+ UL64(0x06F067AA72176FBA), UL64(0x0A637DC5A2C898A6),\n+ UL64(0x113F9804BEF90DAE), UL64(0x1B710B35131C471B),\n+ UL64(0x28DB77F523047D84), UL64(0x32CAAB7B40C72493),\n+ UL64(0x3C9EBE0A15C9BEBC), UL64(0x431D67C49C100D4C),\n+ UL64(0x4CC5D4BECB3E42B6), UL64(0x597F299CFC657E2A),\n+ UL64(0x5FCB6FAB3AD6FAEC), UL64(0x6C44198C4A475817)\n+};\n+\n+void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] )\n+{\n+ int i;\n+ uint64_t temp1, temp2, W[80];\n+ uint64_t A, B, C, D, E, F, G, H;\n+\n+#define SHR(x,n) (x >> n)\n+#define ROTR(x,n) (SHR(x,n) | (x << (64 - n)))\n+\n+#define S0(x) (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x, 7))\n+#define S1(x) (ROTR(x,19) ^ ROTR(x,61) ^ SHR(x, 6))\n+\n+#define S2(x) (ROTR(x,28) ^ ROTR(x,34) ^ ROTR(x,39))\n+#define S3(x) (ROTR(x,14) ^ ROTR(x,18) ^ ROTR(x,41))\n+\n+#define F0(x,y,z) ((x & y) | (z & (x | y)))\n+#define F1(x,y,z) (z ^ (x & (y ^ z)))\n+\n+#define P(a,b,c,d,e,f,g,h,x,K) \\\n+{ \\\n+ temp1 = h + S3(e) + F1(e,f,g) + K + x; \\\n+ temp2 = S2(a) + F0(a,b,c); \\\n+ d += temp1; h = temp1 + temp2; \\\n+}\n+\n+ for( i = 0; i < 16; i++ )\n+ {\n+ GET_UINT64_BE( W[i], data, i << 3 );\n+ }\n+\n+ for( ; i < 80; i++ )\n+ {\n+ W[i] = S1(W[i - 2]) + W[i - 7] +\n+ S0(W[i - 15]) + W[i - 16];\n+ }\n+\n+ A = ctx->state[0];\n+ B = ctx->state[1];\n+ C = ctx->state[2];\n+ D = ctx->state[3];\n+ E = ctx->state[4];\n+ F = ctx->state[5];\n+ G = ctx->state[6];\n+ H = ctx->state[7];\n+ i = 0;\n+\n+ do\n+ {\n+ P( A, B, C, D, E, F, G, H, W[i], K[i] ); i++;\n+ P( H, A, B, C, D, E, F, G, W[i], K[i] ); i++;\n+ P( G, H, A, B, C, D, E, F, W[i], K[i] ); i++;\n+ P( F, G, H, A, B, C, D, E, W[i], K[i] ); i++;\n+ P( E, F, G, H, A, B, C, D, W[i], K[i] ); i++;\n+ P( D, E, F, G, H, A, B, C, W[i], K[i] ); i++;\n+ P( C, D, E, F, G, H, A, B, W[i], K[i] ); i++;\n+ P( B, C, D, E, F, G, H, A, W[i], K[i] ); i++;\n+ }\n+ while( i < 80 );\n+\n+ ctx->state[0] += A;\n+ ctx->state[1] += B;\n+ ctx->state[2] += C;\n+ ctx->state[3] += D;\n+ ctx->state[4] += E;\n+ ctx->state[5] += F;\n+ ctx->state[6] += G;\n+ ctx->state[7] += H;\n+}\n+#endif /* !MBEDTLS_SHA512_PROCESS_ALT */\n+\n+/*\n+ * SHA-512 process buffer\n+ */\n+void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input,\n+ size_t ilen )\n+{\n+ size_t fill;\n+ unsigned int left;\n+\n+ if( ilen == 0 )\n+ return;\n+\n+ left = (unsigned int) (ctx->total[0] & 0x7F);\n+ fill = 128 - left;\n+\n+ ctx->total[0] += (uint64_t) ilen;\n+\n+ if( ctx->total[0] < (uint64_t) ilen )\n+ ctx->total[1]++;\n+\n+ if( left && ilen >= fill )\n+ {\n+ memcpy( (void *) (ctx->buffer + left), input, fill );\n+ mbedtls_sha512_process( ctx, ctx->buffer );\n+ input += fill;\n+ ilen -= fill;\n+ left = 0;\n+ }\n+\n+ while( ilen >= 128 )\n+ {\n+ mbedtls_sha512_process( ctx, input );\n+ input += 128;\n+ ilen -= 128;\n+ }\n+\n+ if( ilen > 0 )\n+ memcpy( (void *) (ctx->buffer + left), input, ilen );\n+}\n+\n+static const unsigned char sha512_padding[128] =\n+{\n+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\n+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n+};\n+\n+/*\n+ * SHA-512 final digest\n+ */\n+void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] )\n+{\n+ size_t last, padn;\n+ uint64_t high, low;\n+ unsigned char msglen[16];\n+\n+ high = ( ctx->total[0] >> 61 )\n+ | ( ctx->total[1] << 3 );\n+ low = ( ctx->total[0] << 3 );\n+\n+ PUT_UINT64_BE( high, msglen, 0 );\n+ PUT_UINT64_BE( low, msglen, 8 );\n+\n+ last = (size_t)( ctx->total[0] & 0x7F );\n+ padn = ( last < 112 ) ? ( 112 - last ) : ( 240 - last );\n+\n+ mbedtls_sha512_update( ctx, sha512_padding, padn );\n+ mbedtls_sha512_update( ctx, msglen, 16 );\n+\n+ PUT_UINT64_BE( ctx->state[0], output, 0 );\n+ PUT_UINT64_BE( ctx->state[1], output, 8 );\n+ PUT_UINT64_BE( ctx->state[2], output, 16 );\n+ PUT_UINT64_BE( ctx->state[3], output, 24 );\n+ PUT_UINT64_BE( ctx->state[4], output, 32 );\n+ PUT_UINT64_BE( ctx->state[5], output, 40 );\n+\n+ if( ctx->is384 == 0 )\n+ {\n+ PUT_UINT64_BE( ctx->state[6], output, 48 );\n+ PUT_UINT64_BE( ctx->state[7], output, 56 );\n+ }\n+}\n+\n+#endif /* !MBEDTLS_SHA512_ALT */\n+\n+/*\n+ * output = SHA-512( input buffer )\n+ */\n+void mbedtls_sha512( const unsigned char *input, size_t ilen,\n+ unsigned char output[64], int is384 )\n+{\n+ mbedtls_sha512_context ctx;\n+\n+ mbedtls_sha512_init( &ctx );\n+ mbedtls_sha512_starts( &ctx, is384 );\n+ mbedtls_sha512_update( &ctx, input, ilen );\n+ mbedtls_sha512_finish( &ctx, output );\n+ mbedtls_sha512_free( &ctx );\n+}\n+\n+#if defined(MBEDTLS_SELF_TEST)\n+\n+/*\n+ * FIPS-180-2 test vectors\n+ */\n+static const unsigned char sha512_test_buf[3][113] =\n+{\n+ { \"abc\" },\n+ { \"abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn\"\n+ \"hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu\" },\n+ { \"\" }\n+};\n+\n+static const int sha512_test_buflen[3] =\n+{\n+ 3, 112, 1000\n+};\n+\n+static const unsigned char sha512_test_sum[6][64] =\n+{\n+ /*\n+ * SHA-384 test vectors\n+ */\n+ { 0xCB, 0x00, 0x75, 0x3F, 0x45, 0xA3, 0x5E, 0x8B,\n+ 0xB5, 0xA0, 0x3D, 0x69, 0x9A, 0xC6, 0x50, 0x07,\n+ 0x27, 0x2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en, ret = 0;\n+ unsigned char buf[1024];\n+ unsigned char sha512sum[64];\n+ mbedtls_sha512_context ctx;\n+\n+ mbedtls_sha512_init( &ctx );\n+\n+ for( i = 0; i < 6; i++ )\n+ {\n+ j = i % 3;\n+ k = i < 3;\n+\n+ if( verbose != 0 )\n+ mbedtls_printf( \" SHA-%d test #%d: \", 512 - k * 128, j + 1 );\n+\n+ mbedtls_sha512_starts( &ctx, k );\n+\n+ if( j == 2 )\n+ {\n+ memset( buf, 'a', buflen = 1000 );\n+\n+ for( j = 0; j < 1000; j++ )\n+ mbedtls_sha512_update( &ctx, buf, buflen );\n+ }\n+ else\n+ mbedtls_sha512_update( &ctx, sha512_test_buf[j],\n+ sha512_test_buflen[j] );\n+\n+ mbedtls_sha512_finish( &ctx, sha512sum );\n+\n+ if( memcmp( sha512sum, sha512_test_sum[i], 64 - k * 16 ) != 0 )\n+ {\n+ if( verbose != 0 )\n+ mbedtls_printf( \"failed\\n\" );\n+\n+ ret = 1;\n+ goto exit;\n+ }\n+\n+ if( verbose != 0 )\n+ mbedtls_printf( \"passed\\n\" );\n+ }\n+\n+ if( verbose != 0 )\n+ mbedtls_printf( \"\\n\" );\n+\n+exit:\n+ mbedtls_sha512_free( &ctx );\n+\n+ return( ret );\n+}\n+\n+#endif /* MBEDTLS_SELF_TEST */\ndiff --git a/libstb/mbedtls/sha512.h b/libstb/mbedtls/sha512.h\nnew file mode 100644\nindex 0000000..627694f\n--- /dev/null\n+++ b/libstb/mbedtls/sha512.h\n@@ -0,0 +1,141 @@\n+/**\n+ * \\file sha512.h\n+ *\n+ * \\brief SHA-384 and SHA-512 cryptographic hash function\n+ *\n+ * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved\n+ * SPDX-License-Identifier: Apache-2.0\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n+ * not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ * http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ *\n+ * This file is part of mbed TLS (https://tls.mbed.org)\n+ */\n+#ifndef MBEDTLS_SHA512_H\n+#define MBEDTLS_SHA512_H\n+\n+#if !defined(MBEDTLS_CONFIG_FILE)\n+#include \"config.h\"\n+#else\n+#include MBEDTLS_CONFIG_FILE\n+#endif\n+\n+#include <stddef.h>\n+#include <stdint.h>\n+\n+#if !defined(MBEDTLS_SHA512_ALT)\n+// Regular implementation\n+//\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+/**\n+ * \\brief SHA-512 context structure\n+ */\n+typedef struct\n+{\n+ uint64_t total[2]; /*!< number of bytes processed */\n+ uint64_t state[8]; /*!< intermediate digest state */\n+ unsigned char buffer[128]; /*!< data block being processed */\n+ int is384; /*!< 0 => SHA-512, else SHA-384 */\n+}\n+mbedtls_sha512_context;\n+\n+/**\n+ * \\brief Initialize SHA-512 context\n+ *\n+ * \\param ctx SHA-512 context to be initialized\n+ */\n+void mbedtls_sha512_init( mbedtls_sha512_context *ctx );\n+\n+/**\n+ * \\brief Clear SHA-512 context\n+ *\n+ * \\param ctx SHA-512 context to be cleared\n+ */\n+void mbedtls_sha512_free( mbedtls_sha512_context *ctx );\n+\n+/**\n+ * \\brief Clone (the state of) a SHA-512 context\n+ *\n+ * \\param dst The destination context\n+ * \\param src The context to be cloned\n+ */\n+void mbedtls_sha512_clone( mbedtls_sha512_context *dst,\n+ const mbedtls_sha512_context *src );\n+\n+/**\n+ * \\brief SHA-512 context setup\n+ *\n+ * \\param ctx context to be initialized\n+ * \\param is384 0 = use SHA512, 1 = use SHA384\n+ */\n+void mbedtls_sha512_starts( mbedtls_sha512_context *ctx, int is384 );\n+\n+/**\n+ * \\brief SHA-512 process buffer\n+ *\n+ * \\param ctx SHA-512 context\n+ * \\param input buffer holding the data\n+ * \\param ilen length of the input data\n+ */\n+void mbedtls_sha512_update( mbedtls_sha512_context *ctx, const unsigned char *input,\n+ size_t ilen );\n+\n+/**\n+ * \\brief SHA-512 final digest\n+ *\n+ * \\param ctx SHA-512 context\n+ * \\param output SHA-384/512 checksum result\n+ */\n+void mbedtls_sha512_finish( mbedtls_sha512_context *ctx, unsigned char output[64] );\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#else /* MBEDTLS_SHA512_ALT */\n+#include \"sha512_alt.h\"\n+#endif /* MBEDTLS_SHA512_ALT */\n+\n+#ifdef __cplusplus\n+extern \"C\" {\n+#endif\n+\n+/**\n+ * \\brief Output = SHA-512( input buffer )\n+ *\n+ * \\param input buffer holding the data\n+ * \\param ilen length of the input data\n+ * \\param output SHA-384/512 checksum result\n+ * \\param is384 0 = use SHA512, 1 = use SHA384\n+ */\n+void mbedtls_sha512( const unsigned char *input, size_t ilen,\n+ unsigned char output[64], int is384 );\n+\n+/**\n+ * \\brief Checkup routine\n+ *\n+ * \\return 0 if successful, or 1 if the test failed\n+ */\n+int mbedtls_sha512_self_test( int verbose );\n+\n+/* Internal use */\n+void mbedtls_sha512_process( mbedtls_sha512_context *ctx, const unsigned char data[128] );\n+\n+#ifdef __cplusplus\n+}\n+#endif\n+\n+#endif /* mbedtls_sha512.h */\n", "prefixes": [ "v2", "08/14" ] }