19
19
#ifndef CRYPTO_STRUCTS_H
20
20
#define CRYPTO_STRUCTS_H
21
21
22
+ #define SDLS_CHALLENGED_SIZE 10
23
+ #define SDLS_CMAC_SIZE 10
24
+ #define SDLS_KEY_VERIFY_BLK_SIZE 29
25
+ #define SDLS_KEY_ID_SIZE 98
26
+ #define SDLS_EKB_LEN 30
27
+
22
28
#include "crypto_config.h"
23
29
24
30
#ifdef NOS3 // NOS3/cFS build is ready
@@ -46,6 +52,8 @@ typedef struct
46
52
47
53
/*
48
54
** Security Association
55
+ * https://public.ccsds.org/Pubs/355x0b2.pdf
56
+ * Table A6
49
57
*/
50
58
typedef struct
51
59
{
@@ -57,7 +65,6 @@ typedef struct
57
65
char ak_ref [REF_SIZE ]; // Authentication Key Reference (Used with string-referenced keystores,EG-PKCS12 keystores, KMC crypto)
58
66
uint8_t sa_state : 2 ;
59
67
crypto_gvcid_t gvcid_blk ;
60
- // crypto_gvcid_t gvcid_tm_blk[NUM_GVCID];
61
68
uint8_t lpid ;
62
69
63
70
// Configuration
@@ -114,15 +121,14 @@ typedef struct
114
121
{
115
122
uint16_t ekid ; // Encrypted Key ID
116
123
uint8_t ek [KEY_SIZE ]; // Encrypted Key
117
- // uint8_t ekcrc[4]; // Encrypted Key CRC
118
124
} SDLS_EKB_t ;
119
125
#define SDLS_EKB_SIZE (sizeof(SDLS_EKB_t))
120
126
121
127
typedef struct
122
128
{
123
129
uint16_t mkid ; // Master Key ID
124
130
uint8_t iv [IV_SIZE ]; // Initialization Vector
125
- SDLS_EKB_t EKB [30 ]; // Encrypted Key Block
131
+ SDLS_EKB_t EKB [SDLS_EKB_LEN ]; // Encrypted Key Block
126
132
uint8_t mac [MAC_SIZE ]; // Message Authentication Code
127
133
} SDLS_OTAR_t ;
128
134
#define SDLS_OTAR_SIZE (sizeof(SDLS_OTAR_t))
@@ -135,7 +141,7 @@ typedef struct
135
141
136
142
typedef struct
137
143
{
138
- SDLS_KEY_t kblk [98 ]; // Key ID Block
144
+ SDLS_KEY_t kblk [SDLS_KEY_ID_SIZE ]; // Key ID Block
139
145
} SDLS_KEY_BLK_t ;
140
146
#define SDLS_KEY_BLK_SIZE (sizeof(SDLS_KEY_BLK_t))
141
147
@@ -155,7 +161,7 @@ typedef struct
155
161
156
162
typedef struct
157
163
{
158
- SDLS_KEYV_CMD_BLK_t blk [29 ]; // Key Verification Command Block
164
+ SDLS_KEYV_CMD_BLK_t blk [SDLS_KEY_VERIFY_BLK_SIZE ]; // Key Verification Command Block
159
165
} SDLS_KEYV_CMD_t ;
160
166
#define SDLS_KEYV_CMD_SIZE (sizeof(SDLS_KEYV_CMD_t))
161
167
@@ -168,25 +174,27 @@ typedef struct
168
174
} SDLS_KEYV_RPLY_BLK_t ;
169
175
#define SDLS_KEYV_RPLY_BLK_SIZE (sizeof(SDLS_KEYV_RPLY_BLK_t))
170
176
177
+
171
178
typedef struct
172
179
{
173
- SDLS_KEYV_RPLY_BLK_t blk [29 ]; // Key Verification Reply Block
180
+ SDLS_KEYV_RPLY_BLK_t blk [SDLS_KEY_VERIFY_BLK_SIZE ]; // Key Verification Reply Block
174
181
} SDLS_KEYV_RPLY_t ;
175
182
#define SDLS_KEYV_RPLY_SIZE (sizeof(SDLS_KEYV_RPLY_t))
176
183
177
184
typedef struct
178
185
{
179
186
uint16_t kid : 16 ; // Key ID
180
- uint8_t challenged [10 ];
187
+ uint8_t challenged [SDLS_CHALLENGED_SIZE ];
181
188
} SDLS_KEYDB_CMD_t ;
182
189
#define SDLS_KEYDB_CMD_SIZE (sizeof(SDLS_KEYDB_CMD_t))
183
190
191
+
184
192
typedef struct
185
193
{
186
194
uint16_t kid : 16 ; // Key ID
187
195
uint8_t iv [IV_SIZE ]; // Initialization Vector
188
- uint8_t challenged [10 ]; // Encrypted Challenge
189
- uint8_t cmac [4 ]; // Challenge Message Authentication Code
196
+ uint8_t challenged [SDLS_CHALLENGED_SIZE ]; // Encrypted Challenge
197
+ uint8_t cmac [SDLS_CMAC_SIZE ]; // Challenge Message Authentication Code
190
198
} SDLS_KEYDB_RPLY_t ;
191
199
#define SDLS_KEYDB_RPLY_SIZE (sizeof(SDLS_KEYDB_RPLY_t))
192
200
@@ -233,8 +241,6 @@ typedef struct
233
241
/*
234
242
** Telecommand (TC) Definitions
235
243
*/
236
- // typedef struct __attribute__ ((packed)) //__attribute__ ((packed)) is not easily supported in CFFI python. Only add
237
- // when CFFI properly supports packed & nonpacked structs.
238
244
typedef struct
239
245
{
240
246
uint8_t tfvn : 2 ; // Transfer Frame Version Number
@@ -312,19 +318,10 @@ typedef struct
312
318
} CCSDS_PUS_t ;
313
319
#define CCSDS_PUS_SIZE (sizeof(CCSDS_PUS_t))
314
320
315
- /* unused?
316
- typedef struct
317
- {
318
- uint8_t CmdHeader[CFE_SB_CMD_HDR_SIZE];
319
-
320
- } Crypto_NoArgsCmd_t;
321
- */
322
-
323
321
typedef struct
324
322
{
325
323
CCSDS_HDR_t hdr ;
326
324
CCSDS_PUS_t pus ;
327
- // CCSDS_2HDR_t cmd;
328
325
SDLS_TLV_t pdu ;
329
326
} CCSDS_t ;
330
327
#define CCSDS_SIZE (sizeof(CCSDS_t))
@@ -396,17 +393,13 @@ typedef struct
396
393
uint16_t fhp : 11 ; // First Header Pointer
397
394
// Sync Flag 0 = Contains position of the first byte of the first packet in the data field
398
395
// Sync Flag 1 = undefined
399
- // uint8_t tfshvn :2; // Transfer Frame Secondary Header Version Number - shall be 00
400
- // uint8_t tfshlen :6; // TFSH Length (max 64 Bytes)
401
396
} TM_FramePrimaryHeader_t ;
402
397
#define TM_FRAME_PRIMARYHEADER_SIZE (sizeof(TM_FramePrimaryHeader_t))
403
398
404
399
typedef struct
405
400
{
406
401
uint16_t spi ; // Security Parameter Index
407
402
uint8_t iv [IV_SIZE ]; // Initialization Vector for encryption
408
- // uint8_t sn[TM_SN_SIZE]; // Sequence Number for anti-replay
409
- // uint8_t pad[TM_PAD_SIZE]; // Count of the used fill Bytes
410
403
} TM_FrameSecurityHeader_t ;
411
404
#define TM_FRAME_SECHEADER_SIZE (sizeof(TM_FrameSecurityHeader_t))
412
405
@@ -462,8 +455,6 @@ typedef struct
462
455
{
463
456
uint16_t spi ; // Security Parameter Index
464
457
uint8_t iv [IV_SIZE ]; // Initialization Vector for encryption
465
- // uint8_t sn[TM_SN_SIZE]; // Sequence Number for anti-replay
466
- // uint8_t pad[TM_PAD_SIZE]; // Count of the used fill Bytes
467
458
} AOS_FrameSecurityHeader_t ;
468
459
#define AOS_FRAME_SECHEADER_SIZE (sizeof(AOS_FrameSecurityHeader_t))
469
460
0 commit comments