]>
git.ipfire.org Git - people/ms/u-boot.git/blob - common/cmd_blob.c
3 * Command for encapsulating/decapsulating blob of memory.
5 * SPDX-License-Identifier: GPL-2.0+
10 #include <environment.h>
12 #include <asm/byteorder.h>
13 #include <linux/compiler.h>
15 DECLARE_GLOBAL_DATA_PTR
;
18 * blob_decap() - Decapsulate the data as a blob
19 * @key_mod: - Pointer to key modifier/key
20 * @src: - Address of data to be decapsulated
21 * @dst: - Address of data to be decapsulated
22 * @len: - Size of data to be decapsulated
24 * Returns zero on success,and negative on error.
26 __weak
int blob_decap(u8
*key_mod
, u8
*src
, u8
*dst
, u32 len
)
32 * blob_encap() - Encapsulate the data as a blob
33 * @key_mod: - Pointer to key modifier/key
34 * @src: - Address of data to be encapsulated
35 * @dst: - Address of data to be encapsulated
36 * @len: - Size of data to be encapsulated
38 * Returns zero on success,and negative on error.
40 __weak
int blob_encap(u8
*key_mod
, u8
*src
, u8
*dst
, u32 len
)
46 * do_blob() - Handle the "blob" command-line command
47 * @cmdtp: Command data struct pointer
49 * @argc: Command-line argument count
50 * @argv: Array of command-line arguments
52 * Returns zero on success, CMD_RET_USAGE in case of misuse and negative
55 static int do_blob(cmd_tbl_t
*cmdtp
, int flag
, int argc
, char *const argv
[])
57 uint32_t key_addr
, src_addr
, dst_addr
, len
;
58 uint8_t *km_ptr
, *src_ptr
, *dst_ptr
;
64 if (!strncmp(argv
[1], "enc", 3))
66 else if (!strncmp(argv
[1], "dec", 3))
71 src_addr
= simple_strtoul(argv
[2], NULL
, 16);
72 dst_addr
= simple_strtoul(argv
[3], NULL
, 16);
73 len
= simple_strtoul(argv
[4], NULL
, 16);
74 key_addr
= simple_strtoul(argv
[5], NULL
, 16);
76 km_ptr
= (uint8_t *)key_addr
;
77 src_ptr
= (uint8_t *)src_addr
;
78 dst_ptr
= (uint8_t *)dst_addr
;
81 ret
= blob_encap(km_ptr
, src_ptr
, dst_ptr
, len
);
83 ret
= blob_decap(km_ptr
, src_ptr
, dst_ptr
, len
);
88 /***************************************************/
89 static char blob_help_text
[] =
90 "enc src dst len km - Encapsulate and create blob of data\n"
91 " $len bytes long at address $src and\n"
92 " store the result at address $dst.\n"
93 " $km is the 16 byte key modifier\n"
94 " is also required for generation/use as\n"
95 " key for cryptographic operation. Key\n"
96 " modifier should be 16 byte long.\n"
97 "blob dec src dst len km - Decapsulate the blob of data at address\n"
98 " $src and store result of $len byte at\n"
100 " $km is the 16 byte key modifier\n"
101 " is also required for generation/use as\n"
102 " key for cryptographic operation. Key\n"
103 " modifier should be 16 byte long.\n";
107 "Blob encapsulation/decryption",