Skip to content

Commit 7ab6dc8

Browse files
author
Valerie Peng
committed
6676643: Improve current C_GetAttributeValue native implementation
Reviewed-by: xuelei
1 parent 28f1c7a commit 7ab6dc8

File tree

14 files changed

+258
-388
lines changed

14 files changed

+258
-388
lines changed

src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11AEADCipher.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import sun.security.jca.JCAUtil;
4040
import sun.security.pkcs11.wrapper.*;
4141
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
42+
import static sun.security.pkcs11.wrapper.PKCS11Exception.*;
4243

4344
/**
4445
* P11 AEAD Cipher implementation class. This class currently supports

src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Cipher.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import sun.security.jca.JCAUtil;
3939
import sun.security.pkcs11.wrapper.*;
4040
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
41+
import static sun.security.pkcs11.wrapper.PKCS11Exception.*;
4142

4243
/**
4344
* Cipher implementation class. This class currently supports

src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11KeyStore.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -73,6 +73,7 @@
7373

7474
import sun.security.pkcs11.wrapper.*;
7575
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
76+
import static sun.security.pkcs11.wrapper.PKCS11Exception.*;
7677

7778
import sun.security.rsa.RSAKeyFactory;
7879

src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Mac.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
import sun.security.pkcs11.wrapper.*;
3838
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
39+
import static sun.security.pkcs11.wrapper.PKCS11Exception.*;
3940

4041
/**
4142
* MAC implementation class. This class currently supports HMAC using

src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11PSSSignature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
import sun.security.pkcs11.wrapper.*;
4141
import sun.security.util.KnownOIDs;
4242
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
43-
43+
import static sun.security.pkcs11.wrapper.PKCS11Exception.*;
4444

4545
/**
4646
* RSASSA-PSS Signature implementation class. This class currently supports the

src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/P11Signature.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
import sun.security.pkcs11.wrapper.*;
4444
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
45+
import static sun.security.pkcs11.wrapper.PKCS11Exception.*;
4546
import sun.security.util.KeyUtil;
4647

4748
/**

src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/SunPKCS11.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353

5454
import sun.security.pkcs11.wrapper.*;
5555
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
56+
import static sun.security.pkcs11.wrapper.PKCS11Exception.*;
5657

5758
/**
5859
* PKCS#11 provider main class.

src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Token.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -38,6 +38,7 @@
3838
import sun.security.pkcs11.wrapper.*;
3939
import static sun.security.pkcs11.TemplateManager.*;
4040
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
41+
import static sun.security.pkcs11.wrapper.PKCS11Exception.*;
4142

4243
/**
4344
* PKCS#11 token.
@@ -385,7 +386,7 @@ CK_MECHANISM_INFO getMechanismInfo(long mechanism) throws PKCS11Exception {
385386
mechanism);
386387
mechInfoMap.put(mechanism, result);
387388
} catch (PKCS11Exception e) {
388-
if (e.getErrorCode() != PKCS11Constants.CKR_MECHANISM_INVALID) {
389+
if (e.getErrorCode() != CKR_MECHANISM_INVALID) {
389390
throw e;
390391
} else {
391392
mechInfoMap.put(mechanism, INVALID_MECH);

src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
33
*/
44

55
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
@@ -57,6 +57,7 @@
5757
import sun.security.util.Debug;
5858

5959
import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
60+
import static sun.security.pkcs11.wrapper.PKCS11Exception.*;
6061

6162
/**
6263
* This is the default implementation of the PKCS11 interface. IT connects to

src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/wrapper/PKCS11Constants.java

Lines changed: 2 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
33
*/
44

55
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
@@ -1043,130 +1043,7 @@ public interface PKCS11Constants {
10431043
public static final long CKF_EXTENSION = 0x80000000L;
10441044

10451045
/* Identifies the return value of a Cryptoki function */
1046-
public static final long CKR_OK = 0x00000000L;
1047-
public static final long CKR_CANCEL = 0x00000001L;
1048-
public static final long CKR_HOST_MEMORY = 0x00000002L;
1049-
public static final long CKR_SLOT_ID_INVALID = 0x00000003L;
1050-
1051-
public static final long CKR_GENERAL_ERROR = 0x00000005L;
1052-
public static final long CKR_FUNCTION_FAILED = 0x00000006L;
1053-
1054-
public static final long CKR_ARGUMENTS_BAD = 0x00000007L;
1055-
public static final long CKR_NO_EVENT = 0x00000008L;
1056-
public static final long CKR_NEED_TO_CREATE_THREADS
1057-
= 0x00000009L;
1058-
public static final long CKR_CANT_LOCK = 0x0000000AL;
1059-
1060-
public static final long CKR_ATTRIBUTE_READ_ONLY = 0x00000010L;
1061-
public static final long CKR_ATTRIBUTE_SENSITIVE = 0x00000011L;
1062-
public static final long CKR_ATTRIBUTE_TYPE_INVALID = 0x00000012L;
1063-
public static final long CKR_ATTRIBUTE_VALUE_INVALID = 0x00000013L;
1064-
public static final long CKR_ACTION_PROHIBITED = 0x0000001BL;
1065-
1066-
public static final long CKR_DATA_INVALID = 0x00000020L;
1067-
public static final long CKR_DATA_LEN_RANGE = 0x00000021L;
1068-
public static final long CKR_DEVICE_ERROR = 0x00000030L;
1069-
public static final long CKR_DEVICE_MEMORY = 0x00000031L;
1070-
public static final long CKR_DEVICE_REMOVED = 0x00000032L;
1071-
public static final long CKR_ENCRYPTED_DATA_INVALID = 0x00000040L;
1072-
public static final long CKR_ENCRYPTED_DATA_LEN_RANGE = 0x00000041L;
1073-
public static final long CKR_AEAD_DECRYPT_FAILED = 0x00000042L;
1074-
public static final long CKR_FUNCTION_CANCELED = 0x00000050L;
1075-
public static final long CKR_FUNCTION_NOT_PARALLEL = 0x00000051L;
1076-
1077-
public static final long CKR_FUNCTION_NOT_SUPPORTED = 0x00000054L;
1078-
1079-
public static final long CKR_KEY_HANDLE_INVALID = 0x00000060L;
1080-
1081-
public static final long CKR_KEY_SIZE_RANGE = 0x00000062L;
1082-
public static final long CKR_KEY_TYPE_INCONSISTENT = 0x00000063L;
1083-
1084-
public static final long CKR_KEY_NOT_NEEDED = 0x00000064L;
1085-
public static final long CKR_KEY_CHANGED = 0x00000065L;
1086-
public static final long CKR_KEY_NEEDED = 0x00000066L;
1087-
public static final long CKR_KEY_INDIGESTIBLE = 0x00000067L;
1088-
public static final long CKR_KEY_FUNCTION_NOT_PERMITTED = 0x00000068L;
1089-
public static final long CKR_KEY_NOT_WRAPPABLE = 0x00000069L;
1090-
public static final long CKR_KEY_UNEXTRACTABLE = 0x0000006AL;
1091-
1092-
public static final long CKR_MECHANISM_INVALID = 0x00000070L;
1093-
public static final long CKR_MECHANISM_PARAM_INVALID = 0x00000071L;
1094-
1095-
public static final long CKR_OBJECT_HANDLE_INVALID = 0x00000082L;
1096-
public static final long CKR_OPERATION_ACTIVE = 0x00000090L;
1097-
public static final long CKR_OPERATION_NOT_INITIALIZED = 0x00000091L;
1098-
public static final long CKR_PIN_INCORRECT = 0x000000A0L;
1099-
public static final long CKR_PIN_INVALID = 0x000000A1L;
1100-
public static final long CKR_PIN_LEN_RANGE = 0x000000A2L;
1101-
1102-
public static final long CKR_PIN_EXPIRED = 0x000000A3L;
1103-
public static final long CKR_PIN_LOCKED = 0x000000A4L;
1104-
1105-
public static final long CKR_SESSION_CLOSED = 0x000000B0L;
1106-
public static final long CKR_SESSION_COUNT = 0x000000B1L;
1107-
public static final long CKR_SESSION_HANDLE_INVALID = 0x000000B3L;
1108-
public static final long CKR_SESSION_PARALLEL_NOT_SUPPORTED = 0x000000B4L;
1109-
public static final long CKR_SESSION_READ_ONLY = 0x000000B5L;
1110-
public static final long CKR_SESSION_EXISTS = 0x000000B6L;
1111-
1112-
public static final long CKR_SESSION_READ_ONLY_EXISTS = 0x000000B7L;
1113-
public static final long CKR_SESSION_READ_WRITE_SO_EXISTS = 0x000000B8L;
1114-
1115-
public static final long CKR_SIGNATURE_INVALID = 0x000000C0L;
1116-
public static final long CKR_SIGNATURE_LEN_RANGE = 0x000000C1L;
1117-
public static final long CKR_TEMPLATE_INCOMPLETE = 0x000000D0L;
1118-
public static final long CKR_TEMPLATE_INCONSISTENT = 0x000000D1L;
1119-
public static final long CKR_TOKEN_NOT_PRESENT = 0x000000E0L;
1120-
public static final long CKR_TOKEN_NOT_RECOGNIZED = 0x000000E1L;
1121-
public static final long CKR_TOKEN_WRITE_PROTECTED = 0x000000E2L;
1122-
public static final long CKR_UNWRAPPING_KEY_HANDLE_INVALID = 0x000000F0L;
1123-
public static final long CKR_UNWRAPPING_KEY_SIZE_RANGE = 0x000000F1L;
1124-
public static final long CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT
1125-
= 0x000000F2L;
1126-
public static final long CKR_USER_ALREADY_LOGGED_IN = 0x00000100L;
1127-
public static final long CKR_USER_NOT_LOGGED_IN = 0x00000101L;
1128-
public static final long CKR_USER_PIN_NOT_INITIALIZED = 0x00000102L;
1129-
public static final long CKR_USER_TYPE_INVALID = 0x00000103L;
1130-
1131-
public static final long CKR_USER_ANOTHER_ALREADY_LOGGED_IN = 0x00000104L;
1132-
public static final long CKR_USER_TOO_MANY_TYPES = 0x00000105L;
1133-
1134-
public static final long CKR_WRAPPED_KEY_INVALID = 0x00000110L;
1135-
public static final long CKR_WRAPPED_KEY_LEN_RANGE = 0x00000112L;
1136-
public static final long CKR_WRAPPING_KEY_HANDLE_INVALID = 0x00000113L;
1137-
public static final long CKR_WRAPPING_KEY_SIZE_RANGE = 0x00000114L;
1138-
public static final long CKR_WRAPPING_KEY_TYPE_INCONSISTENT = 0x00000115L;
1139-
public static final long CKR_RANDOM_SEED_NOT_SUPPORTED = 0x00000120L;
1140-
1141-
public static final long CKR_RANDOM_NO_RNG = 0x00000121L;
1142-
1143-
public static final long CKR_DOMAIN_PARAMS_INVALID = 0x00000130L;
1144-
1145-
public static final long CKR_CURVE_NOT_SUPPORTED = 0x00000140L;
1146-
1147-
public static final long CKR_BUFFER_TOO_SMALL = 0x00000150L;
1148-
public static final long CKR_SAVED_STATE_INVALID = 0x00000160L;
1149-
public static final long CKR_INFORMATION_SENSITIVE = 0x00000170L;
1150-
public static final long CKR_STATE_UNSAVEABLE = 0x00000180L;
1151-
1152-
public static final long CKR_CRYPTOKI_NOT_INITIALIZED = 0x00000190L;
1153-
public static final long CKR_CRYPTOKI_ALREADY_INITIALIZED = 0x00000191L;
1154-
public static final long CKR_MUTEX_BAD = 0x000001A0L;
1155-
public static final long CKR_MUTEX_NOT_LOCKED = 0x000001A1L;
1156-
1157-
public static final long CKR_NEW_PIN_MODE = 0x000001B0L;
1158-
public static final long CKR_NEXT_OTP = 0x000001B1L;
1159-
1160-
public static final long CKR_EXCEEDED_MAX_ITERATIONS = 0x000001B5L;
1161-
public static final long CKR_FIPS_SELF_TEST_FAILED = 0x000001B6L;
1162-
public static final long CKR_LIBRARY_LOAD_FAILED = 0x000001B7L;
1163-
public static final long CKR_PIN_TOO_WEAK = 0x000001B8L;
1164-
public static final long CKR_PUBLIC_KEY_INVALID = 0x000001B9L;
1165-
public static final long CKR_FUNCTION_REJECTED = 0x00000200L;
1166-
public static final long CKR_TOKEN_RESOURCE_EXCEEDED = 0x00000201L;
1167-
public static final long CKR_OPERATION_CANCEL_FAILED = 0x00000202L;
1168-
1169-
public static final long CKR_VENDOR_DEFINED = 0x80000000L;
1046+
// These CKR_xxx constants are stored/defined in PKCS11Exception class
11701047

11711048
/* Uncomment when actually used
11721049
public static final long CKF_END_OF_MESSAGE = 0x00000001L;

0 commit comments

Comments
 (0)