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