comparison src/cs/drivers/drv_core/security/secure_types.h @ 0:945cf7f506b2

src/cs: chipsetsw import from tcs211-fcmodem binary blobs and LCD demo files have been excluded, all line endings are LF only
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Sep 2016 22:50:11 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:945cf7f506b2
1 /* @(#) nom : secure_types.h SID: 1.2 date : 09/19/03 */
2 /* Filename: secure_types.h */
3 /* Version: 1.2 */
4 /******************************************************************************
5 * WIRELESS COMMUNICATION SYSTEM DEVELOPMENT
6 *
7 * (C) 2002 Texas Instruments France. All rights reserved
8 *
9 * Author : Constantin HAIDAMOUS
10 *
11 *
12 * Important Note
13 * --------------
14 *
15 * This S/W is a preliminary version. It contains information on a product
16 * under development and is issued for evaluation purposes only. Features
17 * characteristics, data and other information are subject to change.
18 *
19 * The S/W is furnished under Non Disclosure Agreement and may be used or
20 * copied only in accordance with the terms of the agreement. It is an offence
21 * to copy the software in any way except as specifically set out in the
22 * agreement. No part of this document may be reproduced or transmitted in any
23 * form or by any means, electronic or mechanical, including photocopying and
24 * recording, for any purpose without the express written permission of Texas
25 * Instruments Inc.
26 *
27 ******************************************************************************
28 *
29 * FILE NAME: secure_types.h
30 *
31 *
32 * PURPOSE:
33 *
34 *
35 * FILE REFERENCES:
36 *
37 * Name IO Description
38 * ------------- -- ---------------------------------------------
39 *
40 *
41 *
42 * EXTERNAL VARIABLES:
43 *
44 * Source: none
45 *
46 * Name Type IO Description
47 * ------------------- --------------- -- ----------------------------
48 *
49 *
50 *
51 * ABNORMAL TERMINATION CONDITIONS, ERROR AND WARNING MESSAGES:
52 *
53 *
54 *
55 * ASSUMPTION, CONSTRAINTS, RESTRICTIONS:
56 *
57 *
58 *
59 * NOTES:
60 *
61 *
62 *
63 * REQUIREMENTS/FUNCTIONAL SPECIFICATION REFERENCES:
64 *
65 *
66 *
67 *
68 * DEVELOPMENT HISTORY:
69 *
70 * Date Name(s) Version Description
71 * ---------- -------------------- ------- ---------------------------------
72 * 04/12/2002 Constantin HAIDAMOUS V1.0.0 First release
73 * 22-Apr-02 Francois AMAND V1.0.1 Update of secure status to
74 * facilitate integration in final
75 * ROM code.
76 * Data alignment in struture to
77 * optimize memory requirement.
78 * Management of global secure data.
79 * 28-Apr-02 Francois AMAND V1.0.2 Update some constants to be
80 * compliant with certificate
81 * definition.
82 * Add CALYPSO PLUS specific
83 * parameters structure.
84 * Differentiate Manufacturer and
85 * Platform certificate.
86 * Add debug request field in Manu-
87 * facturer certificate.
88 * Optimize certificate field size.
89 * Change commentary wrapper to be
90 * ANSI compliant.
91 * 29-Apr-02 Francois AMAND V1.0.3 Remove unused constant.
92 * Set under compilation flag the
93 * secure services.
94 * 14-May-02 Francois AMAND V1.0.4 Add CONF_CSI field in T_CONF_PARAM
95 * structure definition.
96 * Change name of CS_MODE to EX_CTRL
97 * Change size of DCCTRL_CSx to 8
98 * bits to optimize size and alignment.
99 * 17-May-02 Francois AMAND V1.0.5 Modification of hashing size for
100 * binding/unbinding.
101 * 17-May-02 Constantin HAIDAMOUS V1.0.6 Integration of data structure for
102 * binding/unbinding services API .
103 * 17-May-02 Francois AMAND V1.0.7 Integration of RSA S/W and Check
104 * ROM in Secure Services.
105 * Update of Secure Services manage-
106 * ment.
107 * 22-May-02 Constantin HAIDAMOUS V1.0.8 Changing RSA modulus length , Max
108 * RSA length =2048 bits. Adding initial
109 * vectore for Binding structure.
110 * 27-May-02 Francois AMAND V1.0.9 Changing SAMSON to CALYPSO.
111 * Addition of Secure Services for
112 * RUN Time checker.
113 * 28-May-02 Constantin HAIDAMOUS V1.0.10 Changing C_PLAT_SIG_SIZE to 4.
114 *
115 * 06-June-02 Constantin HAIDAMOUS V1.0.11 Changing Secure service API.
116 *
117 * 12-Jun-02 Francois AMAND V1.0.12 Update of T_CONF_PARAM according
118 * to last memory interface spec.
119 * 13-Jun-02 Constantin HAIDAMOUS V1.0.13 Update of T_UNBINDCTX for segmented
120 * unbind operation optimization.
121 * 14-Jun-02 Constantin HAIDAMOUS V1.0.14 Update of T_BINDCTX for segmented
122 * bind operation .
123 * 14-Jun-02 Francois AMAND V1.0.15 Force d_temp in Secure RAM.
124 * Remove other definitions.
125 * 25-Jun-02 Francois AMAND V1.0.16 Addition of Platform unbinding
126 * during boot concept under compi-
127 * lation flag C_PLATFORM_UNBIND_BOOT.
128 * 27-Jun-02 Constantin HAIDAMOUS V1.0.17 Adding C_SECURE_RNG_ALARM to E_SECURE_STATUS
129 * C_SECURE_RNG_ALARM = C_RNG_ALARM from Safenet
130 * 09-Jul-02 Constantin HAIDAMOUS V1.0.18 Adding Application ID and Timeout for Bind function
131 * 16-Jul-02 Francois AMAND V1.0.19 Add S/W pseudo-random generator.
132 * 19-Jul-02 Francois AMAND V1.0.20 Remove S/W pseudo-random.
133 * 01-Aug-02 Constantin HAIDAMOUS V1.0.21 Removing boolean b_HashDone in Bind and Unbind Context
134 * 27-Jan-03 Francois AMAND V2.0.0 Remove of C_PLATFORM_UNBIND_BOOT flag
135 * 27-Jan-03 Francois AMAND V2.0.1 Add compliance with SW@P 2.0 (REQ03047)
136 * 20-Mar-03 Francois AMAND V2.0.2 Code cleaning
137 *
138 * ALGORITHM:
139 *
140 *
141 *******************************************************************************/
142
143
144 #ifndef _SECURE_TYPES_H
145 #define _SECURE_TYPES_H
146
147 #ifndef C_SECURE_SERVICES
148 #define C_SECURE_SERVICES 1
149 #endif
150
151 #ifndef C_PLATFORM_UNBIND_BOOT
152 #define C_PLATFORM_UNBIND_BOOT 0
153 #endif
154
155 #ifndef C_CHIPSET
156 #define C_CHIPSET_CALYPSO 4
157 #define C_CHIPSET_CALYPSOPLUS 12
158 #define C_CHIPSET CHIPSET
159 #endif
160
161
162
163 /****************************************************************************
164 * Constants
165 ****************************************************************************/
166
167 #define C_WORD32LGB 4
168
169 #ifndef NULL /* To avoid conflict with other compilers */
170 #define NULL (UWORD32 *) 0x00000000L
171 #endif
172
173 /*Certificate block*/
174
175 /*Length in long word (32 bits)*/
176
177 #define C_SHA1HASHLG 5
178 #define C_MD5HASHLG 4
179
180 #define C_RSAKEYLG 64 /* Max Modulus size : 2048 bits */
181 #define C_RSASIGLG C_RSAKEYLG
182
183 #define C_DIE_ID_SIZE 2 /* DIE ID defined on 64-bits */
184
185 #define C_PLATFORM_DATA_SIZE 16048 /* Maximum value to have CertSize coded on 16-bits */
186
187 #if C_SECURE_SERVICES == 1
188 #define C_IVLG 2
189 #define C_TDESKEYLG 4
190 #define C_TDESKEYLGB C_TDESKEYLG * C_WORD32LGB
191 #define C_PLAT_SIG_SIZE 4 /* Must be a multiple of 64 bits */
192 #endif
193
194 #define C_MANUF_SIG_SIZE C_RSASIGLG
195
196
197 /*Certificate Type*/
198
199 #define C_CERTTYPE_MAN 0x00
200 #define C_CERTTYPE_PLAT 0x01
201
202 #if C_SECURE_SERVICES == 1
203 /*Confidentiality request*/
204
205 #define C_CRYPTVOID 0x00
206 #define C_CRYPTNOREQUEST 0x00
207 #define C_CRYPTREQUEST 0x01
208 #endif
209
210
211 /*Debug request*/
212
213 #define C_DEBUGNOREQUEST 0x00
214 #define C_DEBUGREQUEST 0x01
215
216
217 /*CS image check request*/
218
219 #define C_CSIMGNOREQUEST 0x00
220 #define C_CSIMGREQUEST 0x01
221
222
223 /*Temporary block*/
224
225 #define C_TEMPDATALG 32
226 #define C_TEMPDATALGB C_TEMPDATALG * C_WORD32LGB
227
228 #define C_CERT_TEMP_SWKEY 0
229 #define C_CERT_TEMP_DATA C_CERT_TEMP_SWKEY + C_TDESKEYLG
230
231
232 /****************************************************************************
233 * Structures
234 ****************************************************************************/
235
236 /* CALYPSO PLUS Parameters */
237 typedef struct {
238 /* External Memory Interface configuration */
239 UWORD16 d_conf_cs5;
240 UWORD16 d_exws_cs5;
241 UWORD16 d_ex_ctrl;
242
243 /* Authentication configuration */
244 UWORD16 d_cs_img_req;
245 UWORD32 d_flash_size;
246 UWORD32 d_granularity;
247 } T_CONF_PARAM;
248
249
250 /* RSA Public key */
251
252 typedef struct
253 {
254
255 UWORD32 a_Modulus[C_RSAKEYLG]; /*Public Modulus*/
256 UWORD32 d_ModulusLength; /*Public Modulus length in bytes*/
257 UWORD32 d_Exponent; /*Public Exponent*/
258
259 }T_RSAPUBKEY;
260
261
262 /*Certificate Structure*/
263
264 typedef struct
265 {
266
267 UWORD16 d_Certsize; /* Size of Certificate*/
268 UWORD8 d_Certtype; /* Type of Certificate*/
269 UWORD8 d_Debugrequest; /* Debug request*/
270 UWORD32 d_Addcode; /* Start Address of code*/
271 UWORD32 d_Codesize; /* Size of code*/
272 UWORD32 d_CodeStartAdd; /* Entry point address */
273 T_RSAPUBKEY d_Manpubkey; /* Manufacturer Public key*/
274 T_RSAPUBKEY d_Origpubkey; /* Originator Public key */
275 UWORD32 a_Origpubkeysig[C_MANUF_SIG_SIZE]; /* Originator Public key Signature*/
276 UWORD32 a_Swsig[C_MANUF_SIG_SIZE]; /* Software Signature*/
277 T_CONF_PARAM d_Confparam; /* Configuration parameters*/
278 UWORD32 a_die_id[C_DIE_ID_SIZE]; /* DIE ID field */
279
280 } T_MANUFACTURER_CERTIFICATE;
281
282
283
284 #if C_SECURE_SERVICES == 1
285 /*
286 * Define ROM secure service entry point address
287 */
288 #define C_ROM_SSERVICE_ENTRY_POINT_ADDR 0x00000024L
289
290 /*
291 * Definition of function pointer to use ROM Secure Services
292 */
293 typedef UWORD16 (*T_ROM_SSERVICE) (UWORD16, void *, void *);
294
295
296 typedef struct
297 {
298
299 UWORD16 d_Certsize; /* Size of Certificate*/
300 UWORD8 d_Certtype; /* Type of Certificate*/
301 UWORD8 d_Confrequest; /* Confidentiality request*/
302 UWORD32 d_Addcode; /* Start Address of code*/
303 UWORD32 d_Codesize; /* Size of code*/
304 UWORD32 d_AppID; /* Application ID*/
305 UWORD32 a_iv[C_IVLG]; /* Initial Vector for TDES CBC*/
306 UWORD32 a_Encswkey[C_TDESKEYLG]; /* Encrypted S/W key */
307 UWORD32 a_Swsig[C_PLAT_SIG_SIZE]; /* Software Signature*/
308 UWORD32 a_Certsig[C_PLAT_SIG_SIZE]; /* Certificate Signature*/
309
310 } T_PLATFORM_CERTIFICATE;
311
312
313 /*Unbind Context Structure used for segmented Unbind operation*/
314
315 typedef struct
316 {
317 UWORD32 d_Startpos; /*Start position of data to process */
318 UWORD32 d_Currentpos; /*Current position of data to process */
319 UWORD32 a_Currentdigest[C_MD5HASHLG]; /*Current digest*/
320 UWORD32 d_Digcount; /*Digest Count */
321 UWORD32 a_Currentiv[C_IVLG]; /*Current initial vector */
322 UWORD32 a_Encswkey[C_TDESKEYLG]; /*Encrypted TDES software Key */
323 UWORD32 a_iv[C_IVLG]; /*Initial Vector */
324 UWORD32 d_Codesize; /*Code size*/
325 UWORD32 d_AppID; /*Application ID*/
326 UWORD32 a_Swsig[C_PLAT_SIG_SIZE]; /*Software Signature*/
327 UWORD8 d_Confrequest; /*Confidentiality request*/
328 BOOLEAN b_UnbindDone; /*Set to 1 if data unbinding is done*/
329
330
331 } T_UNBINDCTX;
332
333
334 /*Bind Context Structure used for segmented Bind operation*/
335
336 typedef struct
337 {
338
339 UWORD32 d_Startpos; /*Start position of data to process*/
340 UWORD32 d_Currentpos; /*Current position of data to process */
341 UWORD32 a_Currentdigest[C_MD5HASHLG]; /*Current digest*/
342 UWORD32 d_Digcount; /*Digest Count */
343 UWORD32 a_Currentiv[C_IVLG]; /*Current initial vector */
344 UWORD32 a_Encswkey[C_TDESKEYLG]; /*Encrypted TDES software Key */
345 UWORD32 a_iv[C_IVLG]; /*Initial Vector */
346 UWORD32 d_Addcode; /*Store address of code */
347 UWORD32 d_Codesize; /*Code size*/
348 UWORD32 d_AppID; /*Application ID*/
349 UWORD8 d_Confrequest; /*Confidentiality request*/
350 BOOLEAN b_KeyCreateDone; /*Set to 1 if TDES software key creation is done */
351 BOOLEAN b_BindDone; /*Set to 1 if data binding is done*/
352
353 } T_BINDCTX;
354
355
356
357 typedef struct
358 {
359
360 T_PLATFORM_CERTIFICATE* p_Cert;
361 UWORD32* p_Code;
362 T_PLATFORM_CERTIFICATE* p_CertCtx;
363 T_UNBINDCTX* p_UnbindCtx;
364 UWORD32 d_Steplength;
365 BOOLEAN b_start;
366
367 } T_SSERVICE_UNBIND;
368
369
370
371 typedef struct
372 {
373
374 T_PLATFORM_CERTIFICATE* p_Cert;
375 UWORD32* p_Code;
376 T_PLATFORM_CERTIFICATE* p_CertCtx;
377 T_BINDCTX* p_BindCtx;
378 UWORD32 d_Steplength;
379 UWORD32 d_timeout;
380 BOOLEAN b_start;
381
382 } T_SSERVICE_BIND;
383
384
385 /*
386 * Structure definition for RSA S/W secure services
387 */
388 typedef struct
389 {
390 UWORD32 * p_datain;
391 UWORD32 * p_dataout;
392 UWORD32 output_length;
393 T_RSAPUBKEY * p_rsapubkey;
394 UWORD32 * p_rsaheap;
395 } T_SSERVICE_RSA;
396
397
398 /*
399 * Structure definition for Checker ROM secure services
400 */
401 typedef struct
402 {
403 UWORD16 d_checksum;
404 UWORD16 d_rom_id;
405 } T_SSERVICE_CHECKROM;
406
407
408 /*
409 * Structure definition for Run Time Checker secure services
410 */
411 typedef struct
412 {
413 UWORD32 * p_rsaheap;
414 T_MANUFACTURER_CERTIFICATE * p_certificate;
415 } T_SSERVICE_RUNTIMECHECKER;
416
417
418 /*
419 * Structure definition for Run Time Platform Data Checker secure services
420 */
421 typedef struct
422 {
423 T_PLATFORM_CERTIFICATE* p_Cert;
424 } T_SSERVICE_RUNTIME_PLAT_CHECKER;
425
426
427 #endif /* C_SECURE_SERVICES == 1 */
428
429 /****************************************************************************
430 * Global variables
431 ****************************************************************************/
432 #ifndef SECURE_GLOBAL
433 #define SECURE_GLOBAL extern
434 #endif
435
436 #ifdef _TMS470
437 #pragma DATA_SECTION(d_temp,".secdata")
438 #pragma DATA_SECTION(a_hash_certificate,".secdata")
439 #endif
440
441 SECURE_GLOBAL UWORD32 d_temp[C_TEMPDATALG]; /*Temporary data in Secure RAM*/
442 SECURE_GLOBAL UWORD32 a_hash_certificate[C_SHA1HASHLG]; /* SHA-1 hashing of Manufacturer Certificate */
443
444 /****************************************************************************
445 * Status
446 ****************************************************************************/
447
448 typedef enum
449 {
450
451 C_SECURE_ERROR = 0,
452 C_SECURE_SUCCESS = 1,
453 C_SECURE_INVALID_ID = 2,
454 C_SECURE_RNG_ALARM = 3,
455 C_SECURE_INVALID_DIE_ID = 4,
456 C_SECURE_BLANK_DIE_ID = 5
457
458 }E_SECURE_STATUS;
459
460
461 /****************************************************************************
462 * Function prototype for secure services
463 ****************************************************************************/
464
465 #if C_SECURE_SERVICES == 1
466 #define C_MAX_DEFINED_ID 6
467 #define C_SEC_SERVICE_BINDING_ID 0x0000
468 #define C_SEC_SERVICE_UNBINDING_ID 0x0001
469 #define C_SEC_SERVICE_RSA_ID 0x0002
470 #define C_SEC_SERVICE_CHECKROM_ID 0x0003
471 #define C_SEC_SERVICE_RUN_TIME_CHECKER_ID 0x0004
472 #define C_SEC_SERVICE_RUN_TIME_PLATFORM_DATA_CHECKER 0x0005
473
474 E_SECURE_STATUS ROM_Sservice_Unbind(UWORD16 reserved,
475 T_SSERVICE_UNBIND* p_StructUnbind);
476
477 E_SECURE_STATUS ROM_Sservice_Bind(UWORD16 reserved,
478 T_SSERVICE_BIND* p_StructBind);
479
480 E_SECURE_STATUS ROM_Sservice_Rsa(UWORD16 reserved,
481 T_SSERVICE_RSA* p_StructRsa);
482
483 E_SECURE_STATUS ROM_Sservice_CheckRom(UWORD16 reserved,
484 T_SSERVICE_CHECKROM* p_StructCheckRom);
485
486 E_SECURE_STATUS ROM_Sservice_RunTimeChecker(
487 UWORD16 reserved,
488 T_SSERVICE_RUNTIMECHECKER* p_StructRunTimeChecker);
489
490 E_SECURE_STATUS ROM_Sservice_RunTimePlatformDataChecker(
491 UWORD16 reserved,
492 T_SSERVICE_RUNTIME_PLAT_CHECKER* p_StructRunTimePlatChecker);
493
494 #endif
495
496 #endif /* _SECURE_TYPES_H */