summaryrefslogtreecommitdiff
path: root/peripheral/keystore/chaabi/libcc54/include/dx_driver_abi.h
blob: 33fced26409fc7203b1afa0682116c13ea5ef8f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
/*******************************************************************
* (c) Copyright 2011-2012 Discretix Technologies Ltd.              *
* This file is licensed under the terms provided in the file       *
* libcc54/LICENSE in this directory or a parent directory          *
********************************************************************/

#ifndef __SEP_DRIVER_ABI_H__
#define __SEP_DRIVER_ABI_H__

#ifdef __KERNEL__
#include <linux/types.h>
#ifndef INT32_MAX
#define INT32_MAX 0x7FFFFFFFL
#endif
#else
/* For inclusion in user space library */
#include <stdint.h>
#endif

#include <linux/ioctl.h>
#include <linux/errno.h>
#include "sep_rpc.h"

/* Proprietary error code for unexpected internal errors */
#define EBUG 999

/****************************/
/**** IOCTL return codes ****/
/*****************************************************************************
 ENOTTY  : Unknown IOCTL command					     *
 ENOSYS  : Unsupported/not-implemented (known) operation		     *
 EINVAL  : Invalid parameters                                                *
 EFAULT  : Bad pointers for given user memory space                          *
 EPERM   : Not enough permissions for given command                          *
 ENOMEM,EAGAIN: when not enough resources available for given op.            *
 EIO     : SeP HW error or another internal error (probably operation timed  *
	   out or unexpected behavior)                                       *
 EBUG    : Driver bug found ("assertion") - see system log                   *
*****************************************************************************/

/****** IOCTL commands ********/
/* The magic number appears free in Documentation/ioctl/ioctl-number.txt */
#define DXDI_IOC_MAGIC 0xD1

/* IOCTL ordinal numbers */
/*(for backward compatibility, add new ones only at end of list!) */
enum dxdi_ioc_nr {
	/* Version info. commands */
	DXDI_IOC_NR_GET_VER_MAJOR             = 0,
	DXDI_IOC_NR_GET_VER_MINOR             = 1,
	/* Context size queries */
	DXDI_IOC_NR_GET_SYMCIPHER_CTX_SIZE    = 2,
	DXDI_IOC_NR_GET_AUTH_ENC_CTX_SIZE     = 3,
	DXDI_IOC_NR_GET_MAC_CTX_SIZE          = 4,
	DXDI_IOC_NR_GET_HASH_CTX_SIZE         = 5,
	/* Init context commands */
	DXDI_IOC_NR_SYMCIPHER_INIT            = 7,
	DXDI_IOC_NR_AUTH_ENC_INIT             = 8,
	DXDI_IOC_NR_MAC_INIT                  = 9,
	DXDI_IOC_NR_HASH_INIT                 = 10,
	/* Processing commands */
	DXDI_IOC_NR_PROC_DBLK                 = 12,
	DXDI_IOC_NR_FIN_PROC                  = 13,
	/* "Integrated" processing operations */
	DXDI_IOC_NR_SYMCIPHER_PROC            = 14,
	DXDI_IOC_NR_AUTH_ENC_PROC             = 15,
	DXDI_IOC_NR_MAC_PROC                  = 16,
	DXDI_IOC_NR_HASH_PROC                 = 17,
	/* SeP RPC */
	DXDI_IOC_NR_SEP_RPC                   = 19,
	/* Memory registration */
	DXDI_IOC_NR_REGISTER_MEM4DMA          = 20,
	DXDI_IOC_NR_ALLOC_MEM4DMA             = 21,
	DXDI_IOC_NR_FREE_MEM4DMA              = 22,
	/* SeP Applets API */
	DXDI_IOC_NR_SEPAPP_SESSION_OPEN       = 23,
	DXDI_IOC_NR_SEPAPP_SESSION_CLOSE      = 24,
	DXDI_IOC_NR_SEPAPP_COMMAND_INVOKE     = 25,
	/* Combined mode */
	DXDI_IOC_NR_COMBINED_INIT             = 26,
	DXDI_IOC_NR_COMBINED_PROC_DBLK        = 27,
	DXDI_IOC_NR_COMBINED_PROC_FIN         = 28,
	DXDI_IOC_NR_COMBINED_PROC             = 29,

