Uploaded image for project: 'EJBCA'
  1. EJBCA
  2. ECA-4596

ClientToolBox is unable to verify signature when testing more exotic EC keys in HSM

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: EJBCA 6.3.2.3
    • Fix Version/s: EJBCA 6.6.0
    • Component/s: CLI
    • Environment:
      RHEL 6.7
      java-1.7.0-openjdk-devel-1.7.0.85-2.6.1.3.el6_7.x86_64
      java-1.7.0-openjdk-1.7.0.85-2.6.1.3.el6_7.x86_64

      PSS and EC patches applied (rt.jar/sunpkcs11.jar).
    • Issue discovered during:
      Testing

      Description

      When attempting to test the HSM keys via client toolbox PKCS11HSMKeyTool test command, signature verification will fail if the private key is a more "exotic" elliptic curve (for example brainpoolP160r1).

      Reproduction steps:

      1. Install RHEL 6.7, and set-up some HSM on it that supports brainpoolP160r1.

      2. Generate the key (slot number 1 for example):

      ./ejbcaClientToolBox.sh PKCS11HSMKeyTool generate /path/to/pkcs11.so brainpoolP160r1 testKey 1

      3. Test the key:

      ./ejbcaClientToolBox.sh PKCS11HSMKeyTool test /path/to/pkcs11.so 1

      Expected results:

      1. Test was successful, signature was verified (or maybe the signature was wrong -you never know).

      Actual results:

      1. An exception was thrown:

      ---%---
      SunPKCS11-libsofthsm2.so-slot0 EC private key, 160 bits (id 3, token object, sensitive, unextractable)
      Elliptic curve key:
      the affine x-coordinate: bfd582d2eb14cc499a61ee7f50977520b28ce6f8
      the affine y-coordinate: 9b622ca557e2f8a900bb7a65b6b4ed99083f9b42
      java.security.SignatureException: Could not verify signature
      at sun.security.ec.ECDSASignature.engineVerify(ECDSASignature.java:321)
      at java.security.Signature$Delegate.engineVerify(Signature.java:1217)
      at java.security.Signature.verify(Signature.java:651)
      at org.ejbca.ui.cli.KeyStoreContainerTest$Sign.verify(KeyStoreContainerTest.java:339)
      at org.ejbca.ui.cli.KeyStoreContainerTest$NormalTest.test(KeyStoreContainerTest.java:460)
      at org.ejbca.ui.cli.KeyStoreContainerTest$NormalTest.doIt(KeyStoreContainerTest.java:483)
      at org.ejbca.ui.cli.KeyStoreContainerTest.startNormal(KeyStoreContainerTest.java:147)
      at org.ejbca.ui.cli.KeyStoreContainerTest.test(KeyStoreContainerTest.java:75)
      at org.ejbca.ui.cli.HSMKeyTool.doIt(HSMKeyTool.java:400)
      at org.ejbca.ui.cli.HSMKeyTool.execute(HSMKeyTool.java:449)
      at org.ejbca.ui.cli.PKCS11HSMKeyTool.execute(PKCS11HSMKeyTool.java:47)
      at org.ejbca.ui.cli.ClientToolBox.executeIfSelected(ClientToolBox.java:40)
      at org.ejbca.ui.cli.ClientToolBox.main(ClientToolBox.java:66)
      Caused by: java.security.InvalidAlgorithmParameterException
      at sun.security.ec.ECDSASignature.verifySignedDigest(Native Method)
      at sun.security.ec.ECDSASignature.engineVerify(ECDSASignature.java:317)
      ... 12 more
      Signing not possible with this key. See exception.
      No crypto available for this key.
      ---%---

      Additional notes:

      Keep in mind that you must have a patched OpenJDK with support for additional elliptic curves. In addition, the HSM used also must support the brainpool curve mentioned above (or whatever other curve you are using).

      Markus had a look at code and exceptions, and it seems that this issue could be fixed if we were to use the Bouncy Castle provider for signature verification in client toolbox. Currently we use the Sun provider, which in turn depends on Mozilla's NSS library, which in turn does not have support for this specific curve (or some others).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tomas Tomas Gustavsson
              Reporter:
              branko Branko Majic (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: