|
|
8a74ed |
commit d6ba9ff61743ce869a5a677f6f77339642efef4b
|
|
|
8a74ed |
Author: Ingo Franzki <ifranzki@linux.ibm.com>
|
|
|
8a74ed |
Date: Tue Sep 24 14:35:59 2019 +0200
|
|
|
8a74ed |
|
|
|
8a74ed |
EP11: Support tolerated new crypto cards
|
|
|
8a74ed |
|
|
|
8a74ed |
With just toleration support of new crypt cards, new crypto
|
|
|
8a74ed |
cards are reported as the last known crypto card version.
|
|
|
8a74ed |
E.g. a CEX7 card is reported as CEX6, when CEX6 is the last
|
|
|
8a74ed |
known crypto card version.
|
|
|
8a74ed |
|
|
|
8a74ed |
The EP11 token checks the card versions and needs to distinguish
|
|
|
8a74ed |
tolerated cards from supported cards. New (tolerated) crypto cards
|
|
|
8a74ed |
may have different API and firmware versions, and thus need to be
|
|
|
8a74ed |
handled differently.
|
|
|
8a74ed |
|
|
|
8a74ed |
Signed-off-by: Ingo Franzki <ifranzki@linux.ibm.com>
|
|
|
8a74ed |
|
|
|
8a74ed |
diff --git a/usr/lib/ep11_stdll/ep11_specific.c b/usr/lib/ep11_stdll/ep11_specific.c
|
|
|
8a74ed |
index e22dad5d..a65accea 100644
|
|
|
8a74ed |
--- a/usr/lib/ep11_stdll/ep11_specific.c
|
|
|
8a74ed |
+++ b/usr/lib/ep11_stdll/ep11_specific.c
|
|
|
8a74ed |
@@ -8253,6 +8253,7 @@ static CK_RV get_card_type(uint_32 adapter, CK_ULONG *type)
|
|
|
8a74ed |
char fname[PATH_MAX];
|
|
|
8a74ed |
char buf[250];
|
|
|
8a74ed |
CK_RV rc;
|
|
|
8a74ed |
+ CK_ULONG hwtype, rawtype;
|
|
|
8a74ed |
|
|
|
8a74ed |
sprintf(fname, "%scard%02x/type", SYSFS_DEVICES_AP, adapter);
|
|
|
8a74ed |
rc = file_fgets(fname, buf, sizeof(buf));
|
|
|
8a74ed |
@@ -8260,6 +8261,28 @@ static CK_RV get_card_type(uint_32 adapter, CK_ULONG *type)
|
|
|
8a74ed |
return rc;
|
|
|
8a74ed |
if (sscanf(buf, "CEX%luP", type) != 1)
|
|
|
8a74ed |
return CKR_FUNCTION_FAILED;
|
|
|
8a74ed |
+
|
|
|
8a74ed |
+ sprintf(fname, "%scard%02x/hwtype", SYSFS_DEVICES_AP, adapter);
|
|
|
8a74ed |
+ rc = file_fgets(fname, buf, sizeof(buf));
|
|
|
8a74ed |
+ if (rc != CKR_OK)
|
|
|
8a74ed |
+ return rc;
|
|
|
8a74ed |
+ if (sscanf(buf, "%lu", &hwtype) != 1)
|
|
|
8a74ed |
+ return CKR_FUNCTION_FAILED;
|
|
|
8a74ed |
+
|
|
|
8a74ed |
+ sprintf(fname, "%scard%02x/raw_hwtype", SYSFS_DEVICES_AP, adapter);
|
|
|
8a74ed |
+ rc = file_fgets(fname, buf, sizeof(buf));
|
|
|
8a74ed |
+ if (rc != CKR_OK)
|
|
|
8a74ed |
+ return rc;
|
|
|
8a74ed |
+ if (sscanf(buf, "%lu", &rawtype) != 1)
|
|
|
8a74ed |
+ return CKR_FUNCTION_FAILED;
|
|
|
8a74ed |
+
|
|
|
8a74ed |
+ if (rawtype > hwtype) {
|
|
|
8a74ed |
+ TRACE_DEVEL("%s adapter: %u hwtype: %lu raw_hwtype: %lu\n",
|
|
|
8a74ed |
+ __func__, adapter, hwtype, rawtype);
|
|
|
8a74ed |
+ /* Tolerated new card level: report calculated type */
|
|
|
8a74ed |
+ *type += (rawtype - hwtype);
|
|
|
8a74ed |
+ }
|
|
|
8a74ed |
+
|
|
|
8a74ed |
return CKR_OK;
|
|
|
8a74ed |
}
|
|
|
8a74ed |
|