xref: /rk3399_ARM-atf/include/tools_share/firmware_encrypted.h (revision 091576e7f1fa0ca7360732d290a28ff2dc2a16e6)
1*2be57b86SSumit Garg /*
2*2be57b86SSumit Garg  * Copyright (c) 2020, Linaro Limited. All rights reserved.
3*2be57b86SSumit Garg  * Author: Sumit Garg <sumit.garg@linaro.org>
4*2be57b86SSumit Garg  *
5*2be57b86SSumit Garg  * SPDX-License-Identifier: BSD-3-Clause
6*2be57b86SSumit Garg  */
7*2be57b86SSumit Garg 
8*2be57b86SSumit Garg #ifndef FIRMWARE_ENCRYPTED_H
9*2be57b86SSumit Garg #define FIRMWARE_ENCRYPTED_H
10*2be57b86SSumit Garg 
11*2be57b86SSumit Garg #include <stdint.h>
12*2be57b86SSumit Garg 
13*2be57b86SSumit Garg /* This is used as a signature to validate the encryption header */
14*2be57b86SSumit Garg #define ENC_HEADER_MAGIC		0xAA640001U
15*2be57b86SSumit Garg 
16*2be57b86SSumit Garg /* Firmware encryption status flag mask */
17*2be57b86SSumit Garg #define FW_ENC_STATUS_FLAG_MASK		0x1
18*2be57b86SSumit Garg 
19*2be57b86SSumit Garg /*
20*2be57b86SSumit Garg  * SSK: Secret Symmetric Key
21*2be57b86SSumit Garg  * BSSK: Binding Secret Symmetric Key
22*2be57b86SSumit Garg  */
23*2be57b86SSumit Garg enum fw_enc_status_t {
24*2be57b86SSumit Garg 	FW_ENC_WITH_SSK = 0,
25*2be57b86SSumit Garg 	FW_ENC_WITH_BSSK = 1,
26*2be57b86SSumit Garg };
27*2be57b86SSumit Garg 
28*2be57b86SSumit Garg #define ENC_MAX_IV_SIZE			16U
29*2be57b86SSumit Garg #define ENC_MAX_TAG_SIZE		16U
30*2be57b86SSumit Garg #define ENC_MAX_KEY_SIZE		32U
31*2be57b86SSumit Garg 
32*2be57b86SSumit Garg struct fw_enc_hdr {
33*2be57b86SSumit Garg 	uint32_t magic;
34*2be57b86SSumit Garg 	uint16_t dec_algo;
35*2be57b86SSumit Garg 	uint16_t flags;
36*2be57b86SSumit Garg 	uint16_t iv_len;
37*2be57b86SSumit Garg 	uint16_t tag_len;
38*2be57b86SSumit Garg 	uint8_t iv[ENC_MAX_IV_SIZE];
39*2be57b86SSumit Garg 	uint8_t tag[ENC_MAX_TAG_SIZE];
40*2be57b86SSumit Garg };
41*2be57b86SSumit Garg 
42*2be57b86SSumit Garg #endif /* FIRMWARE_ENCRYPTED_H */
43