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
79
80
81
82
83
84#define ZCRYPT_RNG_BUFFER_SIZE 4096
85
86struct zcrypt_device;
87
88struct zcrypt_ops {
89 long (*rsa_modexpo)(struct zcrypt_device *, struct ica_rsa_modexpo *);
90 long (*rsa_modexpo_crt)(struct zcrypt_device *,
91 struct ica_rsa_modexpo_crt *);
92 long (*send_cprb)(struct zcrypt_device *, struct ica_xcRB *);
93 long (*send_ep11_cprb)(struct zcrypt_device *, struct ep11_urb *);
94 long (*rng)(struct zcrypt_device *, char *);
95 struct list_head list;
96 struct module *owner;
97 int variant;
98};
99
100struct zcrypt_device {
101 struct list_head list;
102 spinlock_t lock;
103 struct kref refcount;
104 struct ap_device *ap_dev;
105 struct zcrypt_ops *ops;
106 int online;
107
108 int user_space_type;
109 char *type_string;
110 int min_mod_size;
111 int max_mod_size;
112 int short_crt;
113 int speed_rating;
114
115 int request_count;
116
117 struct ap_message reply;
118 int max_exp_bit_length;
119
120 debug_info_t *dbf_area;
121};
122
123
124extern atomic_t zcrypt_rescan_req;
125
126struct zcrypt_device *zcrypt_device_alloc(size_t);
127void zcrypt_device_free(struct zcrypt_device *);
128void zcrypt_device_get(struct zcrypt_device *);
129int zcrypt_device_put(struct zcrypt_device *);
130int zcrypt_device_register(struct zcrypt_device *);
131void zcrypt_device_unregister(struct zcrypt_device *);
132void zcrypt_msgtype_register(struct zcrypt_ops *);
133void zcrypt_msgtype_unregister(struct zcrypt_ops *);
134struct zcrypt_ops *zcrypt_msgtype_request(unsigned char *, int);
135void zcrypt_msgtype_release(struct zcrypt_ops *);
136int zcrypt_api_init(void);
137void zcrypt_api_exit(void);
138
139#endif
140