	/* AES IV set/get API */
	DXDI_IOC_NR_SET_IV                    = 30,
	DXDI_IOC_NR_GET_IV                    = 31,
	DXDI_IOC_NR_MAX = DXDI_IOC_NR_GET_IV
};

/* In case error is not DXDI_RET_ESEP these are the
*  errors embedded in the error info field "error_info" */
enum dxdi_error_info {
	DXDI_ERROR_NULL = 0,
	DXDI_ERROR_BAD_CTX = 1,
	DXDI_ERROR_UNSUP = 2,
	DXDI_ERROR_INVAL_MODE = 3,
	DXDI_ERROR_INVAL_DIRECTION = 4,
	DXDI_ERROR_INVAL_KEY_SIZE = 5,
	DXDI_ERROR_INVAL_NONCE_SIZE = 6,
	DXDI_ERROR_INVAL_TAG_SIZE = 7,
	DXDI_ERROR_INVAL_DIN_PTR = 8,
	DXDI_ERROR_INVAL_DOUT_PTR = 9,
	DXDI_ERROR_INVAL_DATA_SIZE = 10,
	DXDI_ERROR_DIN_DOUT_OVERLAP = 11,
	DXDI_ERROR_INTERNAL = 12,
	DXDI_ERROR_NO_RESOURCE = 13,
	DXDI_ERROR_FATAL = 14,
	DXDI_ERROR_INFO_RESERVE32B = INT32_MAX
};

/* ABI Version info. */
#define DXDI_VER_MAJOR 1
#define DXDI_VER_MINOR DXDI_IOC_NR_MAX

/******************************/
/* IOCTL commands definitions */
/******************************/
/* Version info. commands */
#define DXDI_IOC_GET_VER_MAJOR _IOR(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_GET_VER_MAJOR, uint32_t)
#define DXDI_IOC_GET_VER_MINOR _IOR(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_GET_VER_MINOR, uint32_t)
/* Context size queries */
#define DXDI_IOC_GET_SYMCIPHER_CTX_SIZE _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_GET_SYMCIPHER_CTX_SIZE,\
		struct dxdi_get_sym_cipher_ctx_size_params)
#define DXDI_IOC_GET_AUTH_ENC_CTX_SIZE _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_GET_AUTH_ENC_CTX_SIZE,\
		struct dxdi_get_auth_enc_ctx_size_params)
#define DXDI_IOC_GET_MAC_CTX_SIZE _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_GET_MAC_CTX_SIZE,\
		struct dxdi_get_mac_ctx_size_params)
#define DXDI_IOC_GET_HASH_CTX_SIZE _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_GET_HASH_CTX_SIZE,\
		struct dxdi_get_hash_ctx_size_params)
/* Init. Sym. Crypto. */
#define DXDI_IOC_SYMCIPHER_INIT _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_SYMCIPHER_INIT, struct dxdi_sym_cipher_init_params)
#define DXDI_IOC_AUTH_ENC_INIT _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_AUTH_ENC_INIT, struct dxdi_auth_enc_init_params)
#define DXDI_IOC_MAC_INIT _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_MAC_INIT, struct dxdi_mac_init_params)
#define DXDI_IOC_HASH_INIT _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_HASH_INIT, struct dxdi_hash_init_params)

/* Sym. Crypto. Processing commands */
#define DXDI_IOC_PROC_DBLK _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_PROC_DBLK, struct dxdi_process_dblk_params)
#define DXDI_IOC_FIN_PROC _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_FIN_PROC, struct dxdi_fin_process_params)

/* Integrated Sym. Crypto. */
#define DXDI_IOC_SYMCIPHER_PROC _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_SYMCIPHER_PROC, struct dxdi_sym_cipher_proc_params)
#define DXDI_IOC_AUTH_ENC_PROC _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_AUTH_ENC_PROC, struct dxdi_auth_enc_proc_params)
#define DXDI_IOC_MAC_PROC _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_MAC_PROC, struct dxdi_mac_proc_params)
#define DXDI_IOC_HASH_PROC _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_HASH_PROC, struct dxdi_hash_proc_params)

