← Back to team overview

group.of.nepali.translators team mailing list archive

[Bug 1915517] Re: [UBUNTU 21.04] openCryptoki: pkcscca migration fails with usr/sb2 is not a valid slot ID

 

** Changed in: ubuntu-z-systems
       Status: Fix Committed => Fix Released

-- 
You received this bug notification because you are a member of नेपाली
भाषा समायोजकहरुको समूह, which is subscribed to Xenial.
Matching subscriptions: Ubuntu 16.04 Bugs
https://bugs.launchpad.net/bugs/1915517

Title:
  [UBUNTU 21.04] openCryptoki: pkcscca migration fails with usr/sb2 is
  not a valid slot ID

Status in Ubuntu on IBM z Systems:
  Fix Released
Status in opencryptoki package in Ubuntu:
  Fix Released
Status in opencryptoki source package in Xenial:
  Fix Released
Status in opencryptoki source package in Bionic:
  Fix Released
Status in opencryptoki source package in Focal:
  Fix Released
Status in opencryptoki source package in Groovy:
  Fix Released
Status in opencryptoki source package in Hirsute:
  Fix Released

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|20.04|18.04|16.04>
  and on top:

   * Verify that a crypto domain is available with 'lszcrypt -V'.

   * Install the proprietary IBM CCA Host Libraries and Tools package (csulcca_7.1.x-x_s390x.deb)
     from https://www.ibm.com/security/cryptocards/pciecc4/lonzsoftware (as of today: csulcca_7.1.35-01_s390x.deb).

   * 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://limbenjamin.com/articles/des-key-parity-bit-calculator.html)
     Alternatively use: 'panel.exe --mk-load-interactive'

   * 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/opencryptoki/opencryptoki.conf) and restart pkcsslotd:
     sudo cp -p /etc/opencryptoki/opencryptoki.conf{,_$(date +%Y-%m-%d_%H:%M:%S).backup}
     sudo sed -i 's/^stdll = .*/stdll = libpkcs11_cca.so/' /etc/opencryptoki/opencryptoki.conf
     sudo sed -i '/^confname = ep11tok.conf/d' /etc/opencryptoki/opencryptoki.conf
     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_REQUIRED|USER_PIN_INITIALIZED|CLOCK_ON_TOKEN|TOKEN_INITIALIZED)
     pkcsconf -t -c <n> | grep Flags

   * export PKCS11_USER_PIN=<your user PIN> from the token
  initialization.

   * 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_PATH=/usr/lib/s390x-linux-gnu/pkcs11:/usr/lib
     (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://github.com/opencryptoki/opencryptoki/tree/master/testcases/misc_tests)

   * 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://limbenjamin.com/articles/des-key-parity-bit-calculator.html)
     Alternatively use: 'panel.exe --mk-load-interactive'

   * Run: pkcscca -m keys -s 2 -k sym -d /var/lib/opencryptoki/ccatok -v debug
     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://launchpad.net/~fheimes/+archive/ubuntu/lp1915517

   * 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://github.com/opencryptoki/opencryptoki/commit/f1f176cbb4183bcb8a0f7b4d7f649d84a731dd43.patch
  "[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+dfsg-0ubuntu5:
  groovy (20.10)    (utils): 3.14.0+dfsg-0ubuntu3
  hirsute           (utils): 3.14.0+dfsg-0ubuntu3

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu-z-systems/+bug/1915517/+subscriptions