1 /* 2 * Copyright (c) 2021-2023, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7 8 #ifndef BL1_1_OTP_H 9 #define BL1_1_OTP_H 10 11 #include <stdint.h> 12 #include <stddef.h> 13 14 #include "fih.h" 15 #include "crypto_key_defs.h" 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 #ifndef BL1_2_HASH_SIZE 22 #define BL1_2_HASH_SIZE 32 23 #endif /* BL1_2_HASH_SIZE */ 24 25 #ifndef BL2_HASH_SIZE 26 #define BL2_HASH_SIZE 32 27 #endif /* BL1_2_HASH_SIZE */ 28 29 #ifndef TFM_OTP_NV_COUNTER_NUMBER 30 #define TFM_OTP_NV_COUNTER_NUMBER 4u 31 #endif /* !TFM_OTP_NV_COUNTER_NUMBER */ 32 33 #ifndef TFM_OTP_NV_COUNTER_SIZE_IN_BITS 34 #define TFM_OTP_NV_COUNTER_SIZE_IN_BITS 32u 35 #endif /* !TFM_OTP_NV_COUNTER_SIZE_IN_BITS */ 36 37 /* Use ceiling division so we always have at least the correct amount of bits */ 38 #define TFM_OTP_NV_COUNTER_BYTES ((TFM_OTP_NV_COUNTER_SIZE_IN_BITS + 7) / 8) 39 40 enum tfm_bl1_nv_counter_id_t { 41 BL1_NV_COUNTER_ID_BL2_IMAGE, 42 }; 43 44 /* Load the key with the given ID into the key buf */ 45 fih_int bl1_otp_read_key(enum tfm_bl1_key_id_t key_id, uint8_t *key_buf); 46 47 #ifdef __cplusplus 48 } 49 #endif 50 51 #endif /* BL1_1_OTP_H */ 52