From 9df731a176aab8e03b984b681b1bea01ccff6644 Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Mon, 06 Nov 2023 07:23:06 +0000 Subject: [PATCH] rk3568 rt uboot init --- u-boot/lib/sha1.c | 33 ++++++++++++++++++++++++++------- 1 files changed, 26 insertions(+), 7 deletions(-) diff --git a/u-boot/lib/sha1.c b/u-boot/lib/sha1.c index f54bb5b..399607a 100644 --- a/u-boot/lib/sha1.c +++ b/u-boot/lib/sha1.c @@ -26,6 +26,15 @@ #include <watchdog.h> #include <u-boot/sha1.h> +#include <linux/compiler.h> + +#ifdef USE_HOSTCC +#undef __weak +#define __weak +#undef __maybe_unused +#define __maybe_unused +#endif + const uint8_t sha1_der_prefix[SHA1_DER_LEN] = { 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e, 0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14 @@ -66,7 +75,7 @@ ctx->state[4] = 0xC3D2E1F0; } -static void sha1_process(sha1_context *ctx, const unsigned char data[64]) +static void __maybe_unused sha1_process_one(sha1_context *ctx, const unsigned char data[64]) { unsigned long temp, W[16], A, B, C, D, E; @@ -220,6 +229,18 @@ ctx->state[4] += E; } +__weak void sha1_process(sha1_context *ctx, const unsigned char *data, + unsigned int blocks) +{ + if (!blocks) + return; + + while (blocks--) { + sha1_process_one(ctx, data); + data += 64; + } +} + /* * SHA-1 process buffer */ @@ -243,17 +264,15 @@ if (left && ilen >= fill) { memcpy ((void *) (ctx->buffer + left), (void *) input, fill); - sha1_process (ctx, ctx->buffer); + sha1_process(ctx, ctx->buffer, 1); input += fill; ilen -= fill; left = 0; } - while (ilen >= 64) { - sha1_process (ctx, input); - input += 64; - ilen -= 64; - } + sha1_process(ctx, input, ilen / 64); + input += ilen / 64 * 64; + ilen = ilen % 64; if (ilen > 0) { memcpy ((void *) (ctx->buffer + left), (void *) input, ilen); -- Gitblit v1.6.2