From 1f93a7dfd1f8d5ff7a5c53246c7534fe2332d6f4 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Mon, 11 Dec 2023 02:46:07 +0000
Subject: [PATCH] add audio
---
u-boot/lib/avb/libavb/avb_sha512.c | 59 +++++++++++++++++++++++++++++++----------------------------
1 files changed, 31 insertions(+), 28 deletions(-)
diff --git a/u-boot/lib/avb/libavb/avb_sha512.c b/u-boot/lib/avb/libavb/avb_sha512.c
index d3e437b..2cdd6ca 100644
--- a/u-boot/lib/avb/libavb/avb_sha512.c
+++ b/u-boot/lib/avb/libavb/avb_sha512.c
@@ -38,33 +38,6 @@
#include <android_avb/avb_sha.h>
#include <android_avb/avb_util.h>
-/* Crypto-v1 is not support sha512 */
-#ifdef CONFIG_ROCKCHIP_CRYPTO_V2
-void avb_sha512_init(AvbSHA512Ctx* ctx) {
- ctx->crypto_ctx.algo = CRYPTO_SHA512;
- ctx->crypto_ctx.length = ctx->tot_len;
- memset(ctx->buf, 0, sizeof(ctx->buf));
-
- ctx->crypto_dev = crypto_get_device(ctx->crypto_ctx.algo);
- if (!ctx->crypto_dev)
- avb_error("Can't get sha512 crypto device\n");
- else
- crypto_sha_init(ctx->crypto_dev, &ctx->crypto_ctx);
-}
-
-void avb_sha512_update(AvbSHA512Ctx* ctx, const uint8_t* data, size_t len) {
- if (ctx->crypto_dev)
- crypto_sha_update(ctx->crypto_dev, (u32 *)data, len);
-}
-
-uint8_t* avb_sha512_final(AvbSHA512Ctx* ctx) {
- if (ctx->crypto_dev)
- crypto_sha_final(ctx->crypto_dev, &ctx->crypto_ctx, ctx->buf);
-
- return ctx->buf;
-}
-
-#else
#define SHFR(x, n) (x >> n)
#define ROTR(x, n) ((x >> n) | (x << ((sizeof(x) << 3) - n)))
#define ROTL(x, n) ((x << n) | (x >> ((sizeof(x) << 3) - n)))
@@ -160,6 +133,19 @@
/* SHA-512 implementation */
void avb_sha512_init(AvbSHA512Ctx* ctx) {
+/* Crypto-v1 is not support sha512 */
+#ifdef CONFIG_ROCKCHIP_CRYPTO_V2
+ ctx->crypto_ctx.algo = CRYPTO_SHA512;
+ ctx->crypto_ctx.length = ctx->tot_len;
+ memset(ctx->buf, 0, sizeof(ctx->buf));
+
+ ctx->crypto_dev = crypto_get_device(ctx->crypto_ctx.algo);
+ /* If there is no available crypto device, calculate in software instead. */
+ if (ctx->crypto_dev) {
+ crypto_sha_init(ctx->crypto_dev, &ctx->crypto_ctx);
+ return;
+ }
+#endif
#ifdef UNROLL_LOOPS_SHA512
ctx->h[0] = sha512_h0[0];
ctx->h[1] = sha512_h0[1];
@@ -347,6 +333,15 @@
}
void avb_sha512_update(AvbSHA512Ctx* ctx, const uint8_t* data, size_t len) {
+/* Crypto-v1 is not support sha512 */
+#ifdef CONFIG_ROCKCHIP_CRYPTO_V2
+ /* If there is no available crypto device, calculate in software instead. */
+ if (ctx->crypto_dev) {
+ crypto_sha_update(ctx->crypto_dev, (u32 *)data, len);
+ return;
+ }
+#endif
+
size_t block_nb;
size_t new_len, rem_len, tmp_len;
const uint8_t* shifted_data;
@@ -378,6 +373,15 @@
}
uint8_t* avb_sha512_final(AvbSHA512Ctx* ctx) {
+/* Crypto-v1 is not support sha512 */
+#ifdef CONFIG_ROCKCHIP_CRYPTO_V2
+ /* If there is no available crypto device, calculate in software instead. */
+ if (ctx->crypto_dev) {
+ crypto_sha_final(ctx->crypto_dev, &ctx->crypto_ctx, ctx->buf);
+ return ctx->buf;
+ }
+#endif
+
size_t block_nb;
size_t pm_len;
uint64_t len_b;
@@ -414,4 +418,3 @@
return ctx->buf;
}
-#endif
--
Gitblit v1.6.2