xref: /optee_os/core/include/kernel/huk_subkey.h (revision 5b25c76ac40f830867e3d60800120ffd7874e8dc)
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  * @HUK_SUBKEY_UNIQUE_TA: TA unique key
19  * @HUK_SUBKEY_TA_ENC:    TA encryption key
20  *
21  * Add more identifiers as needed, be careful to not change the already
22  * assigned numbers as that will affect the derived subkey.
23  */
24 enum huk_subkey_usage {
25 	/*
26 	 * All IDs are explicitly assigned to make it easier to keep then
27 	 * constant.
28 	 */
29 	HUK_SUBKEY_RPMB = 0,
30 	HUK_SUBKEY_SSK = 1,
31 	HUK_SUBKEY_DIE_ID = 2,
32 	HUK_SUBKEY_UNIQUE_TA = 3,
33 	HUK_SUBKEY_TA_ENC = 4,
34 };
35 
36 #define HUK_SUBKEY_MAX_LEN	TEE_SHA256_HASH_SIZE
37 
38 /*
39  * huk_subkey_derive() - Derive a subkey from the hardware unique key
40  * @usage:		Intended usage of the subkey
41  * @const_data:		Constant data to generate different subkeys with
42  *			the same usage
43  * @const_data_len:	Length of constant data
44  * @subkey:		Generated subkey
45  * @subkey_len:		Required size of the subkey, sizes larger than
46  *			HUK_SUBKEY_MAX_LEN are not accepted.
47  *
48  * Returns a subkey derived from the hardware unique key. Given the same
49  * input the same subkey is returned each time.
50  *
51  * Return TEE_SUCCES on success or an error code on failure.
52  */
53 TEE_Result huk_subkey_derive(enum huk_subkey_usage usage,
54 			     const void *const_data, size_t const_data_len,
55 			     uint8_t *subkey, size_t subkey_len);
56 
57 
58 #endif /*__KERNEL_HUK_SUBKEY_H*/
59