cryptocore_ioctl_header.h 3.42 KB
Newer Older
Naga Suramouli's avatar
Naga Suramouli committed
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
/* 
* cryptocore_ioctl_header.h - the header file with the ioctl definitions.
* The declarations here have to be in a header file, because
* they need to be known both the kernel module in *_driver.c
* and the application *_app.c 
*/

#include <linux/ioctl.h>

// CryptoCore Struct Declarations:
typedef struct MontMult_params{
	__u32 prec;
	__u32 f_sel;
	__u32 sec_calc;
	__u32 n[128];
	__u32 a[128];
	__u32 b[128];
	__u32 c[128];
} MontMult_params_t;

typedef struct MontR_params{
	__u32 prec;
	__u32 f_sel;
	__u32 sec_calc;
	__u32 n[128];
	__u32 r[128];
} MontR_params_t;

typedef struct MontR2_params{
	__u32 prec;
	__u32 f_sel;
	__u32 sec_calc;
	__u32 n[128];
	__u32 r2[128];
} MontR2_params_t;

typedef struct MontExp_params{
	__u32 prec;
	__u32 f_sel;
	__u32 sec_calc;
	__u32 n[128];
	__u32 b[128];
	__u32 e[128];
	__u32 c[128];
} MontExp_params_t;

typedef struct ModAdd_params{
	__u32 prec;
	__u32 f_sel;
	__u32 sec_calc;
	__u32 n[128];
	__u32 a[128];
	__u32 b[128];
	__u32 c[128];
} ModAdd_params_t;

typedef struct ModSub_params{
	__u32 prec;
	__u32 f_sel;
	__u32 sec_calc;
	__u32 n[128];
	__u32 a[128];
	__u32 b[128];
	__u32 c[128];
} ModSub_params_t;

typedef struct CopyH2V_params{
	__u32 prec;
	__u32 f_sel;
	__u32 sec_calc;
	__u32 a[128];
	__u32 acopy[128];
} CopyH2V_params_t;

typedef struct CopyV2V_params{
	__u32 prec;
	__u32 f_sel;
	__u32 sec_calc;
	__u32 a[128];
	__u32 acopy[128];
} CopyV2V_params_t;

typedef struct CopyH2H_params{
	__u32 prec;
	__u32 f_sel;
	__u32 sec_calc;
	__u32 a[128];
	__u32 acopy[128];
} CopyH2H_params_t;

typedef struct CopyV2H_params{
	__u32 prec;
	__u32 f_sel;
	__u32 sec_calc;
	__u32 a[128];
	__u32 acopy[128];
} CopyV2H_params_t;

typedef struct MontMult1_params{
	__u32 prec;
	__u32 f_sel;
	__u32 sec_calc;
	__u32 n[128];
	__u32 b[128];
	__u32 c[128];
} MontMult1_params_t;

typedef struct ModExp_params{
	__u32 prec;
	__u32 f_sel;
	__u32 sec_calc;
	__u32 n[128];
	__u32 b[128];
	__u32 e[128];
	__u32 c[128];
} ModExp_params_t;

typedef struct ModRed_params{
	__u32 prec;
	__u32 f_sel;
	__u32 sec_calc;
	__u32 n[64];
	__u32 a[128];
	__u32 c[128];
} ModRed_params_t ;

// Add CryptoCore Struct Declarations here...



#define IOCTL_BASE 'k' 					// magic number

// NOTE: magic | cmdnumber | size of data to pass
#define 	IOCTL_SET_TRNG_CMD		_IOW(IOCTL_BASE,   1, __u32)
#define 	IOCTL_SET_TRNG_CTR		_IOW(IOCTL_BASE,   2, __u32)
#define 	IOCTL_SET_TRNG_TSTAB	_IOW(IOCTL_BASE,   3, __u32)
#define 	IOCTL_SET_TRNG_TSAMPLE	_IOW(IOCTL_BASE,   4, __u32)
#define 	IOCTL_READ_TRNG_FIFO	_IOR(IOCTL_BASE,   5, __u32)

#define		IOCTL_MWMAC_MONTMULT	_IOWR(IOCTL_BASE,  6, MontMult_params_t)
#define		IOCTL_MWMAC_MONTR		_IOWR(IOCTL_BASE,  7, MontR_params_t)
#define		IOCTL_MWMAC_MONTR2		_IOWR(IOCTL_BASE,  8, MontR2_params_t)
#define		IOCTL_MWMAC_MONTEXP		_IOWR(IOCTL_BASE,  9, MontExp_params_t)
#define		IOCTL_MWMAC_MODADD		_IOWR(IOCTL_BASE, 10, ModAdd_params_t)
#define		IOCTL_MWMAC_MODSUB		_IOWR(IOCTL_BASE, 11, ModSub_params_t)
#define		IOCTL_MWMAC_COPYH2V		_IOWR(IOCTL_BASE, 12, CopyH2V_params_t)
#define		IOCTL_MWMAC_COPYV2V		_IOWR(IOCTL_BASE, 13, CopyV2V_params_t)
#define		IOCTL_MWMAC_COPYH2H		_IOWR(IOCTL_BASE, 14, CopyH2H_params_t)
#define		IOCTL_MWMAC_COPYV2H		_IOWR(IOCTL_BASE, 15, CopyV2H_params_t)
#define		IOCTL_MWMAC_MONTMULT1	_IOWR(IOCTL_BASE, 16, MontMult1_params_t)
#define		IOCTL_MWMAC_MODEXP		_IOWR(IOCTL_BASE, 17, ModExp_params_t)
#define		IOCTL_MWMAC_MODRED		_IOWR(IOCTL_BASE, 18, ModRed_params_t)

// Define further IOCTL commands here...