/* AES Initial Vector set/get */
#define DXDI_IOC_SET_IV _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_SET_IV, struct dxdi_aes_iv_params)
#define DXDI_IOC_GET_IV _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_GET_IV, struct dxdi_aes_iv_params)

/* Combined mode  */
#define DXDI_IOC_COMBINED_INIT _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_COMBINED_INIT,\
		struct dxdi_combined_init_params)
#define DXDI_IOC_COMBINED_PROC_DBLK _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_COMBINED_PROC_DBLK,\
		struct dxdi_combined_proc_dblk_params)
#define DXDI_IOC_COMBINED_PROC_FIN _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_COMBINED_PROC_FIN,\
		struct dxdi_combined_proc_params)
#define DXDI_IOC_COMBINED_PROC _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_COMBINED_PROC,\
		struct dxdi_combined_proc_params)

/* SeP RPC */
#define DXDI_IOC_SEP_RPC _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_SEP_RPC, struct dxdi_sep_rpc_params)
/* Memory registration */
#define DXDI_IOC_REGISTER_MEM4DMA _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_REGISTER_MEM4DMA, \
		struct dxdi_register_mem4dma_params)
#define DXDI_IOC_ALLOC_MEM4DMA _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_ALLOC_MEM4DMA, \
		struct dxdi_alloc_mem4dma_params)
#define DXDI_IOC_FREE_MEM4DMA _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_FREE_MEM4DMA, \
		struct dxdi_free_mem4dma_params)
/* SeP Applets API */
#define DXDI_IOC_SEPAPP_SESSION_OPEN _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_SEPAPP_SESSION_OPEN, \
		struct dxdi_sepapp_session_open_params)
#define DXDI_IOC_SEPAPP_SESSION_CLOSE _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_SEPAPP_SESSION_CLOSE, \
		struct dxdi_sepapp_session_close_params)
#define DXDI_IOC_SEPAPP_COMMAND_INVOKE _IORW(DXDI_IOC_MAGIC,\
		DXDI_IOC_NR_SEPAPP_COMMAND_INVOKE, \
		struct dxdi_sepapp_command_invoke_params)


/*** ABI constants ***/
/* Max. symmetric crypto key size (512b) */
#define DXDI_SYM_KEY_SIZE_MAX 64 /*octets*/
/* Max. MAC key size (applicable to HMAC-SHA512) */
#define DXDI_MAC_KEY_SIZE_MAX 128 /*octets*/
/* AES IV/Counter size (128b) */
#define DXDI_AES_BLOCK_SIZE 16 /*octets*/
/* DES IV size (64b) */
#define DXDI_DES_BLOCK_SIZE 8 /*octets*/
/* Max. Nonce size */
#define DXDI_NONCE_SIZE_MAX 16 /*octets*/
/* Max. digest size */
#define DXDI_DIGEST_SIZE_MAX 64 /*octets*/
/* Max. nodes */
#define DXDI_COMBINED_NODES_MAX 4
#define DXDI_AES_IV_SIZE DXDI_AES_BLOCK_SIZE

/*** ABI data types ***/

enum dxdi_cipher_direction {
	DXDI_CDIR_ENC = 0,
	DXDI_CDIR_DEC = 1,
	DXDI_CDIR_MAX = DXDI_CDIR_DEC,
	DXDI_CDIR_RESERVE32B = INT32_MAX
};

