xref: /optee_os/core/include/kernel/huk_subkey.h (revision 41e5aa8f18c4d48083341ff3df9e75f0c77cf703)
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2019, Linaro Limited
4  */
5 
6 #ifndef __KERNEL_HUK_SUBKEY_H
7 #define __KERNEL_HUK_SUBKEY_H
8 
9 #include <tee_api_types.h>
10 #include <types_ext.h>
11 #include <utee_defines.h>
12 
13 /*
14  * enum huk_subkey_usage - subkey usage identifier
15  * @HUK_SUBKEY_RPMB:	RPMB key
16  * @HUK_SUBKEY_SSK:	Secure Storage key
17  * @HUK_SUBKEY_DIE_ID:	Representing the die ID
18  *
19  * Add more identifiers as needed, be careful to not change the already
20  * assigned numbers as that will affect the derived subkey.
21  */
22 enum huk_subkey_usage {
23 	/*
24 	 * All IDs are explicitly assigned to make it easier to keep then
25 	 * constant.
26 	 */
27 	HUK_SUBKEY_RPMB = 0,
28 	HUK_SUBKEY_SSK = 1,
29 	HUK_SUBKEY_DIE_ID = 2,
30 };
31 
32 #define HUK_SUBKEY_MAX_LEN	TEE_SHA256_HASH_SIZE
33 
34 /*
35  * huk_subkey_derive() - Derive a subkey from the hardware unique key
36  * @usage:		Intended usage of the subkey
37  * @const_data:		Constant data to generate different subkeys with
38  *			the same usage
39  * @const_data_len:	Length of constant data
40  * @subkey:		Generated subkey
41  * @subkey_len:		Required size of the subkey, sizes larger than
42  *			HUK_SUBKEY_MAX_LEN are not accepted.
43  *
44  * Returns a subkey derived from the hardware unique key. Given the same
45  * input the same subkey is returned each time.
46  *
47  * Return TEE_SUCCES on success or an error code on failure.
48  */
49 TEE_Result huk_subkey_derive(enum huk_subkey_usage usage,
50 			     const void *const_data, size_t const_data_len,
51 			     uint8_t *subkey, size_t subkey_len);
52 
53 
54 #endif /*__KERNEL_HUK_SUBKEY_H*/
55