xref: /openbmc/u-boot/board/freescale/common/cmd_esbc_validate.c (revision bc71f926e35be8af1a9491ea0332871881c7eda5)
1 /*
2  * Copyright 2015 Freescale Semiconductor, Inc.
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <command.h>
9 #include <fsl_validate.h>
10 
11 static int do_esbc_halt(cmd_tbl_t *cmdtp, int flag, int argc,
12 				char * const argv[])
13 {
14 	printf("Core is entering spin loop.\n");
15 loop:
16 	goto loop;
17 
18 	return 0;
19 }
20 
21 static int do_esbc_validate(cmd_tbl_t *cmdtp, int flag, int argc,
22 				char * const argv[])
23 {
24 	char *hash_str = NULL;
25 	ulong haddr;
26 	int ret;
27 
28 	if (argc < 2)
29 		return cmd_usage(cmdtp);
30 	else if (argc > 2)
31 		/* Second arg - Optional - Hash Str*/
32 		hash_str = argv[2];
33 
34 	/* First argument - header address -32/64bit */
35 	haddr = simple_strtoul(argv[1], NULL, 16);
36 
37 	ret = fsl_secboot_validate(haddr, hash_str);
38 	if (ret)
39 		return 1;
40 
41 	printf("esbc_validate command successful\n");
42 	return 0;
43 }
44 
45 /***************************************************/
46 static char esbc_validate_help_text[] =
47 	"esbc_validate hdr_addr <hash_val> - Validates signature using\n"
48 	"                          RSA verification\n"
49 	"                          $hdr_addr Address of header of the image\n"
50 	"                          to be validated.\n"
51 	"                          $hash_val -Optional\n"
52 	"                          It provides Hash of public/srk key to be\n"
53 	"                          used to verify signature.\n";
54 
55 U_BOOT_CMD(
56 	esbc_validate,	3,	0,	do_esbc_validate,
57 	"Validates signature on a given image using RSA verification",
58 	esbc_validate_help_text
59 );
60 
61 U_BOOT_CMD(
62 	esbc_halt,	1,	0,	do_esbc_halt,
63 	"Put the core in spin loop ",
64 	""
65 );
66