27 #include <linux/module.h>
28 #include <linux/slab.h>
32 #include <asm/uaccess.h>
39 #define PCICA_MIN_MOD_SIZE 1
40 #define PCICA_MAX_MOD_SIZE 256
42 #define PCICA_SPEED_RATING 2800
44 #define PCICA_MAX_MESSAGE_SIZE 0x3a0
45 #define PCICA_MAX_RESPONSE_SIZE 0x110
47 #define PCICA_CLEANUP_TIME (15*HZ)
57 "Copyright IBM Corp. 2001, 2006");
60 static int zcrypt_pcica_probe(
struct ap_device *ap_dev);
61 static void zcrypt_pcica_remove(
struct ap_device *ap_dev);
65 static struct ap_driver zcrypt_pcica_driver = {
66 .probe = zcrypt_pcica_probe,
67 .remove = zcrypt_pcica_remove,
68 .ids = zcrypt_pcica_ids,
81 static int ICAMEX_msg_to_type4MEX_msg(
struct zcrypt_device *zdev,
92 memset(sme, 0,
sizeof(*sme));
93 ap_msg->
length =
sizeof(*sme);
95 sme->
header.msg_len =
sizeof(*sme);
103 memset(lme, 0,
sizeof(*lme));
104 ap_msg->
length =
sizeof(*lme);
106 lme->
header.msg_len =
sizeof(*lme);
130 static int ICACRT_msg_to_type4CRT_msg(
struct zcrypt_device *zdev,
135 int mod_len, short_len, long_len;
138 short_len = mod_len / 2;
139 long_len = mod_len / 2 + 8;
141 if (mod_len <= 128) {
143 memset(scr, 0,
sizeof(*scr));
144 ap_msg->
length =
sizeof(*scr);
148 scr->
header.msg_len =
sizeof(*scr);
149 p = scr->
p +
sizeof(scr->
p) - long_len;
150 q = scr->
q +
sizeof(scr->
q) - short_len;
151 dp = scr->
dp +
sizeof(scr->
dp) - long_len;
152 dq = scr->
dq +
sizeof(scr->
dq) - short_len;
153 u = scr->
u +
sizeof(scr->
u) - long_len;
157 memset(lcr, 0,
sizeof(*lcr));
158 ap_msg->
length =
sizeof(*lcr);
162 lcr->
header.msg_len =
sizeof(*lcr);
163 p = lcr->
p +
sizeof(lcr->
p) - long_len;
164 q = lcr->
q +
sizeof(lcr->
q) - short_len;
165 dp = lcr->
dp +
sizeof(lcr->
dp) - long_len;
166 dq = lcr->
dq +
sizeof(lcr->
dq) - short_len;
167 u = lcr->
u +
sizeof(lcr->
u) - long_len;
193 char __user *outputdata,
194 unsigned int outputdatalength)
199 if (t84h->
len <
sizeof(*t84h) + outputdatalength) {
205 data = reply->
message + t84h->
len - outputdatalength;
213 char __user *outputdata,
214 unsigned int outputdatalength)
217 switch (((
unsigned char *) reply->
message)[1]) {
220 return convert_error(zdev, reply);
222 return convert_type84(zdev, reply,
223 outputdata, outputdatalength);
238 static void zcrypt_pcica_receive(
struct ap_device *ap_dev,
280 ap_init_message(&ap_msg);
284 ap_msg.
receive = zcrypt_pcica_receive;
288 rc = ICAMEX_msg_to_type4MEX_msg(zdev, &ap_msg, mex);
291 init_completion(&
work);
295 rc = convert_response(zdev, &ap_msg, mex->
outputdata,
312 static long zcrypt_pcica_modexpo_crt(
struct zcrypt_device *zdev,
319 ap_init_message(&ap_msg);
323 ap_msg.
receive = zcrypt_pcica_receive;
327 rc = ICACRT_msg_to_type4CRT_msg(zdev, &ap_msg, crt);
330 init_completion(&
work);
334 rc = convert_response(zdev, &ap_msg, crt->
outputdata,
348 .rsa_modexpo = zcrypt_pcica_modexpo,
349 .rsa_modexpo_crt = zcrypt_pcica_modexpo_crt,
357 static int zcrypt_pcica_probe(
struct ap_device *ap_dev)
366 zdev->
ops = &zcrypt_pcica_ops;
391 static void zcrypt_pcica_remove(
struct ap_device *ap_dev)