blob: ff4986a6190269ed4659685fd9cb77d8c423fae2 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Simon Glass460408e2012-12-05 14:46:36 +00002/*
3 * Copyright (c) 2012 The Chromium OS Authors.
4 *
5 * (C) Copyright 2011
6 * Joe Hershberger, National Instruments, joe.hershberger@ni.com
7 *
8 * (C) Copyright 2000
9 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Simon Glass460408e2012-12-05 14:46:36 +000010 */
11
Ruchika Gupta2dd90022015-01-23 16:01:58 +053012#ifndef USE_HOSTCC
Simon Glass460408e2012-12-05 14:46:36 +000013#include <common.h>
14#include <command.h>
Simon Glass9fb625c2019-08-01 09:46:51 -060015#include <env.h>
Hung-ying Tyanbf007eb2014-03-03 12:19:28 +010016#include <malloc.h>
Joe Hershberger0eb25b62015-03-22 17:08:59 -050017#include <mapmem.h>
Akshay Saraswat1f9c9282013-03-20 21:00:58 +000018#include <hw_sha.h>
Simon Glassbd091b62013-02-24 17:33:31 +000019#include <asm/io.h>
Masahiro Yamada1221ce42016-09-21 11:28:55 +090020#include <linux/errno.h>
Simon Glass3db71102019-11-14 12:57:16 -070021#include <u-boot/crc.h>
Ruchika Gupta2dd90022015-01-23 16:01:58 +053022#else
23#include "mkimage.h"
24#include <time.h>
25#include <image.h>
26#endif /* !USE_HOSTCC*/
27
28#include <hash.h>
29#include <u-boot/crc.h>
30#include <u-boot/sha1.h>
31#include <u-boot/sha256.h>
32#include <u-boot/md5.h>
Simon Glass460408e2012-12-05 14:46:36 +000033
T Karthik Reddy10088fb2019-03-16 15:23:01 +053034#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
35DECLARE_GLOBAL_DATA_PTR;
36#endif
37
38static void reloc_update(void);
39
Tom Rini78eda892017-08-14 16:38:07 -040040#if defined(CONFIG_SHA1) && !defined(CONFIG_SHA_PROG_HW_ACCEL)
Hung-ying Tyanbf007eb2014-03-03 12:19:28 +010041static int hash_init_sha1(struct hash_algo *algo, void **ctxp)
42{
43 sha1_context *ctx = malloc(sizeof(sha1_context));
44 sha1_starts(ctx);
45 *ctxp = ctx;
46 return 0;
47}
48
49static int hash_update_sha1(struct hash_algo *algo, void *ctx, const void *buf,
50 unsigned int size, int is_last)
51{
52 sha1_update((sha1_context *)ctx, buf, size);
53 return 0;
54}
55
56static int hash_finish_sha1(struct hash_algo *algo, void *ctx, void *dest_buf,
57 int size)
58{
59 if (size < algo->digest_size)
60 return -1;
61
62 sha1_finish((sha1_context *)ctx, dest_buf);
63 free(ctx);
64 return 0;
65}
66#endif
67
Tom Rini78eda892017-08-14 16:38:07 -040068#if defined(CONFIG_SHA256) && !defined(CONFIG_SHA_PROG_HW_ACCEL)
Hung-ying Tyanbf007eb2014-03-03 12:19:28 +010069static int hash_init_sha256(struct hash_algo *algo, void **ctxp)
70{
71 sha256_context *ctx = malloc(sizeof(sha256_context));
72 sha256_starts(ctx);
73 *ctxp = ctx;
74 return 0;
75}
76
77static int hash_update_sha256(struct hash_algo *algo, void *ctx,
78 const void *buf, unsigned int size, int is_last)
79{
80 sha256_update((sha256_context *)ctx, buf, size);
81 return 0;
82}
83
84static int hash_finish_sha256(struct hash_algo *algo, void *ctx, void
85 *dest_buf, int size)
86{
87 if (size < algo->digest_size)
88 return -1;
89
90 sha256_finish((sha256_context *)ctx, dest_buf);
91 free(ctx);
92 return 0;
93}
94#endif
95
Philipp Tomsich51c23452018-11-25 19:22:19 +010096static int hash_init_crc16_ccitt(struct hash_algo *algo, void **ctxp)
97{
98 uint16_t *ctx = malloc(sizeof(uint16_t));
99 *ctx = 0;
100 *ctxp = ctx;
101 return 0;
102}
103
104static int hash_update_crc16_ccitt(struct hash_algo *algo, void *ctx,
105 const void *buf, unsigned int size,
106 int is_last)
107{
108 *((uint16_t *)ctx) = crc16_ccitt(*((uint16_t *)ctx), buf, size);
109 return 0;
110}
111
112static int hash_finish_crc16_ccitt(struct hash_algo *algo, void *ctx,
113 void *dest_buf, int size)
114{
115 if (size < algo->digest_size)
116 return -1;
117
118 *((uint16_t *)dest_buf) = *((uint16_t *)ctx);
119 free(ctx);
120 return 0;
121}
122
Hung-ying Tyanbf007eb2014-03-03 12:19:28 +0100123static int hash_init_crc32(struct hash_algo *algo, void **ctxp)
124{
125 uint32_t *ctx = malloc(sizeof(uint32_t));
126 *ctx = 0;
127 *ctxp = ctx;
128 return 0;
129}
130
131static int hash_update_crc32(struct hash_algo *algo, void *ctx,
132 const void *buf, unsigned int size, int is_last)
133{
134 *((uint32_t *)ctx) = crc32(*((uint32_t *)ctx), buf, size);
135 return 0;
136}
137
138static int hash_finish_crc32(struct hash_algo *algo, void *ctx, void *dest_buf,
139 int size)
140{
141 if (size < algo->digest_size)
142 return -1;
143
144 *((uint32_t *)dest_buf) = *((uint32_t *)ctx);
145 free(ctx);
146 return 0;
147}
148
Simon Glass460408e2012-12-05 14:46:36 +0000149/*
Tom Rini78eda892017-08-14 16:38:07 -0400150 * These are the hash algorithms we support. If we have hardware acceleration
151 * is enable we will use that, otherwise a software version of the algorithm.
152 * Note that algorithm names must be in lower case.
Simon Glass460408e2012-12-05 14:46:36 +0000153 */
154static struct hash_algo hash_algo[] = {
Ruchika Gupta46fe2c02015-01-23 16:01:57 +0530155#ifdef CONFIG_SHA1
Simon Glass460408e2012-12-05 14:46:36 +0000156 {
Tom Rini78eda892017-08-14 16:38:07 -0400157 .name = "sha1",
158 .digest_size = SHA1_SUM_LEN,
159 .chunk_size = CHUNKSZ_SHA1,
160#ifdef CONFIG_SHA_HW_ACCEL
161 .hash_func_ws = hw_sha1,
162#else
163 .hash_func_ws = sha1_csum_wd,
164#endif
165#ifdef CONFIG_SHA_PROG_HW_ACCEL
166 .hash_init = hw_sha_init,
167 .hash_update = hw_sha_update,
168 .hash_finish = hw_sha_finish,
169#else
170 .hash_init = hash_init_sha1,
171 .hash_update = hash_update_sha1,
172 .hash_finish = hash_finish_sha1,
173#endif
Simon Glass460408e2012-12-05 14:46:36 +0000174 },
175#endif
176#ifdef CONFIG_SHA256
177 {
Tom Rini78eda892017-08-14 16:38:07 -0400178 .name = "sha256",
179 .digest_size = SHA256_SUM_LEN,
180 .chunk_size = CHUNKSZ_SHA256,
181#ifdef CONFIG_SHA_HW_ACCEL
182 .hash_func_ws = hw_sha256,
183#else
184 .hash_func_ws = sha256_csum_wd,
185#endif
186#ifdef CONFIG_SHA_PROG_HW_ACCEL
187 .hash_init = hw_sha_init,
188 .hash_update = hw_sha_update,
189 .hash_finish = hw_sha_finish,
190#else
191 .hash_init = hash_init_sha256,
192 .hash_update = hash_update_sha256,
193 .hash_finish = hash_finish_sha256,
194#endif
Simon Glass460408e2012-12-05 14:46:36 +0000195 },
196#endif
Simon Glassd20a40d2013-02-24 20:30:22 +0000197 {
Philipp Tomsich51c23452018-11-25 19:22:19 +0100198 .name = "crc16-ccitt",
199 .digest_size = 2,
200 .chunk_size = CHUNKSZ,
201 .hash_func_ws = crc16_ccitt_wd_buf,
202 .hash_init = hash_init_crc16_ccitt,
203 .hash_update = hash_update_crc16_ccitt,
204 .hash_finish = hash_finish_crc16_ccitt,
205 },
206 {
Tom Rini78eda892017-08-14 16:38:07 -0400207 .name = "crc32",
208 .digest_size = 4,
209 .chunk_size = CHUNKSZ_CRC32,
210 .hash_func_ws = crc32_wd_buf,
211 .hash_init = hash_init_crc32,
212 .hash_update = hash_update_crc32,
213 .hash_finish = hash_finish_crc32,
Simon Glassd20a40d2013-02-24 20:30:22 +0000214 },
Simon Glass460408e2012-12-05 14:46:36 +0000215};
216
Simon Glassd20a40d2013-02-24 20:30:22 +0000217/* Try to minimize code size for boards that don't want much hashing */
Daniel Thompson221a9492017-05-19 17:26:58 +0100218#if defined(CONFIG_SHA256) || defined(CONFIG_CMD_SHA1SUM) || \
219 defined(CONFIG_CRC32_VERIFY) || defined(CONFIG_CMD_HASH)
Simon Glassd20a40d2013-02-24 20:30:22 +0000220#define multi_hash() 1
221#else
222#define multi_hash() 0
223#endif
224
T Karthik Reddy10088fb2019-03-16 15:23:01 +0530225static void reloc_update(void)
226{
227#if !defined(USE_HOSTCC) && defined(CONFIG_NEEDS_MANUAL_RELOC)
228 int i;
229 static bool done;
230
231 if (!done) {
232 done = true;
233 for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
234 hash_algo[i].name += gd->reloc_off;
235 hash_algo[i].hash_func_ws += gd->reloc_off;
236 hash_algo[i].hash_init += gd->reloc_off;
237 hash_algo[i].hash_update += gd->reloc_off;
238 hash_algo[i].hash_finish += gd->reloc_off;
239 }
240 }
241#endif
242}
243
Ruchika Gupta2dd90022015-01-23 16:01:58 +0530244int hash_lookup_algo(const char *algo_name, struct hash_algo **algop)
245{
246 int i;
247
T Karthik Reddy10088fb2019-03-16 15:23:01 +0530248 reloc_update();
249
Ruchika Gupta2dd90022015-01-23 16:01:58 +0530250 for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
251 if (!strcmp(algo_name, hash_algo[i].name)) {
252 *algop = &hash_algo[i];
253 return 0;
254 }
255 }
256
257 debug("Unknown hash algorithm '%s'\n", algo_name);
258 return -EPROTONOSUPPORT;
259}
260
261int hash_progressive_lookup_algo(const char *algo_name,
262 struct hash_algo **algop)
263{
264 int i;
265
T Karthik Reddy10088fb2019-03-16 15:23:01 +0530266 reloc_update();
267
Ruchika Gupta2dd90022015-01-23 16:01:58 +0530268 for (i = 0; i < ARRAY_SIZE(hash_algo); i++) {
269 if (!strcmp(algo_name, hash_algo[i].name)) {
270 if (hash_algo[i].hash_init) {
271 *algop = &hash_algo[i];
272 return 0;
273 }
274 }
275 }
276
277 debug("Unknown hash algorithm '%s'\n", algo_name);
278 return -EPROTONOSUPPORT;
279}
280
281#ifndef USE_HOSTCC
Stefan Roese8f0b1e22015-05-18 14:08:24 +0200282int hash_parse_string(const char *algo_name, const char *str, uint8_t *result)
283{
284 struct hash_algo *algo;
285 int ret;
286 int i;
287
288 ret = hash_lookup_algo(algo_name, &algo);
289 if (ret)
290 return ret;
291
292 for (i = 0; i < algo->digest_size; i++) {
293 char chr[3];
294
295 strncpy(chr, &str[i * 2], 2);
296 result[i] = simple_strtoul(chr, NULL, 16);
297 }
298
299 return 0;
300}
301
Tom Rini48ad68d2016-01-05 08:47:48 -0500302int hash_block(const char *algo_name, const void *data, unsigned int len,
303 uint8_t *output, int *output_size)
304{
305 struct hash_algo *algo;
306 int ret;
307
308 ret = hash_lookup_algo(algo_name, &algo);
309 if (ret)
310 return ret;
311
312 if (output_size && *output_size < algo->digest_size) {
313 debug("Output buffer size %d too small (need %d bytes)",
314 *output_size, algo->digest_size);
315 return -ENOSPC;
316 }
317 if (output_size)
318 *output_size = algo->digest_size;
319 algo->hash_func_ws(data, len, output, algo->chunk_size);
320
321 return 0;
322}
323
324#if defined(CONFIG_CMD_HASH) || defined(CONFIG_CMD_SHA1SUM) || defined(CONFIG_CMD_CRC32)
Simon Glass460408e2012-12-05 14:46:36 +0000325/**
326 * store_result: Store the resulting sum to an address or variable
327 *
328 * @algo: Hash algorithm being used
329 * @sum: Hash digest (algo->digest_size bytes)
330 * @dest: Destination, interpreted as a hex address if it starts
Simon Glassd5b76672013-02-24 17:33:26 +0000331 * with * (or allow_env_vars is 0) or otherwise as an
332 * environment variable.
333 * @allow_env_vars: non-zero to permit storing the result to an
334 * variable environment
Simon Glass460408e2012-12-05 14:46:36 +0000335 */
Simon Glass04819a42014-06-12 07:24:41 -0600336static void store_result(struct hash_algo *algo, const uint8_t *sum,
Simon Glassd5b76672013-02-24 17:33:26 +0000337 const char *dest, int allow_env_vars)
Simon Glass460408e2012-12-05 14:46:36 +0000338{
339 unsigned int i;
Simon Glassd5b76672013-02-24 17:33:26 +0000340 int env_var = 0;
Simon Glass460408e2012-12-05 14:46:36 +0000341
Simon Glassd5b76672013-02-24 17:33:26 +0000342 /*
343 * If environment variables are allowed, then we assume that 'dest'
344 * is an environment variable, unless it starts with *, in which
345 * case we assume it is an address. If not allowed, it is always an
346 * address. This is to support the crc32 command.
347 */
348 if (allow_env_vars) {
349 if (*dest == '*')
350 dest++;
351 else
352 env_var = 1;
353 }
Simon Glass460408e2012-12-05 14:46:36 +0000354
Simon Glassd5b76672013-02-24 17:33:26 +0000355 if (env_var) {
Simon Glass460408e2012-12-05 14:46:36 +0000356 char str_output[HASH_MAX_DIGEST_SIZE * 2 + 1];
357 char *str_ptr = str_output;
358
359 for (i = 0; i < algo->digest_size; i++) {
360 sprintf(str_ptr, "%02x", sum[i]);
361 str_ptr += 2;
362 }
Jeroen Hofstee8b9cc862014-06-09 11:02:02 +0200363 *str_ptr = '\0';
Simon Glass382bee52017-08-03 12:22:09 -0600364 env_set(dest, str_output);
Simon Glassd5b76672013-02-24 17:33:26 +0000365 } else {
Simon Glassbd091b62013-02-24 17:33:31 +0000366 ulong addr;
367 void *buf;
Simon Glassd5b76672013-02-24 17:33:26 +0000368
Simon Glassbd091b62013-02-24 17:33:31 +0000369 addr = simple_strtoul(dest, NULL, 16);
370 buf = map_sysmem(addr, algo->digest_size);
371 memcpy(buf, sum, algo->digest_size);
372 unmap_sysmem(buf);
Simon Glass460408e2012-12-05 14:46:36 +0000373 }
374}
375
376/**
377 * parse_verify_sum: Parse a hash verification parameter
378 *
379 * @algo: Hash algorithm being used
380 * @verify_str: Argument to parse. If it starts with * then it is
381 * interpreted as a hex address containing the hash.
382 * If the length is exactly the right number of hex digits
383 * for the digest size, then we assume it is a hex digest.
384 * Otherwise we assume it is an environment variable, and
385 * look up its value (it must contain a hex digest).
386 * @vsum: Returns binary digest value (algo->digest_size bytes)
Simon Glassd5b76672013-02-24 17:33:26 +0000387 * @allow_env_vars: non-zero to permit storing the result to an environment
388 * variable. If 0 then verify_str is assumed to be an
389 * address, and the * prefix is not expected.
Simon Glass460408e2012-12-05 14:46:36 +0000390 * @return 0 if ok, non-zero on error
391 */
Simon Glass04819a42014-06-12 07:24:41 -0600392static int parse_verify_sum(struct hash_algo *algo, char *verify_str,
393 uint8_t *vsum, int allow_env_vars)
Simon Glass460408e2012-12-05 14:46:36 +0000394{
Simon Glassd5b76672013-02-24 17:33:26 +0000395 int env_var = 0;
396
397 /* See comment above in store_result() */
398 if (allow_env_vars) {
399 if (*verify_str == '*')
400 verify_str++;
401 else
402 env_var = 1;
403 }
404
Nikolay Dimitrov3ef46a92014-12-12 20:01:23 +0200405 if (!env_var) {
Simon Glassbd091b62013-02-24 17:33:31 +0000406 ulong addr;
407 void *buf;
Simon Glass460408e2012-12-05 14:46:36 +0000408
Simon Glassbd091b62013-02-24 17:33:31 +0000409 addr = simple_strtoul(verify_str, NULL, 16);
410 buf = map_sysmem(addr, algo->digest_size);
411 memcpy(vsum, buf, algo->digest_size);
Simon Glass460408e2012-12-05 14:46:36 +0000412 } else {
Simon Glass460408e2012-12-05 14:46:36 +0000413 char *vsum_str;
414 int digits = algo->digest_size * 2;
415
416 /*
417 * As with the original code from sha1sum.c, we assume that a
418 * string which matches the digest size exactly is a hex
419 * string and not an environment variable.
420 */
421 if (strlen(verify_str) == digits)
422 vsum_str = verify_str;
423 else {
Simon Glass00caae62017-08-03 12:22:12 -0600424 vsum_str = env_get(verify_str);
Simon Glass460408e2012-12-05 14:46:36 +0000425 if (vsum_str == NULL || strlen(vsum_str) != digits) {
426 printf("Expected %d hex digits in env var\n",
427 digits);
428 return 1;
429 }
430 }
431
Stefan Roese8f0b1e22015-05-18 14:08:24 +0200432 hash_parse_string(algo->name, vsum_str, vsum);
Simon Glass460408e2012-12-05 14:46:36 +0000433 }
434 return 0;
435}
436
Tom Rini48ad68d2016-01-05 08:47:48 -0500437static void hash_show(struct hash_algo *algo, ulong addr, ulong len, uint8_t *output)
Simon Glass460408e2012-12-05 14:46:36 +0000438{
439 int i;
440
441 printf("%s for %08lx ... %08lx ==> ", algo->name, addr, addr + len - 1);
442 for (i = 0; i < algo->digest_size; i++)
443 printf("%02x", output[i]);
444}
445
Simon Glassd5b76672013-02-24 17:33:26 +0000446int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
Simon Glass460408e2012-12-05 14:46:36 +0000447 int argc, char * const argv[])
448{
Simon Glass460408e2012-12-05 14:46:36 +0000449 ulong addr, len;
Simon Glass460408e2012-12-05 14:46:36 +0000450
Nikolay Dimitrov3ef46a92014-12-12 20:01:23 +0200451 if ((argc < 2) || ((flags & HASH_FLAG_VERIFY) && (argc < 3)))
Simon Glass460408e2012-12-05 14:46:36 +0000452 return CMD_RET_USAGE;
453
Simon Glassd5b76672013-02-24 17:33:26 +0000454 addr = simple_strtoul(*argv++, NULL, 16);
455 len = simple_strtoul(*argv++, NULL, 16);
456
Simon Glassd20a40d2013-02-24 20:30:22 +0000457 if (multi_hash()) {
458 struct hash_algo *algo;
Breno Limad7af2ba2018-01-17 10:03:45 -0200459 u8 *output;
Simon Glass04819a42014-06-12 07:24:41 -0600460 uint8_t vsum[HASH_MAX_DIGEST_SIZE];
Simon Glassbd091b62013-02-24 17:33:31 +0000461 void *buf;
Simon Glass460408e2012-12-05 14:46:36 +0000462
Hung-ying Tyanbf007eb2014-03-03 12:19:28 +0100463 if (hash_lookup_algo(algo_name, &algo)) {
Simon Glassd20a40d2013-02-24 20:30:22 +0000464 printf("Unknown hash algorithm '%s'\n", algo_name);
Simon Glass460408e2012-12-05 14:46:36 +0000465 return CMD_RET_USAGE;
Simon Glassd20a40d2013-02-24 20:30:22 +0000466 }
467 argc -= 2;
468
469 if (algo->digest_size > HASH_MAX_DIGEST_SIZE) {
470 puts("HASH_MAX_DIGEST_SIZE exceeded\n");
471 return 1;
472 }
473
Breno Limad7af2ba2018-01-17 10:03:45 -0200474 output = memalign(ARCH_DMA_MINALIGN,
475 sizeof(uint32_t) * HASH_MAX_DIGEST_SIZE);
476
Simon Glassbd091b62013-02-24 17:33:31 +0000477 buf = map_sysmem(addr, len);
478 algo->hash_func_ws(buf, len, output, algo->chunk_size);
479 unmap_sysmem(buf);
Simon Glassd20a40d2013-02-24 20:30:22 +0000480
481 /* Try to avoid code bloat when verify is not needed */
Daniel Thompson221a9492017-05-19 17:26:58 +0100482#if defined(CONFIG_CRC32_VERIFY) || defined(CONFIG_SHA1SUM_VERIFY) || \
483 defined(CONFIG_HASH_VERIFY)
Simon Glassd20a40d2013-02-24 20:30:22 +0000484 if (flags & HASH_FLAG_VERIFY) {
485#else
486 if (0) {
487#endif
Simon Glassd20a40d2013-02-24 20:30:22 +0000488 if (parse_verify_sum(algo, *argv, vsum,
Simon Glassd5b76672013-02-24 17:33:26 +0000489 flags & HASH_FLAG_ENV)) {
Simon Glassd20a40d2013-02-24 20:30:22 +0000490 printf("ERROR: %s does not contain a valid "
491 "%s sum\n", *argv, algo->name);
492 return 1;
493 }
494 if (memcmp(output, vsum, algo->digest_size) != 0) {
495 int i;
Simon Glass460408e2012-12-05 14:46:36 +0000496
Simon Glass31890ae2014-06-02 22:04:49 -0600497 hash_show(algo, addr, len, output);
Simon Glassd20a40d2013-02-24 20:30:22 +0000498 printf(" != ");
499 for (i = 0; i < algo->digest_size; i++)
500 printf("%02x", vsum[i]);
501 puts(" ** ERROR **\n");
502 return 1;
503 }
504 } else {
Simon Glass31890ae2014-06-02 22:04:49 -0600505 hash_show(algo, addr, len, output);
Simon Glassd20a40d2013-02-24 20:30:22 +0000506 printf("\n");
Simon Glass460408e2012-12-05 14:46:36 +0000507
Simon Glassd20a40d2013-02-24 20:30:22 +0000508 if (argc) {
509 store_result(algo, output, *argv,
510 flags & HASH_FLAG_ENV);
511 }
Breno Limad7af2ba2018-01-17 10:03:45 -0200512 unmap_sysmem(output);
513
Simon Glassd20a40d2013-02-24 20:30:22 +0000514 }
515
516 /* Horrible code size hack for boards that just want crc32 */
517 } else {
518 ulong crc;
519 ulong *ptr;
520
521 crc = crc32_wd(0, (const uchar *)addr, len, CHUNKSZ_CRC32);
522
523 printf("CRC32 for %08lx ... %08lx ==> %08lx\n",
524 addr, addr + len - 1, crc);
525
Tom Rini4b756b02013-11-07 07:39:48 -0500526 if (argc >= 3) {
527 ptr = (ulong *)simple_strtoul(argv[0], NULL, 16);
Simon Glassd20a40d2013-02-24 20:30:22 +0000528 *ptr = crc;
Simon Glassd5b76672013-02-24 17:33:26 +0000529 }
Simon Glass460408e2012-12-05 14:46:36 +0000530 }
531
532 return 0;
533}
Simon Glassd70f9192017-05-17 09:05:34 -0600534#endif /* CONFIG_CMD_HASH || CONFIG_CMD_SHA1SUM || CONFIG_CMD_CRC32) */
535#endif /* !USE_HOSTCC */