]>
git.ipfire.org Git - people/ms/u-boot.git/blob - arch/arm/mach-imx/cmd_dek.c
2 * Copyright 2008-2015 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
6 * Command for encapsulating DEK blob
11 #include <environment.h>
13 #include <asm/byteorder.h>
14 #include <linux/compiler.h>
16 #include <asm/arch/clock.h>
19 DECLARE_GLOBAL_DATA_PTR
;
22 * blob_dek() - Encapsulate the DEK as a blob using CAM's Key
23 * @src: - Address of data to be encapsulated
24 * @dst: - Desination address of encapsulated data
25 * @len: - Size of data to be encapsulated
27 * Returns zero on success,and negative on error.
29 static int blob_encap_dek(const u8
*src
, u8
*dst
, u32 len
)
34 u32 out_jr_size
= sec_in32(CONFIG_SYS_FSL_JR0_ADDR
+ 0x102c);
35 if (out_jr_size
!= jr_size
) {
36 hab_caam_clock_enable(1);
40 if (!((len
== 128) | (len
== 192) | (len
== 256))) {
41 debug("Invalid DEK size. Valid sizes are 128, 192 and 256b\n");
46 ret
= blob_dek(src
, dst
, len
);
52 * do_dek_blob() - Handle the "dek_blob" command-line command
53 * @cmdtp: Command data struct pointer
55 * @argc: Command-line argument count
56 * @argv: Array of command-line arguments
58 * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
61 static int do_dek_blob(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *const argv
[])
63 uint32_t src_addr
, dst_addr
, len
;
64 uint8_t *src_ptr
, *dst_ptr
;
70 src_addr
= simple_strtoul(argv
[1], NULL
, 16);
71 dst_addr
= simple_strtoul(argv
[2], NULL
, 16);
72 len
= simple_strtoul(argv
[3], NULL
, 10);
74 src_ptr
= map_sysmem(src_addr
, len
/8);
75 dst_ptr
= map_sysmem(dst_addr
, BLOB_SIZE(len
/8));
77 ret
= blob_encap_dek(src_ptr
, dst_ptr
, len
);
82 /***************************************************/
83 static char dek_blob_help_text
[] =
84 "src dst len - Encapsulate and create blob of data\n"
85 " $len bits long at address $src and\n"
86 " store the result at address $dst.\n";
89 dek_blob
, 4, 1, do_dek_blob
,
90 "Data Encryption Key blob encapsulation",