• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2017-2021 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __JOBDESC_H
9 #define __JOBDESC_H
10 
11 #include <rsa.h>
12 
13 #define DESC_LEN_MASK		0x7f
14 #define DESC_START_SHIFT	16
15 
16 #define KEY_BLOB_SIZE 32
17 #define MAC_SIZE 16
18 
19 #define KEY_IDNFR_SZ_BYTES 16
20 #define CLASS_SHIFT 25
21 #define CLASS_2	(0x02 << CLASS_SHIFT)
22 
23 #define CMD_SHIFT		27
24 #define CMD_OPERATION		(U(0x10) << CMD_SHIFT)
25 
26 #define OP_TYPE_SHIFT		24
27 #define OP_TYPE_ENCAP_PROTOCOL	(0x07 << OP_TYPE_SHIFT)
28 
29 /* Assuming OP_TYPE = OP_TYPE_UNI_PROTOCOL */
30 #define OP_PCLID_SHIFT		16
31 #define OP_PCLID_BLOB		(0x0d << OP_PCLID_SHIFT)
32 
33 #define BLOB_PROTO_INFO		 0x00000002
34 
35 uint32_t desc_length(uint32_t *desc);
36 
37 int cnstr_rng_jobdesc(uint32_t *desc, uint32_t state_handle,
38 		      uint32_t *add_inp, uint32_t add_ip_len,
39 		      uint8_t *out_data, uint32_t len);
40 
41 int cnstr_rng_instantiate_jobdesc(uint32_t *desc);
42 
43 /* Construct descriptor to generate hw key blob */
44 int cnstr_hw_encap_blob_jobdesc(uint32_t *desc,
45 				uint8_t *key_idnfr, uint32_t key_sz,
46 				uint32_t key_class, uint8_t *plain_txt,
47 				uint32_t in_sz, uint8_t *enc_blob,
48 				uint32_t out_sz, uint32_t operation);
49 
50 void cnstr_hash_jobdesc(uint32_t *desc, uint8_t *msg, uint32_t msgsz,
51 			uint8_t *digest);
52 
53 void cnstr_jobdesc_pkha_rsaexp(uint32_t *desc,
54 			       struct pk_in_params *pkin, uint8_t *out,
55 			       uint32_t out_siz);
56 #endif
57