8264849: Add KW and KWP support to PKCS11 provider

Reviewed-by: ascarpino
This commit is contained in:
Valerie Peng 2021-10-19 20:50:56 +00:00
parent bd2b41dd70
commit e63c1486dc
17 changed files with 2089 additions and 99 deletions

View file

@ -73,7 +73,7 @@ import static sun.security.pkcs11.P11Util.*;
import sun.security.pkcs11.wrapper.*;
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
import static sun.security.pkcs11.wrapper.PKCS11Exception.*;
import static sun.security.pkcs11.wrapper.PKCS11Exception.RV.*;
import sun.security.rsa.RSAKeyFactory;
@ -757,7 +757,7 @@ final class P11KeyStore extends KeyStoreSpi {
Throwable cause = e.getCause();
if (cause instanceof PKCS11Exception) {
PKCS11Exception pe = (PKCS11Exception) cause;
if (pe.getErrorCode() == CKR_PIN_INCORRECT) {
if (pe.match(CKR_PIN_INCORRECT)) {
// if password is wrong, the cause of the IOException
// should be an UnrecoverableKeyException
throw new IOException("load failed",
@ -2330,7 +2330,7 @@ final class P11KeyStore extends KeyStoreSpi {
cka_label = new String(attrs[0].getCharArray());
}
} catch (PKCS11Exception pe) {
if (pe.getErrorCode() != CKR_ATTRIBUTE_TYPE_INVALID) {
if (!pe.match(CKR_ATTRIBUTE_TYPE_INVALID)) {
throw pe;
}
@ -2371,7 +2371,7 @@ final class P11KeyStore extends KeyStoreSpi {
(session.id(), handle, trustedAttr);
cka_trusted = trustedAttr[0].getBoolean();
} catch (PKCS11Exception pe) {
if (pe.getErrorCode() == CKR_ATTRIBUTE_TYPE_INVALID) {
if (pe.match(CKR_ATTRIBUTE_TYPE_INVALID)) {
// XXX NSS, ibutton, sca1000
CKA_TRUSTED_SUPPORTED = false;
if (debug != null) {