|
@@ -1,7 +1,5 @@
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
/*
|
|
- * zcrypt 2.1.0
|
|
|
|
- *
|
|
|
|
* Copyright IBM Corp. 2001, 2012
|
|
* Copyright IBM Corp. 2001, 2012
|
|
* Author(s): Robert Burroughs
|
|
* Author(s): Robert Burroughs
|
|
* Eric Rossman (edrossma@us.ibm.com)
|
|
* Eric Rossman (edrossma@us.ibm.com)
|
|
@@ -29,8 +27,7 @@
|
|
#include "zcrypt_msgtype6.h"
|
|
#include "zcrypt_msgtype6.h"
|
|
#include "zcrypt_cca_key.h"
|
|
#include "zcrypt_cca_key.h"
|
|
|
|
|
|
-#define PCIXCC_MIN_MOD_SIZE_OLD 64 /* 512 bits */
|
|
|
|
-#define PCIXCC_MAX_ICA_RESPONSE_SIZE 0x77c /* max size type86 v2 reply */
|
|
|
|
|
|
+#define CEXXC_MAX_ICA_RESPONSE_SIZE 0x77c /* max size type86 v2 reply */
|
|
|
|
|
|
#define CEIL4(x) ((((x)+3)/4)*4)
|
|
#define CEIL4(x) ((((x)+3)/4)*4)
|
|
|
|
|
|
@@ -38,9 +35,9 @@ struct response_type {
|
|
struct completion work;
|
|
struct completion work;
|
|
int type;
|
|
int type;
|
|
};
|
|
};
|
|
-#define PCIXCC_RESPONSE_TYPE_ICA 0
|
|
|
|
-#define PCIXCC_RESPONSE_TYPE_XCRB 1
|
|
|
|
-#define PCIXCC_RESPONSE_TYPE_EP11 2
|
|
|
|
|
|
+#define CEXXC_RESPONSE_TYPE_ICA 0
|
|
|
|
+#define CEXXC_RESPONSE_TYPE_XCRB 1
|
|
|
|
+#define CEXXC_RESPONSE_TYPE_EP11 2
|
|
|
|
|
|
MODULE_AUTHOR("IBM Corporation");
|
|
MODULE_AUTHOR("IBM Corporation");
|
|
MODULE_DESCRIPTION("Cryptographic Coprocessor (message type 6), " \
|
|
MODULE_DESCRIPTION("Cryptographic Coprocessor (message type 6), " \
|
|
@@ -111,7 +108,7 @@ struct function_and_rules_block {
|
|
} __packed;
|
|
} __packed;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The following is used to initialize the CPRBX passed to the PCIXCC/CEX2C
|
|
|
|
|
|
+ * The following is used to initialize the CPRBX passed to the CEXxC/CEXxP
|
|
* card in a type6 message. The 3 fields that must be filled in at execution
|
|
* card in a type6 message. The 3 fields that must be filled in at execution
|
|
* time are req_parml, rpl_parml and usage_domain.
|
|
* time are req_parml, rpl_parml and usage_domain.
|
|
* Everything about this interface is ascii/big-endian, since the
|
|
* Everything about this interface is ascii/big-endian, since the
|
|
@@ -294,7 +291,7 @@ static int ICAMEX_msg_to_type6MEX_msgX(struct zcrypt_queue *zq,
|
|
/* message header, cprbx and f&r */
|
|
/* message header, cprbx and f&r */
|
|
msg->hdr = static_type6_hdrX;
|
|
msg->hdr = static_type6_hdrX;
|
|
msg->hdr.ToCardLen1 = size - sizeof(msg->hdr);
|
|
msg->hdr.ToCardLen1 = size - sizeof(msg->hdr);
|
|
- msg->hdr.FromCardLen1 = PCIXCC_MAX_ICA_RESPONSE_SIZE - sizeof(msg->hdr);
|
|
|
|
|
|
+ msg->hdr.FromCardLen1 = CEXXC_MAX_ICA_RESPONSE_SIZE - sizeof(msg->hdr);
|
|
|
|
|
|
msg->cprbx = static_cprbx;
|
|
msg->cprbx = static_cprbx;
|
|
msg->cprbx.domain = AP_QID_QUEUE(zq->queue->qid);
|
|
msg->cprbx.domain = AP_QID_QUEUE(zq->queue->qid);
|
|
@@ -364,7 +361,7 @@ static int ICACRT_msg_to_type6CRT_msgX(struct zcrypt_queue *zq,
|
|
/* message header, cprbx and f&r */
|
|
/* message header, cprbx and f&r */
|
|
msg->hdr = static_type6_hdrX;
|
|
msg->hdr = static_type6_hdrX;
|
|
msg->hdr.ToCardLen1 = size - sizeof(msg->hdr);
|
|
msg->hdr.ToCardLen1 = size - sizeof(msg->hdr);
|
|
- msg->hdr.FromCardLen1 = PCIXCC_MAX_ICA_RESPONSE_SIZE - sizeof(msg->hdr);
|
|
|
|
|
|
+ msg->hdr.FromCardLen1 = CEXXC_MAX_ICA_RESPONSE_SIZE - sizeof(msg->hdr);
|
|
|
|
|
|
msg->cprbx = static_cprbx;
|
|
msg->cprbx = static_cprbx;
|
|
msg->cprbx.domain = AP_QID_QUEUE(zq->queue->qid);
|
|
msg->cprbx.domain = AP_QID_QUEUE(zq->queue->qid);
|
|
@@ -658,16 +655,6 @@ static int convert_type86_ica(struct zcrypt_queue *zq,
|
|
(int) service_rc, (int) service_rs);
|
|
(int) service_rc, (int) service_rs);
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
- if (service_rc == 8 && service_rs == 783) {
|
|
|
|
- zq->zcard->min_mod_size =
|
|
|
|
- PCIXCC_MIN_MOD_SIZE_OLD;
|
|
|
|
- ZCRYPT_DBF(DBF_DEBUG,
|
|
|
|
- "device=%02x.%04x rc/rs=%d/%d => rc=EAGAIN\n",
|
|
|
|
- AP_QID_CARD(zq->queue->qid),
|
|
|
|
- AP_QID_QUEUE(zq->queue->qid),
|
|
|
|
- (int) service_rc, (int) service_rs);
|
|
|
|
- return -EAGAIN;
|
|
|
|
- }
|
|
|
|
zq->online = 0;
|
|
zq->online = 0;
|
|
pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
|
|
pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
|
|
AP_QID_CARD(zq->queue->qid),
|
|
AP_QID_CARD(zq->queue->qid),
|
|
@@ -697,7 +684,7 @@ static int convert_type86_ica(struct zcrypt_queue *zq,
|
|
if (pad_len > 0) {
|
|
if (pad_len > 0) {
|
|
if (pad_len < 10)
|
|
if (pad_len < 10)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
- /* 'restore' padding left in the PCICC/PCIXCC card. */
|
|
|
|
|
|
+ /* 'restore' padding left in the CEXXC card. */
|
|
if (copy_to_user(outputdata, static_pad, pad_len - 1))
|
|
if (copy_to_user(outputdata, static_pad, pad_len - 1))
|
|
return -EFAULT;
|
|
return -EFAULT;
|
|
if (put_user(0, outputdata + pad_len - 1))
|
|
if (put_user(0, outputdata + pad_len - 1))
|
|
@@ -955,13 +942,13 @@ static void zcrypt_msgtype6_receive(struct ap_queue *aq,
|
|
if (t86r->hdr.type == TYPE86_RSP_CODE &&
|
|
if (t86r->hdr.type == TYPE86_RSP_CODE &&
|
|
t86r->cprbx.cprb_ver_id == 0x02) {
|
|
t86r->cprbx.cprb_ver_id == 0x02) {
|
|
switch (resp_type->type) {
|
|
switch (resp_type->type) {
|
|
- case PCIXCC_RESPONSE_TYPE_ICA:
|
|
|
|
|
|
+ case CEXXC_RESPONSE_TYPE_ICA:
|
|
length = sizeof(struct type86x_reply)
|
|
length = sizeof(struct type86x_reply)
|
|
+ t86r->length - 2;
|
|
+ t86r->length - 2;
|
|
- length = min(PCIXCC_MAX_ICA_RESPONSE_SIZE, length);
|
|
|
|
|
|
+ length = min(CEXXC_MAX_ICA_RESPONSE_SIZE, length);
|
|
memcpy(msg->message, reply->message, length);
|
|
memcpy(msg->message, reply->message, length);
|
|
break;
|
|
break;
|
|
- case PCIXCC_RESPONSE_TYPE_XCRB:
|
|
|
|
|
|
+ case CEXXC_RESPONSE_TYPE_XCRB:
|
|
length = t86r->fmt2.offset2 + t86r->fmt2.count2;
|
|
length = t86r->fmt2.offset2 + t86r->fmt2.count2;
|
|
length = min(MSGTYPE06_MAX_MSG_SIZE, length);
|
|
length = min(MSGTYPE06_MAX_MSG_SIZE, length);
|
|
memcpy(msg->message, reply->message, length);
|
|
memcpy(msg->message, reply->message, length);
|
|
@@ -1004,7 +991,7 @@ static void zcrypt_msgtype6_receive_ep11(struct ap_queue *aq,
|
|
if (t86r->hdr.type == TYPE86_RSP_CODE &&
|
|
if (t86r->hdr.type == TYPE86_RSP_CODE &&
|
|
t86r->cprbx.cprb_ver_id == 0x04) {
|
|
t86r->cprbx.cprb_ver_id == 0x04) {
|
|
switch (resp_type->type) {
|
|
switch (resp_type->type) {
|
|
- case PCIXCC_RESPONSE_TYPE_EP11:
|
|
|
|
|
|
+ case CEXXC_RESPONSE_TYPE_EP11:
|
|
length = t86r->fmt2.offset1 + t86r->fmt2.count1;
|
|
length = t86r->fmt2.offset1 + t86r->fmt2.count1;
|
|
length = min(MSGTYPE06_MAX_MSG_SIZE, length);
|
|
length = min(MSGTYPE06_MAX_MSG_SIZE, length);
|
|
memcpy(msg->message, reply->message, length);
|
|
memcpy(msg->message, reply->message, length);
|
|
@@ -1022,10 +1009,10 @@ out:
|
|
static atomic_t zcrypt_step = ATOMIC_INIT(0);
|
|
static atomic_t zcrypt_step = ATOMIC_INIT(0);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The request distributor calls this function if it picked the PCIXCC/CEX2C
|
|
|
|
|
|
+ * The request distributor calls this function if it picked the CEXxC
|
|
* device to handle a modexpo request.
|
|
* device to handle a modexpo request.
|
|
* @zq: pointer to zcrypt_queue structure that identifies the
|
|
* @zq: pointer to zcrypt_queue structure that identifies the
|
|
- * PCIXCC/CEX2C device to the request distributor
|
|
|
|
|
|
+ * CEXxC device to the request distributor
|
|
* @mex: pointer to the modexpo request buffer
|
|
* @mex: pointer to the modexpo request buffer
|
|
*/
|
|
*/
|
|
static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq,
|
|
static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq,
|
|
@@ -1033,7 +1020,7 @@ static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq,
|
|
{
|
|
{
|
|
struct ap_message ap_msg;
|
|
struct ap_message ap_msg;
|
|
struct response_type resp_type = {
|
|
struct response_type resp_type = {
|
|
- .type = PCIXCC_RESPONSE_TYPE_ICA,
|
|
|
|
|
|
+ .type = CEXXC_RESPONSE_TYPE_ICA,
|
|
};
|
|
};
|
|
int rc;
|
|
int rc;
|
|
|
|
|
|
@@ -1066,10 +1053,10 @@ out_free:
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The request distributor calls this function if it picked the PCIXCC/CEX2C
|
|
|
|
|
|
+ * The request distributor calls this function if it picked the CEXxC
|
|
* device to handle a modexpo_crt request.
|
|
* device to handle a modexpo_crt request.
|
|
* @zq: pointer to zcrypt_queue structure that identifies the
|
|
* @zq: pointer to zcrypt_queue structure that identifies the
|
|
- * PCIXCC/CEX2C device to the request distributor
|
|
|
|
|
|
+ * CEXxC device to the request distributor
|
|
* @crt: pointer to the modexpoc_crt request buffer
|
|
* @crt: pointer to the modexpoc_crt request buffer
|
|
*/
|
|
*/
|
|
static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq,
|
|
static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq,
|
|
@@ -1077,7 +1064,7 @@ static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq,
|
|
{
|
|
{
|
|
struct ap_message ap_msg;
|
|
struct ap_message ap_msg;
|
|
struct response_type resp_type = {
|
|
struct response_type resp_type = {
|
|
- .type = PCIXCC_RESPONSE_TYPE_ICA,
|
|
|
|
|
|
+ .type = CEXXC_RESPONSE_TYPE_ICA,
|
|
};
|
|
};
|
|
int rc;
|
|
int rc;
|
|
|
|
|
|
@@ -1122,7 +1109,7 @@ unsigned int get_cprb_fc(struct ica_xcRB *xcRB,
|
|
unsigned int *func_code, unsigned short **dom)
|
|
unsigned int *func_code, unsigned short **dom)
|
|
{
|
|
{
|
|
struct response_type resp_type = {
|
|
struct response_type resp_type = {
|
|
- .type = PCIXCC_RESPONSE_TYPE_XCRB,
|
|
|
|
|
|
+ .type = CEXXC_RESPONSE_TYPE_XCRB,
|
|
};
|
|
};
|
|
|
|
|
|
ap_msg->message = kmalloc(MSGTYPE06_MAX_MSG_SIZE, GFP_KERNEL);
|
|
ap_msg->message = kmalloc(MSGTYPE06_MAX_MSG_SIZE, GFP_KERNEL);
|
|
@@ -1138,10 +1125,10 @@ unsigned int get_cprb_fc(struct ica_xcRB *xcRB,
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The request distributor calls this function if it picked the PCIXCC/CEX2C
|
|
|
|
|
|
+ * The request distributor calls this function if it picked the CEXxC
|
|
* device to handle a send_cprb request.
|
|
* device to handle a send_cprb request.
|
|
* @zq: pointer to zcrypt_queue structure that identifies the
|
|
* @zq: pointer to zcrypt_queue structure that identifies the
|
|
- * PCIXCC/CEX2C device to the request distributor
|
|
|
|
|
|
+ * CEXxC device to the request distributor
|
|
* @xcRB: pointer to the send_cprb request buffer
|
|
* @xcRB: pointer to the send_cprb request buffer
|
|
*/
|
|
*/
|
|
static long zcrypt_msgtype6_send_cprb(struct zcrypt_queue *zq,
|
|
static long zcrypt_msgtype6_send_cprb(struct zcrypt_queue *zq,
|
|
@@ -1177,7 +1164,7 @@ unsigned int get_ep11cprb_fc(struct ep11_urb *xcrb,
|
|
unsigned int *func_code)
|
|
unsigned int *func_code)
|
|
{
|
|
{
|
|
struct response_type resp_type = {
|
|
struct response_type resp_type = {
|
|
- .type = PCIXCC_RESPONSE_TYPE_EP11,
|
|
|
|
|
|
+ .type = CEXXC_RESPONSE_TYPE_EP11,
|
|
};
|
|
};
|
|
|
|
|
|
ap_msg->message = kmalloc(MSGTYPE06_MAX_MSG_SIZE, GFP_KERNEL);
|
|
ap_msg->message = kmalloc(MSGTYPE06_MAX_MSG_SIZE, GFP_KERNEL);
|
|
@@ -1271,7 +1258,7 @@ unsigned int get_rng_fc(struct ap_message *ap_msg, int *func_code,
|
|
unsigned int *domain)
|
|
unsigned int *domain)
|
|
{
|
|
{
|
|
struct response_type resp_type = {
|
|
struct response_type resp_type = {
|
|
- .type = PCIXCC_RESPONSE_TYPE_XCRB,
|
|
|
|
|
|
+ .type = CEXXC_RESPONSE_TYPE_XCRB,
|
|
};
|
|
};
|
|
|
|
|
|
ap_msg->message = kmalloc(MSGTYPE06_MAX_MSG_SIZE, GFP_KERNEL);
|
|
ap_msg->message = kmalloc(MSGTYPE06_MAX_MSG_SIZE, GFP_KERNEL);
|
|
@@ -1291,10 +1278,10 @@ unsigned int get_rng_fc(struct ap_message *ap_msg, int *func_code,
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The request distributor calls this function if it picked the PCIXCC/CEX2C
|
|
|
|
|
|
+ * The request distributor calls this function if it picked the CEXxC
|
|
* device to generate random data.
|
|
* device to generate random data.
|
|
* @zq: pointer to zcrypt_queue structure that identifies the
|
|
* @zq: pointer to zcrypt_queue structure that identifies the
|
|
- * PCIXCC/CEX2C device to the request distributor
|
|
|
|
|
|
+ * CEXxC device to the request distributor
|
|
* @buffer: pointer to a memory page to return random data
|
|
* @buffer: pointer to a memory page to return random data
|
|
*/
|
|
*/
|
|
static long zcrypt_msgtype6_rng(struct zcrypt_queue *zq,
|
|
static long zcrypt_msgtype6_rng(struct zcrypt_queue *zq,
|
|
@@ -1329,7 +1316,7 @@ static long zcrypt_msgtype6_rng(struct zcrypt_queue *zq,
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * The crypto operations for a PCIXCC/CEX2C card.
|
|
|
|
|
|
+ * The crypto operations for a CEXxC card.
|
|
*/
|
|
*/
|
|
static struct zcrypt_ops zcrypt_msgtype6_norng_ops = {
|
|
static struct zcrypt_ops zcrypt_msgtype6_norng_ops = {
|
|
.owner = THIS_MODULE,
|
|
.owner = THIS_MODULE,
|