enum dxdi_sym_cipher_type {
	DXDI_SYMCIPHER_NONE = 0,
	_DXDI_SYMCIPHER_AES_FIRST = 1,
	DXDI_SYMCIPHER_AES_XXX  = _DXDI_SYMCIPHER_AES_FIRST,
	DXDI_SYMCIPHER_AES_ECB  = _DXDI_SYMCIPHER_AES_FIRST + 1,
	DXDI_SYMCIPHER_AES_CBC  = _DXDI_SYMCIPHER_AES_FIRST + 2,
	DXDI_SYMCIPHER_AES_CTR  = _DXDI_SYMCIPHER_AES_FIRST + 3,
	DXDI_SYMCIPHER_AES_XTS  = _DXDI_SYMCIPHER_AES_FIRST + 4,
	_DXDI_SYMCIPHER_AES_LAST = DXDI_SYMCIPHER_AES_XTS,
	_DXDI_SYMCIPHER_DES_FIRST = 0x11,
	DXDI_SYMCIPHER_DES_ECB  = _DXDI_SYMCIPHER_DES_FIRST,
	DXDI_SYMCIPHER_DES_CBC  = _DXDI_SYMCIPHER_DES_FIRST + 1,
	_DXDI_SYMCIPHER_DES_LAST = DXDI_SYMCIPHER_DES_CBC,
	_DXDI_SYMCIPHER_C2_FIRST = 0x21,
	DXDI_SYMCIPHER_C2_ECB   = _DXDI_SYMCIPHER_C2_FIRST,
	DXDI_SYMCIPHER_C2_CBC   = _DXDI_SYMCIPHER_C2_FIRST + 1,
	_DXDI_SYMCIPHER_C2_LAST = DXDI_SYMCIPHER_C2_CBC,
	DXDI_SYMCIPHER_RC4  = 0x31, /* Supported in message API only */
	DXDI_SYMCIPHER_RESERVE32B = INT32_MAX
};


enum dxdi_auth_enc_type {
	DXDI_AUTHENC_NONE = 0,
	DXDI_AUTHENC_AES_CCM = 1,
	DXDI_AUTHENC_AES_GCM = 2,
	DXDI_AUTHENC_MAX = DXDI_AUTHENC_AES_GCM,
	DXDI_AUTHENC_RESERVE32B = INT32_MAX
};

enum dxdi_mac_type {
	DXDI_MAC_NONE     = 0,
	DXDI_MAC_HMAC     = 1,
	DXDI_MAC_AES_MAC  = 2,
	DXDI_MAC_AES_CMAC = 3,
	DXDI_MAC_AES_XCBC_MAC = 4,
	DXDI_MAC_MAX = DXDI_MAC_AES_XCBC_MAC,
	DXDI_MAC_RESERVE32B = INT32_MAX
};

enum dxdi_hash_type {
	DXDI_HASH_NONE = 0,
	DXDI_HASH_MD5  = 1,
	DXDI_HASH_SHA1 = 2,
	DXDI_HASH_SHA224 = 3,
	DXDI_HASH_SHA256 = 4,
	DXDI_HASH_SHA384 = 5,
	DXDI_HASH_SHA512 = 6,
	DXDI_HASH_MAX = DXDI_HASH_SHA512,
	DXDI_HASH_RESERVE32B = INT32_MAX
};

enum dxdi_data_block_type {
	DXDI_DATA_TYPE_NULL = 0,
	DXDI_DATA_TYPE_TEXT = 1,  /* Plain/cipher text */
	DXDI_DATA_TYPE_ADATA = 2, /* Additional/Associated data for AEAD */
	DXDI_DATA_TYPE_MAX = DXDI_DATA_TYPE_ADATA,
	DXDI_DATA_TYPE_RESERVE32B = INT32_MAX
};

enum dxdi_input_engine_type {
	DXDI_INPUT_NULL = 0,     /* no input */
	DXDI_INPUT_ENGINE_1 = 1,
	DXID_INPUT_ENGINE_2 = 2,
	DXDI_INPUT_DIN = 15,     /* input from DIN */
	DXDI_INPUT_ENGINE_RESERVE32B = INT32_MAX,
};

/* Properties of specific ciphers */
/* (for use in alg_specific union of dxdi_cipher_props) */
struct dxdi_des_cbc_props {
	uint8_t iv[DXDI_DES_BLOCK_SIZE];
};
struct dxdi_aes_cbc_props {
	uint8_t iv[DXDI_AES_BLOCK_SIZE];
};
struct dxdi_aes_ctr_props {
	uint8_t cntr[DXDI_AES_BLOCK_SIZE];
};
struct dxdi_aes_xts_props {
	uint8_t init_tweak[DXDI_AES_BLOCK_SIZE];
	unsigned long data_unit_size;
};
struct dxdi_c2_cbc_props {
	uint32_t reset_interval;
};

