[UBUNTU 21.04] openCryptoki: pkcscca migration fails with usr/sb2 is not a valid slot ID
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ubuntu on IBM z Systems |
Fix Released
|
High
|
Skipper Bug Screeners | ||
opencryptoki (Ubuntu) |
Fix Released
|
High
|
Brian Murray | ||
Xenial |
Fix Released
|
High
|
Frank Heimes | ||
Bionic |
Fix Released
|
High
|
Frank Heimes | ||
Focal |
Fix Released
|
High
|
Frank Heimes | ||
Groovy |
Fix Released
|
High
|
Frank Heimes | ||
Hirsute |
Fix Released
|
High
|
Brian Murray |
Bug Description
[Impact]
* An opencryptoki symmetric key object, wrapped by an IBM CCA DES
master key, cannot be migrated from a previous master key stored
in the OLD register to a new master key stored in the CURRENT
register, if a token is used that has a higher index than the
number of tokens available.
* The problem remains if the CCA token is indexed as token 0,
as well as if the ICA token is defined in addition
and the ICA token is token 0 and CCA is token 1.
* Users who run configurations which do not have a token present
in all slots starting from 0 to slot <n> wont be able to do the
described migration.
* The upstream accepted patch removes a faulty check which enforces
users to run configurations
with continuous slot ids for slots that have a token present,
hence it enables users running such configurations to do the
migration as described above flawlessly.
[Test Plan]
* An IBM Z or LinuxONE system is needed with a CryptoExpress 5S or newer
crypto adapter card in place and with at least one crypto domain online.
* Install Ubuntu Server for s390x version <20.10|
* Verify that a crypto domain is available with 'lszcrypt -V'.
* Install the proprietary IBM CCA Host Libraries and Tools package (csulcca_
from https:/
* Prepare for setting an initial master key, for example with:
panel.exe --mk-load=<48 byte DES key incl. odd parity> --mktype=SYM --mkpart=<PART>
whereas <PART> is FIRST, MIDDLE and LAST
(to generate a proper TEST and SAMPLE key incl. parity bits see:
https:/
Alternatively use: 'panel.exe --mk-load-
* And set the master key:
panel.exe -mk-set --mktype=SYM
* Install opencryptoki:
sudo apt-get install opencryptoki
* Add the acting user to the pkcs11 group:
sudo usermod -aG pkcs11 <userid>
and add the cca_* groups:
for g in $(grep cca_ /etc/group | awk -F':' '{ print $1 }'); do sudo usermod -a -G $g $USER; done
Log out and in again with <userid> to make the group changes take effect.
* Configure opencryptoki to only show the CCA token (see /etc/opencrypto
sudo cp -p /etc/opencrypto
sudo sed -i 's/^stdll = .*/stdll = libpkcs11_cca.so/' /etc/opencrypto
sudo sed -i '/^confname = ep11tok.conf/d' /etc/opencrypto
sudo systemctl restart pkcsslotd
* Initialize the opencryptoki CCA token:
pkcsconf -I -c <n> # whereas <n> is the CCA slot, e.g. 1
pkcsconf -P -c <n>
pkcsconf -u -c <n>
* The token is expected to be in the initialized state, showing the flags value as below:
Flags: 0x44D (RNG|LOGIN_
pkcsconf -t -c <n> | grep Flags
* export PKCS11_
* Generate DES token objects wrapped by the secure master key stored in the current CCA DES register (sym category):
p11sak generate-key des --slot <n> --pin <your user PIN> --label des_test
Since p11sak need to be separately compiled, the LD_LIBRARY_PATH might need to be adjusted, like:
LD_LIBRARY_
(For older opencryptoki library versions than 3.14 use the GitHub opencryptoki misc_tests
tok_des test with C_DestroyObject() commented to keep the objects created during the test. https:/
* Prepare for setting a new DES master key, for example with:
panel.exe --mk-load=<48 byte DES key incl. odd parity> --mktype=SYM --mkpart=<PART>
whereas <PART> is FIRST, MIDDLE and LAST
(to generate a proper TEST and SAMPLE key incl. parity bits see:
https:/
Alternatively use: 'panel.exe --mk-load-
* Run: pkcscca -m keys -s 2 -k sym -d /var/lib/
Without fix the message "usr/sb2 is not a valid slot ID" is printed.
With working solution, the messages printed are
"Enter the SO PIN:
Enter the USER PIN:
Successfully migrated: DES: 1."
[Where problems could occur]
* With the removal of the erroneous code, done by commit/patch:
caa4bbba "A slot ID has nothing to do with the number of slots"
the behavior of migrate_wrapped may change unexpectedly.
* Especially since exit codes 3 and 4 got dropped.
* Any checks for those exit codes would potentially have to be adapted,
but such error codes would have been caused by error situations anyway, even in case the bug is not fixed.
Invalid slot ids will cause an exit code of 5 now.
* Issues could occur in case slot_count might still be used outside the scope of the patch,
but this is simple to check and a test build will indicate this anyway.
[Other Info]
* A successful test build of a patched package was made available
for further testing with this PPA:
https:/
* Hirsute/21.04 is covered by the version bump to a new upstream release
3.15.1 (+ add. patches) of LP: #1906369.
__________
Details
=======
An opencryptoki symmetric key object wrapped by the IBM CCA DES master key cannot be migrated from a previous master key stored in the OLD register to a newer master key stored in the CURRENT register, when a token with a higher index is used, than number of tokens are available. The problem remains when the CCA token is indexed as token 0, as well as when the ICA token is defined in addition and the ICA token is token 0 and CCA is token 1.
Fix
===
The following commit has been verified to fix this issue:
https:/
"[PATCH] A slot ID has nothing to do with the number of slots"
This git commit need to be applied to all version with opencrycpptoki >= 3.4
xenial (16.04LTS) (utils): 3.4.1+dfsg-1ubuntu3
bionic (18.04LTS) (utils): 3.9.0+dfsg-0ubuntu1
focal (20.04LTS) (utils): 3.13.0+
groovy (20.10) (utils): 3.14.0+
hirsute (utils): 3.14.0+
Related branches
- Canonical Foundations Team: Pending requested
-
Diff: 82 lines (+60/-0)3 files modifieddebian/changelog (+9/-0)
debian/patches/f1f176cbb4183bcb8a0f7b4d7f649d84a731dd43.patch (+50/-0)
debian/patches/series (+1/-0)
- Canonical Foundations Team: Pending requested
-
Diff: 81 lines (+59/-0)3 files modifieddebian/changelog (+8/-0)
debian/patches/f1f176cbb4183bcb8a0f7b4d7f649d84a731dd43.patch (+50/-0)
debian/patches/series (+1/-0)
- Canonical Foundations Team: Pending requested
-
Diff: 86 lines (+64/-0)3 files modifieddebian/changelog (+8/-0)
debian/patches/f1f176cbb4183bcb8a0f7b4d7f649d84a731dd43.patch (+55/-0)
debian/patches/series (+1/-0)
- Canonical Foundations Team: Pending requested
-
Diff: 85 lines (+63/-0)3 files modifieddebian/changelog (+8/-0)
debian/patches/f1f176cbb4183bcb8a0f7b4d7f649d84a731dd43.patch (+54/-0)
debian/patches/series (+1/-0)
tags: | added: architecture-s39064 bugnameltc-191527 severity-high targetmilestone-inin2104 |
Changed in ubuntu: | |
assignee: | nobody → Skipper Bug Screeners (skipper-screen-team) |
affects: | ubuntu → opencryptoki (Ubuntu) |
Changed in ubuntu-z-systems: | |
importance: | Undecided → High |
assignee: | nobody → Skipper Bug Screeners (skipper-screen-team) |
Changed in ubuntu-z-systems: | |
status: | New → Triaged |
tags: | added: fr-1140 |
Changed in opencryptoki (Ubuntu Hirsute): | |
status: | New → In Progress |
assignee: | Skipper Bug Screeners (skipper-screen-team) → Brian Murray (brian-murray) |
importance: | Undecided → High |
Changed in ubuntu-z-systems: | |
status: | Triaged → In Progress |
Changed in opencryptoki (Ubuntu Groovy): | |
status: | New → In Progress |
assignee: | nobody → Frank Heimes (fheimes) |
importance: | Undecided → High |
description: | updated |
description: | updated |
description: | updated |
Changed in ubuntu-z-systems: | |
status: | In Progress → Fix Committed |
description: | updated |
Changed in ubuntu-z-systems: | |
status: | Fix Committed → Fix Released |
The hirsute part could and should be done as part of LP 1906369.