Commit 8877fda60d47cd1444f480a3486234ad76a547bb

Authored by Aymen Sghaier
Committed by Ye Li
1 parent 6427f23dce

MLK-18703: crypto: caam: Fix typo for caam blob commands

This fix a wrong trace error while executing caam genlob command.

Signed-off-by: Aymen Sghaier <aymen.sghaier@nxp.com>
(cherry picked from commit 7b80598100baf38562bee10bb4a19c3c834b945b)
(cherry picked from commit 878d0d145482683bd7d3b89f3cbd74878b5d1064)

Showing 1 changed file with 3 additions and 2 deletions Inline Diff

1 /* 1 /*
2 * Copyright (C) 2012-2016 Freescale Semiconductor, Inc. 2 * Copyright (C) 2012-2016 Freescale Semiconductor, Inc.
3 * Copyright 2018 NXP
3 * 4 *
4 * 5 *
5 * See file CREDITS for list of people who contributed to this 6 * See file CREDITS for list of people who contributed to this
6 * project. 7 * project.
7 * 8 *
8 * This program is free software; you can redistribute it and/or 9 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as 10 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of 11 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version. 12 * the License, or (at your option) any later version.
12 * 13 *
13 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 17 * GNU General Public License for more details.
17 */ 18 */
18 19
19 20
20 #include <common.h> 21 #include <common.h>
21 #include <command.h> 22 #include <command.h>
22 #include <fsl_caam.h> 23 #include <fsl_caam.h>
23 24
24 static int do_caam(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) 25 static int do_caam(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
25 { 26 {
26 27
27 int ret, i; 28 int ret, i;
28 29
29 if (argc < 2) 30 if (argc < 2)
30 return CMD_RET_USAGE; 31 return CMD_RET_USAGE;
31 32
32 if (strcmp(argv[1], "genblob") == 0) { 33 if (strcmp(argv[1], "genblob") == 0) {
33 34
34 if (argc != 5) 35 if (argc != 5)
35 return CMD_RET_USAGE; 36 return CMD_RET_USAGE;
36 37
37 void *data_addr; 38 void *data_addr;
38 void *blob_addr; 39 void *blob_addr;
39 int size; 40 int size;
40 41
41 data_addr = (void *)simple_strtoul(argv[2], NULL, 16); 42 data_addr = (void *)simple_strtoul(argv[2], NULL, 16);
42 blob_addr = (void *)simple_strtoul(argv[3], NULL, 16); 43 blob_addr = (void *)simple_strtoul(argv[3], NULL, 16);
43 size = simple_strtoul(argv[4], NULL, 10); 44 size = simple_strtoul(argv[4], NULL, 10);
44 if (size <= 48) 45 if (size <= 48)
45 return CMD_RET_USAGE; 46 return CMD_RET_USAGE;
46 47
47 caam_open(); 48 caam_open();
48 ret = caam_gen_blob((uint32_t)data_addr, (uint32_t)blob_addr, (uint32_t)size); 49 ret = caam_gen_blob((uint32_t)data_addr, (uint32_t)blob_addr, (uint32_t)size);
49 50
50 if(ret != SUCCESS){ 51 if(ret != SUCCESS){
51 printf("Error during blob decap operation: 0x%d\n",ret); 52 printf("Error during blob encap operation: 0x%x\n", ret);
52 return 0; 53 return 0;
53 } 54 }
54 55
55 /* Print the generated DEK blob */ 56 /* Print the generated DEK blob */
56 printf("DEK blob is available at 0x%08X and equals:\n",(unsigned int)blob_addr); 57 printf("DEK blob is available at 0x%08X and equals:\n",(unsigned int)blob_addr);
57 for(i=0;i<size;i++) 58 for(i=0;i<size;i++)
58 printf("%02X ",((uint8_t *)blob_addr)[i]); 59 printf("%02X ",((uint8_t *)blob_addr)[i]);
59 printf("\n\n"); 60 printf("\n\n");
60 61
61 62
62 return 1; 63 return 1;
63 64
64 } 65 }
65 66
66 else if (strcmp(argv[1], "decap") == 0){ 67 else if (strcmp(argv[1], "decap") == 0){
67 68
68 if (argc != 5) 69 if (argc != 5)
69 return CMD_RET_USAGE; 70 return CMD_RET_USAGE;
70 71
71 void *blob_addr; 72 void *blob_addr;
72 void *data_addr; 73 void *data_addr;
73 int size; 74 int size;
74 75
75 blob_addr = (void *)simple_strtoul(argv[2], NULL, 16); 76 blob_addr = (void *)simple_strtoul(argv[2], NULL, 16);
76 data_addr = (void *)simple_strtoul(argv[3], NULL, 16); 77 data_addr = (void *)simple_strtoul(argv[3], NULL, 16);
77 size = simple_strtoul(argv[4], NULL, 10); 78 size = simple_strtoul(argv[4], NULL, 10);
78 if (size <= 48) 79 if (size <= 48)
79 return CMD_RET_USAGE; 80 return CMD_RET_USAGE;
80 81
81 caam_open(); 82 caam_open();
82 ret = caam_decap_blob((uint32_t)(data_addr), (uint32_t)(blob_addr), (uint32_t)size); 83 ret = caam_decap_blob((uint32_t)(data_addr), (uint32_t)(blob_addr), (uint32_t)size);
83 if(ret != SUCCESS) 84 if(ret != SUCCESS)
84 printf("Error during blob decap operation: 0x%d\n",ret); 85 printf("Error during blob decap operation: 0x%x\n", ret);
85 else { 86 else {
86 printf("Success, blob decap at SM PAGE1 original data is:\n"); 87 printf("Success, blob decap at SM PAGE1 original data is:\n");
87 int i = 0; 88 int i = 0;
88 for (i = 0; i < size; i++) { 89 for (i = 0; i < size; i++) {
89 printf("0x%x ",*(unsigned char*)(data_addr+i)); 90 printf("0x%x ",*(unsigned char*)(data_addr+i));
90 if (i % 16 == 0) 91 if (i % 16 == 0)
91 printf("\n"); 92 printf("\n");
92 } 93 }
93 printf("\n"); 94 printf("\n");
94 } 95 }
95 96
96 return 1; 97 return 1;
97 } 98 }
98 99
99 return CMD_RET_USAGE; 100 return CMD_RET_USAGE;
100 } 101 }
101 102
102 U_BOOT_CMD( 103 U_BOOT_CMD(
103 caam, 5, 1, do_caam, 104 caam, 5, 1, do_caam,
104 "Freescale i.MX CAAM command", 105 "Freescale i.MX CAAM command",
105 "caam genblob data_addr blob_addr data_size\n \ 106 "caam genblob data_addr blob_addr data_size\n \
106 caam decap blobaddr data_addr data_size\n \ 107 caam decap blobaddr data_addr data_size\n \
107 \n " 108 \n "
108 ); 109 );
109 110