From: Loic Poulain <loic.poulain@linaro.org>
To: trini@konsulko.com
Cc: u-boot@lists.denx.de, michal.simek@xilinx.com,
kettenis@openbsd.org, Loic Poulain <loic.poulain@linaro.org>
Subject: [PATCH v2 1/5] lib: sha1: Add support for hardware specific sha1_process
Date: Wed, 1 Jun 2022 20:26:27 +0200 [thread overview]
Message-ID: <1654107991-598-2-git-send-email-loic.poulain@linaro.org> (raw)
In-Reply-To: <1654107991-598-1-git-send-email-loic.poulain@linaro.org>
Mark sha1_process as weak to allow hardware specific implementation.
Add parameter to support for multiple blocks processing.
Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
---
lib/sha1.c | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/lib/sha1.c b/lib/sha1.c
index 8154e1e..e5e42bc 100644
--- a/lib/sha1.c
+++ b/lib/sha1.c
@@ -25,6 +25,8 @@
#include <watchdog.h>
#include <u-boot/sha1.h>
+#include <linux/compiler_attributes.h>
+
const uint8_t sha1_der_prefix[SHA1_DER_LEN] = {
0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0e,
0x03, 0x02, 0x1a, 0x05, 0x00, 0x04, 0x14
@@ -65,7 +67,7 @@ void sha1_starts (sha1_context * ctx)
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;
@@ -219,6 +221,18 @@ static void sha1_process(sha1_context *ctx, const unsigned char data[64])
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
*/
@@ -242,17 +256,15 @@ void sha1_update(sha1_context *ctx, const unsigned char *input,
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);
--
2.7.4
next prev parent reply other threads:[~2022-06-01 18:27 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-01 18:26 [PATCH v2 0/5] Add ARMv8 CE sha1/sha256 support Loic Poulain
2022-06-01 18:26 ` Loic Poulain [this message]
2022-06-27 21:30 ` [PATCH v2 1/5] lib: sha1: Add support for hardware specific sha1_process Tom Rini
2022-06-01 18:26 ` [PATCH v2 2/5] sha1: Fix digest state size/type Loic Poulain
2022-06-27 21:31 ` Tom Rini
2022-06-01 18:26 ` [PATCH v2 3/5] armv8 SHA-1 using ARMv8 Crypto Extensions: Loic Poulain
2022-06-27 21:31 ` Tom Rini
2022-06-01 18:26 ` [PATCH v2 4/5] lib: sha256: Add support for hardware specific sha256_process Loic Poulain
2022-06-27 21:31 ` Tom Rini
2023-02-06 17:12 ` Simon Glass
2023-02-06 22:12 ` Loic Poulain
2023-02-07 4:02 ` Simon Glass
2023-02-07 21:47 ` Loic Poulain
2023-02-07 22:25 ` Simon Glass
2023-02-08 0:10 ` Tom Rini
2023-02-08 18:28 ` Simon Glass
2023-02-08 18:38 ` Tom Rini
2022-06-01 18:26 ` [PATCH v2 5/5] armv8 SHA-256 using ARMv8 Crypto Extensions Loic Poulain
2022-06-23 19:51 ` [PATCH] qemu_arm64: Enable CONFIG_ARMV8_CRYPTO support Tom Rini
2022-06-27 21:31 ` Tom Rini
2022-06-27 21:31 ` [PATCH v2 5/5] armv8 SHA-256 using ARMv8 Crypto Extensions Tom Rini
2022-06-15 23:04 ` [PATCH v2 0/5] Add ARMv8 CE sha1/sha256 support Loic Poulain
2022-06-16 14:39 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1654107991-598-2-git-send-email-loic.poulain@linaro.org \
--to=loic.poulain@linaro.org \
--cc=kettenis@openbsd.org \
--cc=michal.simek@xilinx.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.