OPTIGA™ Trust M
Host Library Documentation
protected_update_data_set.h
Go to the documentation of this file.
1 
37 #ifndef _PROTECTED_UPDATE_DATA_SET_H_
38 #define _PROTECTED_UPDATE_DATA_SET_H_
39 
40 #include <stdint.h>
41 
42 #define FRAGMENT_DIGEST_LENGTH (0x20)
43 #define MAX_PAYLOAD_SIZE (640U)
44 #define MAC_SIZE (8U)
45 #define MAX_PAYLOAD_FRAGMENT_SIZE (MAX_PAYLOAD_SIZE - FRAGMENT_DIGEST_LENGTH)
46 
47 #define NONCE_LENGTH (11U)
48 #define FRAGMENT_NUMBER_LENGTH (2U)
49 #define ASSOCIATED_DATA_LENGTH (8U)
50 #define SESSION_KEY_LENGTH (27U)
51 
52 #define PAYLOAD_TYPE_KEY "key"
53 #define PAYLOAD_TYPE_DATA "data"
54 #define PROTECTED_INTEGRATY_TYPE "integrity"
55 #define PROTECTED_CONFIDENTIALITY_TYPE "confidentiality"
56 #define TRUE (1U)
57 #define FALSE (0U)
58 
59 typedef enum key_type
60 {
61  eRSA = 1,
62  eECC = 2,
63  eAES = 3
65 
66 typedef enum payload_type
67 {
72 
73 typedef enum key_algorithm
74 {
77  eRSA_1024_EXP = 0x41,
78  eRSA_2048_EXP = 0x42,
79  eAES_128 = 0x81,
81 
82 typedef enum key_usage
83 {
84  eAUTH = 0x01,
85  eENC = 0x02,
86  eSIGN = 0x10,
87  eKEY_AGREE = 0x20
89 
90 
91 typedef enum encryption_algo
92 {
95 
96 typedef enum kdf_algo
97 {
100 
101 typedef enum content_reset_type
102 {
104  eZEROES = 1,
105  eRANDOM = 2
107 
108 // Structure to store key derivation
109 typedef struct kdf
110 {
112  uint8_t * shared_secret;
114  const uint8_t * label;
115  uint16_t label_length;
116  uint8_t * seed;
117  uint8_t seed_length;
120 
121 // Structure to store encrypt data parameters
122 typedef struct enc_params
123 {
127  uint8_t nonce_length;
130  uint8_t mac_size;
132 
133 typedef struct confidentiality
134 {
138 
139 typedef struct data_payload
140 {
141  uint32_t offset_in_oid;
142  uint8_t * data;
143  uint16_t data_length;
144  uint8_t write_type;
146 
147 typedef struct ecc_key
148 {
149  uint8_t * D;
150  uint16_t D_length;
151  uint8_t * X;
152  uint16_t X_length;
153  uint8_t * Y;
154  uint16_t Y_length;
156 
157 typedef struct rsa_key
158 {
159  uint8_t * N;
160  uint16_t N_length;
161  uint8_t * E;
162  uint16_t E_length;
163  uint8_t * D;
164  uint16_t D_length;
166 
167 typedef struct aes_key
168 {
169  uint8_t * key;
170  uint16_t key_length;
172 
173 typedef union key_params
174 {
179 
180 typedef struct key_payload
181 {
186  const int8_t * key_data_file_path;
188 
189 typedef struct metadata_payload
190 {
193  uint8_t * metadata;
194  uint16_t metadata_length;
196 
197 typedef enum signature_algo
198 {
199  eES_SHA = -7,
202 
203 typedef enum digest_algo
204 {
205  eSHA_256 = 41,
207 
208 // Structure to store manifest data
209 typedef struct manifest
210 {
211  uint16_t payload_version;
213  uint16_t target_oid;
214  const uint8_t * couid;
216  const int8_t * private_key;
218  uint8_t * payload;
219  uint32_t payload_length;
221 
222  // confidentiality
224  // payload data
226  // payload key
228  // payload metadata
230 
232 
233 // Structure to store protect update data set
235 {
236  uint8_t * data;
237  uint16_t data_length;
238 
239  uint8_t * fragments;
242 
244 
245 // Create protected update manifest
247  protected_update_data_set_d * p_cbor_manifest);
248 
249 // Create protected update payload fragments
251  protected_update_data_set_d * p_cbor_manifest);
252 
254 
255 #ifndef _NO_STATIC_H
256 #define _STATIC_H static
257 #else
258 #define _STATIC_H
259 #endif
260 
261 #endif //_PROTECTED_UPDATE_DATA_SET_H_
262 
enc_params::encrypt_algo
encryption_algo_t encrypt_algo
Definition: protected_update_data_set.h:124
kdf_algo
kdf_algo
Definition: protected_update_data_set.h:97
signature_algo
signature_algo
Definition: protected_update_data_set.h:198
ecc_key::D_length
uint16_t D_length
Definition: protected_update_data_set.h:150
eAUTH
@ eAUTH
Definition: protected_update_data_set.h:84
eRSA
@ eRSA
Definition: protected_update_data_set.h:61
manifest_t
struct manifest manifest_t
metadata_payload::additional_flag
uint8_t additional_flag
Definition: protected_update_data_set.h:192
content_reset_type
content_reset_type
Definition: protected_update_data_set.h:102
aes_key::key
uint8_t * key
Definition: protected_update_data_set.h:169
kdf
Definition: protected_update_data_set.h:110
protected_update_create_fragments
int32_t protected_update_create_fragments(manifest_t *manifest_data, protected_update_data_set_d *p_cbor_manifest)
key_payload::key_params
key_params_t key_params
Definition: protected_update_data_set.h:185
enc_params::nonce_data
uint8_t nonce_data[NONCE_LENGTH]
Definition: protected_update_data_set.h:128
confidentiality_t
struct confidentiality confidentiality_t
key_algorithm
key_algorithm
Definition: protected_update_data_set.h:74
key_payload::key_type
key_type_d key_type
Definition: protected_update_data_set.h:182
eKEY_AGREE
@ eKEY_AGREE
Definition: protected_update_data_set.h:87
ecc_key::Y
uint8_t * Y
Definition: protected_update_data_set.h:153
metadata_payload::metadata_length
uint16_t metadata_length
Definition: protected_update_data_set.h:194
data_payload::data_length
uint16_t data_length
Definition: protected_update_data_set.h:143
protected_update_data_set::actual_memory_allocated
uint16_t actual_memory_allocated
Definition: protected_update_data_set.h:241
enc_params::session_key
uint8_t session_key[SESSION_KEY_LENGTH]
Definition: protected_update_data_set.h:125
metadata_payload_t
struct metadata_payload metadata_payload_t
rsa_key::E
uint8_t * E
Definition: protected_update_data_set.h:161
SESSION_KEY_LENGTH
#define SESSION_KEY_LENGTH
Definition: protected_update_data_set.h:50
protected_update_data_set_d
struct protected_update_data_set protected_update_data_set_d
eENC
@ eENC
Definition: protected_update_data_set.h:85
data_payload::data
uint8_t * data
Definition: protected_update_data_set.h:142
key_payload
Definition: protected_update_data_set.h:181
protected_update_data_set::data_length
uint16_t data_length
Definition: protected_update_data_set.h:237
eRSA_1024_EXP
@ eRSA_1024_EXP
Definition: protected_update_data_set.h:77
kdf::seed_length
uint8_t seed_length
Definition: protected_update_data_set.h:117
aes_key_t
struct aes_key aes_key_t
ecc_key::D
uint8_t * D
Definition: protected_update_data_set.h:149
eRSA_2048_EXP
@ eRSA_2048_EXP
Definition: protected_update_data_set.h:78
ePAYLOAD_METADATA
@ ePAYLOAD_METADATA
Definition: protected_update_data_set.h:69
enc_params::associated_data
uint8_t associated_data[ASSOCIATED_DATA_LENGTH]
Definition: protected_update_data_set.h:129
key_payload::key_algorithm
key_algorithm_t key_algorithm
Definition: protected_update_data_set.h:184
key_type
key_type
Definition: protected_update_data_set.h:60
manifest::trust_anchor_oid
uint16_t trust_anchor_oid
Definition: protected_update_data_set.h:212
manifest::p_data_payload
data_payload_t * p_data_payload
Definition: protected_update_data_set.h:225
payload_type_t
enum payload_type payload_type_t
manifest::p_metadata_payload
metadata_payload_t * p_metadata_payload
Definition: protected_update_data_set.h:229
key_params::ecc_key
ecc_key_t ecc_key
Definition: protected_update_data_set.h:176
digest_algo
digest_algo
Definition: protected_update_data_set.h:204
eSIGN
@ eSIGN
Definition: protected_update_data_set.h:86
eIFX_KDF_TLS12_PRF_SHA256
@ eIFX_KDF_TLS12_PRF_SHA256
Definition: protected_update_data_set.h:98
ePAYLOAD_KEY
@ ePAYLOAD_KEY
Definition: protected_update_data_set.h:70
rsa_key::N_length
uint16_t N_length
Definition: protected_update_data_set.h:160
manifest::payload_type
payload_type_t payload_type
Definition: protected_update_data_set.h:220
payload_type
payload_type
Definition: protected_update_data_set.h:67
key_payload::key_usage
key_usage_t key_usage
Definition: protected_update_data_set.h:183
metadata_payload
Definition: protected_update_data_set.h:190
protected_update_data_set::fragments
uint8_t * fragments
Definition: protected_update_data_set.h:239
eZEROES
@ eZEROES
Definition: protected_update_data_set.h:104
protected_update_data_set::data
uint8_t * data
Definition: protected_update_data_set.h:236
key_params::aes_key
aes_key_t aes_key
Definition: protected_update_data_set.h:177
protected_update_create_manifest
int32_t protected_update_create_manifest(manifest_t *manifest_data, protected_update_data_set_d *p_cbor_manifest)
aes_key::key_length
uint16_t key_length
Definition: protected_update_data_set.h:170
ASSOCIATED_DATA_LENGTH
#define ASSOCIATED_DATA_LENGTH
Definition: protected_update_data_set.h:49
data_payload_t
struct data_payload data_payload_t
enc_params_t
struct enc_params enc_params_t
key_params
Definition: protected_update_data_set.h:174
manifest::target_oid
uint16_t target_oid
Definition: protected_update_data_set.h:213
data_payload::offset_in_oid
uint32_t offset_in_oid
Definition: protected_update_data_set.h:141
key_usage_t
enum key_usage key_usage_t
eECC_NIST_P_384
@ eECC_NIST_P_384
Definition: protected_update_data_set.h:76
eES_SHA
@ eES_SHA
Definition: protected_update_data_set.h:199
ePAYLOAD_DATA
@ ePAYLOAD_DATA
Definition: protected_update_data_set.h:68
eAES
@ eAES
Definition: protected_update_data_set.h:63
enc_params
Definition: protected_update_data_set.h:123
manifest::p_key_payload
key_payload_t * p_key_payload
Definition: protected_update_data_set.h:227
rsa_key::E_length
uint16_t E_length
Definition: protected_update_data_set.h:162
eMETADATA_IDENTIFIER_FLAG
@ eMETADATA_IDENTIFIER_FLAG
Definition: protected_update_data_set.h:103
eRSA_SSA_PKCS1_V1_5_SHA_256
@ eRSA_SSA_PKCS1_V1_5_SHA_256
Definition: protected_update_data_set.h:200
key_payload::key_data_file_path
const int8_t * key_data_file_path
Definition: protected_update_data_set.h:186
key_algorithm_t
enum key_algorithm key_algorithm_t
ecc_key_t
struct ecc_key ecc_key_t
manifest::p_confidentiality
confidentiality_t * p_confidentiality
Definition: protected_update_data_set.h:223
rsa_key
Definition: protected_update_data_set.h:158
key_payload_t
struct key_payload key_payload_t
rsa_key_t
struct rsa_key rsa_key_t
rsa_key::D
uint8_t * D
Definition: protected_update_data_set.h:163
manifest::couid
const uint8_t * couid
Definition: protected_update_data_set.h:214
kdf::label_length
uint16_t label_length
Definition: protected_update_data_set.h:115
eAES_128
@ eAES_128
Definition: protected_update_data_set.h:79
rsa_key::N
uint8_t * N
Definition: protected_update_data_set.h:159
kdf::shared_secret
uint8_t * shared_secret
Definition: protected_update_data_set.h:112
eRANDOM
@ eRANDOM
Definition: protected_update_data_set.h:105
manifest::payload_length
uint32_t payload_length
Definition: protected_update_data_set.h:219
key_params::rsa_key
rsa_key_t rsa_key
Definition: protected_update_data_set.h:175
key_usage
key_usage
Definition: protected_update_data_set.h:83
metadata_payload::metadata
uint8_t * metadata
Definition: protected_update_data_set.h:193
enc_params::session_key_length
uint8_t session_key_length
Definition: protected_update_data_set.h:126
manifest::private_key
const int8_t * private_key
Definition: protected_update_data_set.h:216
key_params_t
union key_params key_params_t
data_payload::write_type
uint8_t write_type
Definition: protected_update_data_set.h:144
kdf::key_derivation_algo
kdf_algo_t key_derivation_algo
Definition: protected_update_data_set.h:118
confidentiality::enc_params
enc_params_t enc_params
Definition: protected_update_data_set.h:136
kdf_algo_t
enum kdf_algo kdf_algo_t
kdf::seed
uint8_t * seed
Definition: protected_update_data_set.h:116
digest_algo_t
enum digest_algo digest_algo_t
key_type_d
enum key_type key_type_d
content_reset_type_t
enum content_reset_type content_reset_type_t
metadata_payload::content_reset
key_type_d content_reset
Definition: protected_update_data_set.h:191
manifest
Definition: protected_update_data_set.h:210
encryption_algo_t
enum encryption_algo encryption_algo_t
enc_params::mac_size
uint8_t mac_size
Definition: protected_update_data_set.h:130
protected_update_data_set
Definition: protected_update_data_set.h:235
kdf_t
struct kdf kdf_t
eECC_NIST_P_256
@ eECC_NIST_P_256
Definition: protected_update_data_set.h:75
ecc_key
Definition: protected_update_data_set.h:148
eECC
@ eECC
Definition: protected_update_data_set.h:62
manifest::digest_algo
digest_algo_t digest_algo
Definition: protected_update_data_set.h:217
protected_update_data_set::fragments_length
uint16_t fragments_length
Definition: protected_update_data_set.h:240
manifest::payload
uint8_t * payload
Definition: protected_update_data_set.h:218
confidentiality
Definition: protected_update_data_set.h:134
ecc_key::X
uint8_t * X
Definition: protected_update_data_set.h:151
eAES_CCM_16_64_128
@ eAES_CCM_16_64_128
Definition: protected_update_data_set.h:93
ecc_key::X_length
uint16_t X_length
Definition: protected_update_data_set.h:152
aes_key
Definition: protected_update_data_set.h:168
manifest::signature_algo
signature_algo_t signature_algo
Definition: protected_update_data_set.h:215
protected_update_print_output_dataset
void protected_update_print_output_dataset(const protected_update_data_set_d *p_cbor_manifest)
manifest::payload_version
uint16_t payload_version
Definition: protected_update_data_set.h:211
enc_params::nonce_length
uint8_t nonce_length
Definition: protected_update_data_set.h:127
confidentiality::kdf_data
kdf_t kdf_data
Definition: protected_update_data_set.h:135
kdf::shared_secret_oid
uint16_t shared_secret_oid
Definition: protected_update_data_set.h:111
encryption_algo
encryption_algo
Definition: protected_update_data_set.h:92
data_payload
Definition: protected_update_data_set.h:140
rsa_key::D_length
uint16_t D_length
Definition: protected_update_data_set.h:164
kdf::label
const uint8_t * label
Definition: protected_update_data_set.h:114
ecc_key::Y_length
uint16_t Y_length
Definition: protected_update_data_set.h:154
signature_algo_t
enum signature_algo signature_algo_t
NONCE_LENGTH
#define NONCE_LENGTH
Definition: protected_update_data_set.h:47
kdf::shared_secret_length
uint16_t shared_secret_length
Definition: protected_update_data_set.h:113
eSHA_256
@ eSHA_256
Definition: protected_update_data_set.h:205