2 * Copyright 2015 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
7 #ifndef _FSL_VALIDATE_H_
8 #define _FSL_VALIDATE_H_
11 #include <fsl_sec_mon.h>
13 #include <linux/types.h>
17 /* Minimum and maximum size of RSA signature length in bits */
19 #define KEY_SIZE_BYTES (KEY_SIZE/8)
20 #define KEY_SIZE_WORDS (KEY_SIZE_BYTES/(WORD_SIZE))
22 extern struct jobring jr;
24 #ifdef CONFIG_KEY_REVOCATION
25 /* Srk table and key revocation check */
27 #define UNREVOCABLE_KEY 4
28 #define ALIGN_REVOC_KEY 3
29 #define MAX_KEY_ENTRIES 4
32 /* Barker code size in bytes */
33 #define ESBC_BARKER_LEN 4 /* barker code length in ESBC uboot client */
36 /* No-error return values */
37 #define ESBC_VALID_HDR 0 /* header is valid */
39 /* Maximum number of SG entries allowed */
40 #define MAX_SG_ENTRIES 8
43 * ESBC uboot client header structure.
44 * The struct contain the following fields
49 * length of the signature
51 * no of entries in SG table
59 * Here, pub key is modulus concatenated with exponent
62 struct fsl_secboot_img_hdr {
63 u8 barker[ESBC_BARKER_LEN]; /* barker code */
65 u32 pkey; /* public key offset */
66 #ifdef CONFIG_KEY_REVOCATION
72 u32 key_len; /* pub key length in bytes */
73 #ifdef CONFIG_KEY_REVOCATION
82 u32 psign; /* signature offset */
83 u32 sign_len; /* length of the signature in bytes */
85 u32 psgtable; /* ptr to SG table */
86 u32 pimg; /* ptr to ESBC client image */
89 u32 sg_entries; /* no of entries in SG table */
90 u32 img_size; /* ESBC client image size in bytes */
92 u32 img_start; /* ESBC client entry point */
93 u32 sg_flag; /* Scatter gather flag */
105 #if defined(CONFIG_FSL_ISBC_KEY_EXT)
106 struct ie_key_table {
108 u8 pkey[2 * KEY_SIZE_BYTES];
114 struct ie_key_table ie_key_tbl[32];
118 #ifdef CONFIG_KEY_REVOCATION
121 u8 pkey[2 * KEY_SIZE_BYTES];
128 #if defined(CONFIG_FSL_TRUST_ARCH_v1) && defined(CONFIG_FSL_CORENET)
130 * This struct contains the following fields
131 * length of the segment
134 struct fsl_secboot_sg_table {
135 u32 len; /* length of the segment in bytes */
136 u32 src_addr; /* ptr to the data segment */
140 * This struct contains the following fields
141 * length of the segment
142 * Destination Target ID
144 * destination address
146 struct fsl_secboot_sg_table {
155 * ESBC private structure.
156 * Private structure used by ESBC to store following fields
158 * ESBC client key hash
159 * ESBC client Signature
160 * Encoded hash recovered from signature
161 * Encoded hash of ESBC client header plus ESBC client image
163 struct fsl_secboot_img_priv {
164 uint32_t hdr_location;
167 struct fsl_secboot_img_hdr hdr;
169 u8 img_key[2 * KEY_SIZE_BYTES]; /* ESBC client key */
170 u8 img_key_hash[32]; /* ESBC client key hash */
172 #ifdef CONFIG_KEY_REVOCATION
173 struct srk_table srk_tbl[MAX_KEY_ENTRIES];
175 u8 img_sign[KEY_SIZE_BYTES]; /* ESBC client signature */
177 u8 img_encoded_hash[KEY_SIZE_BYTES]; /* EM wrt RSA PKCSv1.5 */
178 /* Includes hash recovered after
179 * signature verification
182 u8 img_encoded_hash_second[KEY_SIZE_BYTES];/* EM' wrt RSA PKCSv1.5 */
184 * ESBC client header plus
188 struct fsl_secboot_sg_table sgtbl[MAX_SG_ENTRIES]; /* SG table */
189 u32 ehdrloc; /* ESBC client location */
192 int fsl_secboot_validate(cmd_tbl_t *cmdtp, int flag, int argc,
193 char * const argv[]);
194 int fsl_secboot_blob_encap(cmd_tbl_t *cmdtp, int flag, int argc,
195 char * const argv[]);
196 int fsl_secboot_blob_decap(cmd_tbl_t *cmdtp, int flag, int argc,
197 char * const argv[]);