src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11RSACipher.java
changeset 54062 62ab0859e7e5
parent 53257 5170dc2bcf64
child 55332 f492567244ab
equal deleted inserted replaced
54060:53a95878619f 54062:62ab0859e7e5
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   548             SecretKey secretKey = null;
   548             SecretKey secretKey = null;
   549             long p11KeyID = p11Key.getKeyID();
   549             long p11KeyID = p11Key.getKeyID();
   550             try {
   550             try {
   551                 try {
   551                 try {
   552                     s = token.getObjSession();
   552                     s = token.getObjSession();
   553                     long keyType = CKK_GENERIC_SECRET;
   553                     long p11KeyType =
       
   554                         P11SecretKeyFactory.getPKCS11KeyType(algorithm);
   554                     CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
   555                     CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
   555                             new CK_ATTRIBUTE(CKA_CLASS, CKO_SECRET_KEY),
   556                             new CK_ATTRIBUTE(CKA_CLASS, CKO_SECRET_KEY),
   556                             new CK_ATTRIBUTE(CKA_KEY_TYPE, keyType),
   557                             new CK_ATTRIBUTE(CKA_KEY_TYPE, p11KeyType),
   557                         };
   558                         };
   558                     attributes = token.getAttributes(
   559                     attributes = token.getAttributes(
   559                             O_IMPORT, CKO_SECRET_KEY, keyType, attributes);
   560                             O_IMPORT, CKO_SECRET_KEY, p11KeyType, attributes);
   560 
   561 
   561                     long keyID = token.p11.C_UnwrapKey(s.id(),
   562                     long keyID = token.p11.C_UnwrapKey(s.id(),
   562                                     new CK_MECHANISM(mechanism), p11KeyID,
   563                                     new CK_MECHANISM(mechanism), p11KeyID,
   563                                     wrappedKey, attributes);
   564                                     wrappedKey, attributes);
   564                     secretKey = P11Key.secretKey(s, keyID,
   565                     secretKey = P11Key.secretKey(s, keyID,