struct dxdi_sym_cipher_props {
	enum dxdi_sym_cipher_type cipher_type;
	enum dxdi_cipher_direction direction;
	uint8_t key_size; /* In octets */
	uint8_t key[DXDI_SYM_KEY_SIZE_MAX];
	union { /* cipher specific properties */
		struct dxdi_des_cbc_props des_cbc;
		struct dxdi_aes_cbc_props aes_cbc;
		struct dxdi_aes_ctr_props aes_ctr;
		struct dxdi_aes_xts_props aes_xts;
		struct dxdi_c2_cbc_props c2_cbc;
		uint32_t __assure_32b_union_alignment;
		/* Reserve space for future extension?*/
	} alg_specific;
};

struct dxdi_auth_enc_props {
	enum dxdi_auth_enc_type ae_type;
	enum dxdi_cipher_direction direction;
	uint32_t adata_size; /* In octets */
	uint32_t text_size; /* In octets */
	uint8_t key_size; /* In octets */
	uint8_t nonce_size; /* In octets */
	uint8_t tag_size; /* In octets */
	uint8_t key[DXDI_SYM_KEY_SIZE_MAX];
	uint8_t nonce[DXDI_NONCE_SIZE_MAX];
};

/* Properties specific for HMAC */
/* (for use in properties union of dxdi_mac_props) */
struct dxdi_hmac_props {
	enum dxdi_hash_type hash_type;
};

struct dxdi_aes_mac_props {
	uint8_t iv[DXDI_AES_BLOCK_SIZE];
};

struct dxdi_mac_props {
	enum dxdi_mac_type mac_type;
	uint32_t key_size; /* In octets */
	uint8_t  key[DXDI_MAC_KEY_SIZE_MAX];
	union { /* Union of algorithm specific properties */
		struct dxdi_hmac_props hmac;
		struct dxdi_aes_mac_props aes_mac;
		uint32_t __assure_32b_union_alignment;
		/* Reserve space for future extension?*/
	} alg_specific;
};

/* Combined mode props */
struct dxdi_combined_node_props {
	uint32_t *context;
	enum dxdi_input_engine_type eng_input;
};

struct dxdi_combined_props {
	struct dxdi_combined_node_props node_props[DXDI_COMBINED_NODES_MAX];
};

/*** IOCTL commands parameters structures ***/

struct dxdi_get_sym_cipher_ctx_size_params {
	enum dxdi_sym_cipher_type sym_cipher_type; /*[in]*/
	uint32_t ctx_size; /*[out]*/
};

struct dxdi_get_auth_enc_ctx_size_params {
	enum dxdi_auth_enc_type ae_type; /*[in]*/
	uint32_t ctx_size; /*[out]*/
};

struct dxdi_get_mac_ctx_size_params {
	enum dxdi_mac_type mac_type; /*[in]*/
	uint32_t ctx_size; /*[out]*/
};

struct dxdi_get_hash_ctx_size_params {
	enum dxdi_hash_type hash_type; /*[in]*/
	uint32_t ctx_size; /*[out]*/
};

/* Init params */
struct dxdi_sym_cipher_init_params {
	uint32_t *context_buf; /*[in]*/
	struct dxdi_sym_cipher_props props; /*[in]*/
	uint32_t error_info; /*[out]*/
};

struct dxdi_auth_enc_init_params {
	uint32_t *context_buf; /*[in]*/
	struct dxdi_auth_enc_props props; /*[in]*/
	uint32_t error_info; /*[out]*/
};

struct dxdi_mac_init_params {
	uint32_t *context_buf; /*[in]*/
	struct dxdi_mac_props props; /*[in]*/
	uint32_t error_info; /*[out]*/
};

struct dxdi_hash_init_params {
	uint32_t *context_buf; /*[in]*/
	enum dxdi_hash_type hash_type; /*[in]*/
	uint32_t error_info; /*[out]*/
};

/* Processing params */
struct dxdi_process_dblk_params {
	uint32_t *context_buf; /*[in]*/
	uint8_t *data_in; /*[in]*/
	uint8_t *data_out; /*[in]*/
	enum dxdi_data_block_type data_block_type; /*[in]*/
	uint32_t data_in_size; /*[in]*/
	uint32_t error_info; /*[out]*/
};

