From: Charles Manning <cdhmanning@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] mkimage: Refactor mxsimage to use common crc32 code
Date: Tue, 6 May 2014 10:46:46 +1200 [thread overview]
Message-ID: <1399330006-3376-3-git-send-email-cdhmanning@gmail.com> (raw)
In-Reply-To: <1399330006-3376-1-git-send-email-cdhmanning@gmail.com>
mxsimage uses the same crc32 function as pblimage.
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
---
tools/mxsimage.c | 28 +++-------------------------
1 file changed, 3 insertions(+), 25 deletions(-)
diff --git a/tools/mxsimage.c b/tools/mxsimage.c
index 045b35a..0c4348c 100644
--- a/tools/mxsimage.c
+++ b/tools/mxsimage.c
@@ -19,6 +19,7 @@
#include "imagetool.h"
#include "mxsimage.h"
+#include "pbl_crc32.h"
#include <image.h>
@@ -231,29 +232,6 @@ static int sb_aes_reinit(struct sb_image_ctx *ictx, int enc)
}
/*
- * CRC32
- */
-static uint32_t crc32(uint8_t *data, uint32_t len)
-{
- const uint32_t poly = 0x04c11db7;
- uint32_t crc32 = 0xffffffff;
- unsigned int byte, bit;
-
- for (byte = 0; byte < len; byte++) {
- crc32 ^= data[byte] << 24;
-
- for (bit = 8; bit > 0; bit--) {
- if (crc32 & (1UL << 31))
- crc32 = (crc32 << 1) ^ poly;
- else
- crc32 = (crc32 << 1);
- }
- }
-
- return crc32;
-}
-
-/*
* Debug
*/
static void soprintf(struct sb_image_ctx *ictx, const char *fmt, ...)
@@ -998,7 +976,7 @@ static int sb_build_command_load(struct sb_image_ctx *ictx,
ccmd->load.address = dest;
ccmd->load.count = cctx->length;
- ccmd->load.crc32 = crc32(cctx->data, cctx->length);
+ ccmd->load.crc32 = pbl_crc32(0, cctx->data, cctx->length);
cctx->size = sizeof(*ccmd) + cctx->length;
@@ -1834,7 +1812,7 @@ static int sb_verify_command(struct sb_image_ctx *ictx,
EVP_DigestUpdate(&ictx->md_ctx, cctx->data, asize);
sb_aes_crypt(ictx, cctx->data, cctx->data, asize);
- if (ccmd->load.crc32 != crc32(cctx->data, asize)) {
+ if (ccmd->load.crc32 != pbl_crc32(0, cctx->data, asize)) {
fprintf(stderr,
"ERR: SB LOAD command payload CRC32 invalid!\n");
return -EINVAL;
--
1.7.9.5
next prev parent reply other threads:[~2014-05-05 22:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-05 22:46 [U-Boot] [PATCH 0/2] mkimage: Refactor and clean up 32-bit crcs Charles Manning
2014-05-05 22:46 ` [U-Boot] [PATCH 1/2] mkimage : Split out and clean pbl_crc32 for use by other image types Charles Manning
2014-05-06 8:10 ` Stefano Babic
2014-05-05 22:46 ` Charles Manning [this message]
2014-05-06 8:11 ` [U-Boot] [PATCH 2/2] mkimage: Refactor mxsimage to use common crc32 code Stefano Babic
2014-05-12 20:26 ` [U-Boot] [U-Boot, " Tom Rini
2014-05-13 7:27 ` Charles Manning
2014-05-13 21:08 ` Tom Rini
2014-05-14 2:44 ` [U-Boot] [PATCH v2 0/2] mkimage: Refactor and clean up 32-bit crcs Charles Manning
2014-05-14 2:45 ` [U-Boot] [PATCH v2 1/2] mkimage : Split out and clean pbl_crc32 for use by other image types Charles Manning
2014-06-05 22:46 ` [U-Boot] [U-Boot, v2, " Tom Rini
2014-05-14 2:45 ` [U-Boot] [PATCH v2 2/2] tools: Refactor mxsimage to use pbl_crc32 Charles Manning
2014-06-05 22:46 ` [U-Boot] [U-Boot, v2, " 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=1399330006-3376-3-git-send-email-cdhmanning@gmail.com \
--to=cdhmanning@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox