89 final int keyLength;
90
91 // flags indicating whether the key is a token object, sensitive, extractable
92 final boolean tokenObject, sensitive, extractable;
93
94 private final NativeKeyHolder keyIDHolder;
95
96 private static final boolean DISABLE_NATIVE_KEYS_EXTRACTION;
97
98 /**
99 * {@systemProperty sun.security.pkcs11.disableKeyExtraction} property
100 * indicating whether or not cryptographic keys within tokens are
101 * extracted to a Java byte array for memory management purposes.
102 *
103 * Key extraction affects NSS PKCS11 library only.
104 *
105 */
106 static {
107 PrivilegedAction<String> getKeyExtractionProp =
108 () -> System.getProperty(
109 "sun.security.pkcs11.disableKeyExtraction", "false");
110 String disableKeyExtraction =
111 AccessController.doPrivileged(getKeyExtractionProp);
112 DISABLE_NATIVE_KEYS_EXTRACTION =
113 "true".equalsIgnoreCase(disableKeyExtraction);
114 }
115
116 P11Key(String type, Session session, long keyID, String algorithm,
117 int keyLength, CK_ATTRIBUTE[] attributes) {
118 this.type = type;
119 this.token = session.token;
120 this.algorithm = algorithm;
121 this.keyLength = keyLength;
122 boolean tokenObject = false;
123 boolean sensitive = false;
124 boolean extractable = true;
125 int n = (attributes == null) ? 0 : attributes.length;
126 for (int i = 0; i < n; i++) {
127 CK_ATTRIBUTE attr = attributes[i];
128 if (attr.type == CKA_TOKEN) {
129 tokenObject = attr.getBoolean();
|
89 final int keyLength;
90
91 // flags indicating whether the key is a token object, sensitive, extractable
92 final boolean tokenObject, sensitive, extractable;
93
94 private final NativeKeyHolder keyIDHolder;
95
96 private static final boolean DISABLE_NATIVE_KEYS_EXTRACTION;
97
98 /**
99 * {@systemProperty sun.security.pkcs11.disableKeyExtraction} property
100 * indicating whether or not cryptographic keys within tokens are
101 * extracted to a Java byte array for memory management purposes.
102 *
103 * Key extraction affects NSS PKCS11 library only.
104 *
105 */
106 static {
107 PrivilegedAction<String> getKeyExtractionProp =
108 () -> System.getProperty(
109 "sun.security.pkcs11.disableKeyExtraction", "true");
110 String disableKeyExtraction =
111 AccessController.doPrivileged(getKeyExtractionProp);
112 DISABLE_NATIVE_KEYS_EXTRACTION =
113 "true".equalsIgnoreCase(disableKeyExtraction);
114 }
115
116 P11Key(String type, Session session, long keyID, String algorithm,
117 int keyLength, CK_ATTRIBUTE[] attributes) {
118 this.type = type;
119 this.token = session.token;
120 this.algorithm = algorithm;
121 this.keyLength = keyLength;
122 boolean tokenObject = false;
123 boolean sensitive = false;
124 boolean extractable = true;
125 int n = (attributes == null) ? 0 : attributes.length;
126 for (int i = 0; i < n; i++) {
127 CK_ATTRIBUTE attr = attributes[i];
128 if (attr.type == CKA_TOKEN) {
129 tokenObject = attr.getBoolean();
|