struct dxdi_fin_process_params {
	uint32_t *context_buf; /*[in]*/
	uint8_t *data_in; /*[in]*/
	uint8_t *data_out; /*[in]*/
	uint32_t data_in_size; /*[in] (octets)*/
	uint8_t digest_or_mac[DXDI_DIGEST_SIZE_MAX]; /*[out]*/
	uint8_t digest_or_mac_size; /*[out] (octets)*/
	uint32_t error_info; /*[out]*/
};

struct dxdi_sym_cipher_proc_params {
	uint32_t *context_buf; /*[in]*/
	struct dxdi_sym_cipher_props props; /*[in]*/
	uint8_t *data_in; /*[in]*/
	uint8_t *data_out; /*[in]*/
	uint32_t data_in_size; /*[in] (octets)*/
	uint32_t error_info; /*[out]*/
};

struct dxdi_auth_enc_proc_params {
	uint32_t *context_buf; /*[in]*/
	struct dxdi_auth_enc_props props; /*[in]*/
	uint8_t *adata; /*[in]*/
	uint8_t *text_data; /*[in]*/
	uint8_t *data_out; /*[in] */
	uint8_t tag[DXDI_DIGEST_SIZE_MAX]; /*[out]*/
	uint32_t error_info; /*[out]*/
};

struct dxdi_mac_proc_params {
	uint32_t *context_buf; /*[in]*/
	struct dxdi_mac_props props; /*[in]*/
	uint8_t *data_in; /*[in]*/
	uint32_t data_in_size; /*[in] (octets)*/
	uint8_t mac[DXDI_DIGEST_SIZE_MAX]; /*[out]*/
	uint8_t mac_size; /*[out] (octets)*/
	uint32_t error_info; /*[out]*/
};

struct dxdi_hash_proc_params {
	uint32_t *context_buf; /*[in]*/
	enum dxdi_hash_type hash_type; /*[in]*/
	uint8_t *data_in; /*[in]*/
	uint32_t data_in_size; /*[in] (octets)*/
	uint8_t digest[DXDI_DIGEST_SIZE_MAX]; /*[out]*/
	uint8_t digest_size; /*[out] (octets)*/
	uint32_t error_info; /*[out]*/
};

struct dxdi_aes_iv_params {
	uint32_t *context_buf; /*[in]*/
	uint8_t iv_ptr[DXDI_AES_IV_SIZE]; /*[in]/[out]*/
};

/* Combined params */
struct dxdi_combined_init_params {
	struct dxdi_combined_props props; /*[in]*/
	uint32_t error_info; /*[out]*/
};

struct dxdi_combined_proc_dblk_params {
	struct dxdi_combined_props props; /*[in]*/
	uint8_t *data_in; /*[in]*/
	uint8_t *data_out; /*[out]*/
	uint32_t data_in_size; /*[in] (octets)*/
	uint32_t error_info; /*[out]*/
};

/* the structure used in finalize and integrated processing */
struct dxdi_combined_proc_params {
	struct dxdi_combined_props props; /*[in]*/
	uint8_t *data_in; /*[in]*/
	uint8_t *data_out; /*[out]*/
	uint32_t data_in_size; /*[in] (octets)*/
	uint8_t auth_data[DXDI_DIGEST_SIZE_MAX]; /*[out]*/
	uint8_t auth_data_size; /*[out] (octets)*/
	uint32_t error_info; /*[out]*/
};

/**************************************/
/* Memory references and registration */
/**************************************/

enum dxdi_data_direction {
	DXDI_DATA_NULL = 0,
	DXDI_DATA_TO_DEVICE = 1,
	DXDI_DATA_FROM_DEVICE = (1<<1),
	DXDI_DATA_BIDIR = (DXDI_DATA_TO_DEVICE |  DXDI_DATA_FROM_DEVICE)
};

/* Reference to pre-registered memory */
typedef int dxdi_memref_id_t;
#define DXDI_MEMREF_ID_NULL -1

struct dxdi_memref {
	enum dxdi_data_direction dma_direction;
	/* Memory reference ID - DXDI_MEMREF_ID_NULL if not registered */
	dxdi_memref_id_t ref_id;
	/* Start address of a non-registered memory or offset within a
	   registered memory */
	unsigned long start_or_offset;
	/* Size in bytes of non-registered buffer or size of chunk within a
	   registered buffer */
	unsigned long size;
};

