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#ifndef _ZCRYPT_API_H_
30#define _ZCRYPT_API_H_
31
32#include <linux/atomic.h>
33#include <asm/debug.h>
34#include <asm/zcrypt.h>
35#include "ap_bus.h"
36
37
38#define ICAZ90STATUS _IOR(ZCRYPT_IOCTL_MAGIC, 0x10, struct ica_z90_status)
39#define Z90STAT_PCIXCCCOUNT _IOR(ZCRYPT_IOCTL_MAGIC, 0x43, int)
40
41
42
43
44
45struct ica_z90_status {
46 int totalcount;
47 int leedslitecount;
48 int leeds2count;
49
50 int requestqWaitCount;
51 int pendingqWaitCount;
52 int totalOpenCount;
53 int cryptoDomain;
54
55
56 unsigned char status[64];
57
58 unsigned char qdepth[64];
59};
60
61
62
63
64
65
66
67
68
69#define ZCRYPT_PCICA 1
70#define ZCRYPT_PCICC 2
71#define ZCRYPT_PCIXCC_MCL2 3
72#define ZCRYPT_PCIXCC_MCL3 4
73#define ZCRYPT_CEX2C 5
74#define ZCRYPT_CEX2A 6
75#define ZCRYPT_CEX3C 7
76#define ZCRYPT_CEX3A 8
77#define ZCRYPT_CEX4 10
78#define ZCRYPT_CEX5 11
79
80
81
82
83
84
85#define ZCRYPT_RNG_BUFFER_SIZE 4096
86
87struct zcrypt_device;
88
89struct zcrypt_ops {
90 long (*rsa_modexpo)(struct zcrypt_device *, struct ica_rsa_modexpo *);
91 long (*rsa_modexpo_crt)(struct zcrypt_device *,
92 struct ica_rsa_modexpo_crt *);
93 long (*send_cprb)(struct zcrypt_device *, struct ica_xcRB *);
94 long (*send_ep11_cprb)(struct zcrypt_device *, struct ep11_urb *);
95 long (*rng)(struct zcrypt_device *, char *);
96 struct list_head list;
97 struct module *owner;
98 int variant;
99 char name[128];
100};
101
102struct zcrypt_device {
103 struct list_head list;
104 spinlock_t lock;
105 struct kref refcount;
106 struct ap_device *ap_dev;
107 struct zcrypt_ops *ops;
108 int online;
109
110 int user_space_type;
111 char *type_string;
112 int min_mod_size;
113 int max_mod_size;
114 int short_crt;
115 int speed_rating;
116
117 int request_count;
118
119 struct ap_message reply;
120 int max_exp_bit_length;
121
122 debug_info_t *dbf_area;
123};
124
125
126extern atomic_t zcrypt_rescan_req;
127
128struct zcrypt_device *zcrypt_device_alloc(size_t);
129void zcrypt_device_free(struct zcrypt_device *);
130void zcrypt_device_get(struct zcrypt_device *);
131int zcrypt_device_put(struct zcrypt_device *);
132int zcrypt_device_register(struct zcrypt_device *);
133void zcrypt_device_unregister(struct zcrypt_device *);
134void zcrypt_msgtype_register(struct zcrypt_ops *);
135void zcrypt_msgtype_unregister(struct zcrypt_ops *);
136struct zcrypt_ops *zcrypt_msgtype_request(unsigned char *, int);
137void zcrypt_msgtype_release(struct zcrypt_ops *);
138int zcrypt_api_init(void);
139void zcrypt_api_exit(void);
140
141#endif
142