Compare SunPKCS11 support for AES vs HMAC

  *   AES => keygen is supported, and AES key can be used for encrypt and 
decrypt.
  *   HMAC => keygen is not supported, but HMAC key can be used for MAC.

This does not make sense. A third-party utility is required for HMAC keygen, 
but not for AES keygen.

Use case:

  *   PKCS#11 driver is v2.20.
  *   This means AES-256-GCM is not available for confidentiality and 
integrity, because GCM supported was only added in PKCS#11 v2.40.
  *   Fallback to AES-256-CBC and HmacSha256 is required for confidentiality 
and integrity, respectively.
  *   Java can trigger AES keygen, but not HMAC keygen. A third-party utility 
is required to trigger HMAC keygen before running Java.

Would it be possible to add the missing GENERIC-SECRET-KEY-GEN mechanism to 
SunPKCS11? Notice how that mechanism is missing from the documented SunPKCS11 
algorithms and mechanisms. It is the same in Java 8 all the way up to 15.

  *   
https://docs.oracle.com/javase/8/docs/technotes/guides/security/p11guide.html#ALG



To reproduce and demonstrate the missing HMAC keygen issue, here is a small 
Java Maven project.

  *   https://github.com/justincranford/pkcs11

The readme shows the commands to initialize the SoftHSM2 token, and use a 
third-party OpenSC utility to trigger HMAC keygen. It also shows how to set the 
required SoftHSM2 env variable and run the Maven build.

The Maven build will execute the ITPkcs11.java integration test class. The 
tests demonstrate:

  *   Successful SunPKCS11 login to SoftHSM2 and list any existing keys
  *   Successful AES keygen, encrypt, decrypt
  *   Successful HMAC mac
  *   Failed HMAC keygen (because SunPKCS11 does not support 
GENERIC-SECRET-KEY-GEN mechanism yet)



Thank you,
Justin Cranford

Reply via email to