struct dxdi_register_mem4dma_params {
	struct dxdi_memref memref; /*[in]*/
	dxdi_memref_id_t memref_id; /*[out]*/
};

struct dxdi_alloc_mem4dma_params {
	unsigned long size; /*[in]*/
	dxdi_memref_id_t memref_id; /*[out]*/
};

struct dxdi_free_mem4dma_params {
	dxdi_memref_id_t memref_id; /*[in]*/
};

/***********/
/* SeP-RPC */
/***********/
struct dxdi_sep_rpc_params {
	seprpc_agent_id_t agent_id; /*[in]*/
	seprpc_func_id_t func_id; /*[in]*/
	struct dxdi_memref mem_refs[SEP_RPC_MAX_MEMREF_PER_FUNC]; /*[in]*/
	unsigned long rpc_params_size; /*[in]*/
	struct seprpc_params *rpc_params; /*[in]*/
	/* rpc_params to be copied into kernel DMA buffer */
	seprpc_retcode_t error_info; /*[out]*/
};

/***************/
/* SeP Applets */
/***************/

enum dxdi_sepapp_param_type {
	DXDI_SEPAPP_PARAM_NULL = 0,
	DXDI_SEPAPP_PARAM_VAL = 1,
	DXDI_SEPAPP_PARAM_MEMREF = 2,
	DXDI_SEPAPP_PARAM_RESERVE32B = 0x7FFFFFFF
};

struct dxdi_val_param {
	enum dxdi_data_direction copy_dir; /* Copy direction */
	uint32_t data[2];
};

#define SEP_APP_PARAMS_MAX 4

struct dxdi_sepapp_params {
	enum dxdi_sepapp_param_type params_types[SEP_APP_PARAMS_MAX];
	union {
		struct dxdi_val_param val;
		struct dxdi_memref memref;
	} params[SEP_APP_PARAMS_MAX];
};

/* SeP modules ID for returnOrigin */
enum dxdi_sep_module {
	DXDI_SEP_MODULE_NULL        = 0,
	DXDI_SEP_MODULE_HOST_DRIVER = 1,
	DXDI_SEP_MODULE_SW_QUEUE    = 2, /* SW-queue task: Inc. desc. parsers */
	DXDI_SEP_MODULE_APP_MGR     = 3, /* Applet Manager*/
	DXDI_SEP_MODULE_APP         = 4, /* Applet */
	DXDI_SEP_MODULE_RPC_AGENT   = 5, /* Down to RPC parsers */
	DXDI_SEP_MODULE_SYM_CRYPTO  = 6, /* Symmetric crypto driver */
	DXDI_SEP_MODULE_RESERVE32B  = 0x7FFFFFFF
};

#define DXDI_SEPAPP_UUID_SIZE 16
typedef uint8_t dxdi_sepapp_uuid_t[DXDI_SEPAPP_UUID_SIZE];

typedef int dxdi_sepapp_session_id_t;
#define DXDI_SEPAPP_SESSION_INVALID (-1)

struct dxdi_sepapp_session_open_params {
	dxdi_sepapp_uuid_t app_uuid; /*[in]*/
	uint32_t auth_method; /*[in]*/
	uint32_t auth_data[3]; /*[in]*/
	struct dxdi_sepapp_params app_auth_data; /*[in/out]*/
	dxdi_sepapp_session_id_t session_id; /*[out]*/
	enum dxdi_sep_module sep_ret_origin; /*[out]*/
	uint32_t error_info; /*[out]*/
};

struct dxdi_sepapp_session_close_params {
	dxdi_sepapp_session_id_t session_id; /*[in]*/
};

struct dxdi_sepapp_command_invoke_params {
	dxdi_sepapp_session_id_t session_id; /*[in]*/
	uint32_t command_id; /*[in]*/
	struct dxdi_sepapp_params command_params; /*[in/out]*/
	enum dxdi_sep_module sep_ret_origin; /*[out]*/
	uint32_t error_info; /*[out]*/
};

#endif /*__SEP_DRIVER_ABI_H__*/