Skip to content

Commit 5b47fc9

Browse files
author
duke
committed
Backport 640b71da48c41e1f216f6bee1e7871961322cf53
1 parent 5e07074 commit 5b47fc9

File tree

2 files changed

+57
-49
lines changed

2 files changed

+57
-49
lines changed

src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_convert.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,8 +1461,7 @@ jobject ckAttributeValueToJObject(JNIEnv *env, const CK_ATTRIBUTE_PTR ckpAttribu
14611461
case CKA_OWNER:
14621462
case CKA_AC_ISSUER:
14631463
case CKA_ATTR_TYPES:
1464-
case CKA_ECDSA_PARAMS:
1465-
/* CKA_EC_PARAMS is the same, these two are equivalent */
1464+
case CKA_EC_PARAMS:
14661465
case CKA_EC_POINT:
14671466
case CKA_PRIVATE_EXPONENT:
14681467
case CKA_PRIME_1:

src/jdk.crypto.cryptoki/share/native/libj2pkcs11/p11_keymgmt.c

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

55
/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
@@ -56,69 +56,78 @@
5656

5757
#ifdef P11_ENABLE_GETNATIVEKEYINFO
5858

59-
#define CK_ATTRIBUTES_TEMPLATE_LENGTH (CK_ULONG)61U
59+
#define CK_ATTRIBUTES_TEMPLATE_LENGTH (CK_ULONG)60U
6060

61+
// Group attributes based on their value types; put attributes whose values
62+
// requiring address alignments, e.g. CK_ULONG, first
6163
static CK_ATTRIBUTE ckpAttributesTemplate[CK_ATTRIBUTES_TEMPLATE_LENGTH] = {
62-
{CKA_CLASS, 0, 0},
63-
{CKA_TOKEN, 0, 0},
64-
{CKA_PRIVATE, 0, 0},
65-
{CKA_LABEL, 0, 0},
66-
{CKA_APPLICATION, 0, 0},
67-
{CKA_VALUE, 0, 0},
68-
{CKA_OBJECT_ID, 0, 0},
64+
// CK_ULONG
6965
{CKA_CERTIFICATE_TYPE, 0, 0},
70-
{CKA_ISSUER, 0, 0},
71-
{CKA_SERIAL_NUMBER, 0, 0},
72-
{CKA_AC_ISSUER, 0, 0},
73-
{CKA_OWNER, 0, 0},
74-
{CKA_ATTR_TYPES, 0, 0},
75-
{CKA_TRUSTED, 0, 0},
66+
{CKA_CLASS, 0, 0},
67+
{CKA_HW_FEATURE_TYPE, 0, 0},
68+
{CKA_KEY_GEN_MECHANISM, 0, 0},
7669
{CKA_KEY_TYPE, 0, 0},
77-
{CKA_SUBJECT, 0, 0},
78-
{CKA_ID, 0, 0},
79-
{CKA_SENSITIVE, 0, 0},
80-
{CKA_ENCRYPT, 0, 0},
81-
{CKA_DECRYPT, 0, 0},
82-
{CKA_WRAP, 0, 0},
83-
{CKA_UNWRAP, 0, 0},
84-
{CKA_SIGN, 0, 0},
85-
{CKA_SIGN_RECOVER, 0, 0},
86-
{CKA_VERIFY, 0, 0},
87-
{CKA_VERIFY_RECOVER, 0, 0},
88-
{CKA_DERIVE, 0, 0},
89-
{CKA_START_DATE, 0, 0},
90-
{CKA_END_DATE, 0, 0},
91-
{CKA_MODULUS, 0, 0},
9270
{CKA_MODULUS_BITS, 0, 0},
93-
{CKA_PUBLIC_EXPONENT, 0, 0},
94-
{CKA_PRIVATE_EXPONENT, 0, 0},
95-
{CKA_PRIME_1, 0, 0},
96-
{CKA_PRIME_2, 0, 0},
97-
{CKA_EXPONENT_1, 0, 0},
98-
{CKA_EXPONENT_2, 0, 0},
99-
{CKA_COEFFICIENT, 0, 0},
100-
{CKA_PRIME, 0, 0},
101-
{CKA_SUBPRIME, 0, 0},
102-
{CKA_BASE, 0, 0},
10371
{CKA_PRIME_BITS, 0, 0},
10472
{CKA_SUB_PRIME_BITS, 0, 0},
10573
{CKA_VALUE_BITS, 0, 0},
10674
{CKA_VALUE_LEN, 0, 0},
75+
// CK_BBOOL
76+
{CKA_ALWAYS_SENSITIVE, 0, 0},
77+
{CKA_DECRYPT, 0, 0},
78+
{CKA_DERIVE, 0, 0},
79+
{CKA_ENCRYPT, 0, 0},
10780
{CKA_EXTRACTABLE, 0, 0},
81+
{CKA_HAS_RESET, 0, 0},
10882
{CKA_LOCAL, 0, 0},
109-
{CKA_NEVER_EXTRACTABLE, 0, 0},
110-
{CKA_ALWAYS_SENSITIVE, 0, 0},
111-
{CKA_KEY_GEN_MECHANISM, 0, 0},
11283
{CKA_MODIFIABLE, 0, 0},
113-
{CKA_ECDSA_PARAMS, 0, 0},
84+
{CKA_NEVER_EXTRACTABLE, 0, 0},
85+
{CKA_PRIVATE, 0, 0},
86+
{CKA_RESET_ON_INIT, 0, 0},
87+
{CKA_SENSITIVE, 0, 0},
88+
{CKA_SIGN, 0, 0},
89+
{CKA_SIGN_RECOVER, 0, 0},
90+
{CKA_TOKEN, 0, 0},
91+
{CKA_TRUSTED, 0, 0},
92+
{CKA_UNWRAP, 0, 0},
93+
{CKA_VERIFY, 0, 0},
94+
{CKA_VERIFY_RECOVER, 0, 0},
95+
{CKA_WRAP, 0, 0},
96+
// PTR: byte[]
97+
{CKA_AC_ISSUER, 0, 0},
98+
{CKA_ATTR_TYPES, 0, 0},
99+
{CKA_BASE, 0, 0},
100+
{CKA_COEFFICIENT, 0, 0},
114101
{CKA_EC_PARAMS, 0, 0},
115102
{CKA_EC_POINT, 0, 0},
103+
{CKA_EXPONENT_1, 0, 0},
104+
{CKA_EXPONENT_2, 0, 0},
105+
{CKA_ID, 0, 0},
106+
{CKA_ISSUER, 0, 0},
107+
{CKA_MODULUS, 0, 0},
108+
{CKA_OBJECT_ID, 0, 0},
109+
{CKA_OWNER, 0, 0},
110+
{CKA_PRIME, 0, 0},
111+
{CKA_PRIME_1, 0, 0},
112+
{CKA_PRIME_2, 0, 0},
113+
{CKA_PRIVATE_EXPONENT, 0, 0},
114+
{CKA_PUBLIC_EXPONENT, 0, 0},
115+
{CKA_SERIAL_NUMBER, 0, 0},
116+
{CKA_SUBJECT, 0, 0},
117+
{CKA_SUBPRIME, 0, 0},
118+
{CKA_VALUE, 0, 0},
119+
// PTR: CK_UTF8CHAR[]
120+
{CKA_APPLICATION, 0, 0},
121+
{CKA_LABEL, 0, 0},
122+
// PTR: CK_DATE
123+
{CKA_START_DATE, 0, 0},
124+
{CKA_END_DATE, 0, 0},
125+
// deprecated
116126
{CKA_SECONDARY_AUTH, 0, 0},
117127
{CKA_AUTH_PIN_FLAGS, 0, 0},
118-
{CKA_HW_FEATURE_TYPE, 0, 0},
119-
{CKA_RESET_ON_INIT, 0, 0},
120-
{CKA_HAS_RESET, 0, 0},
128+
// misc
121129
{CKA_VENDOR_DEFINED, 0, 0},
130+
// keep this at the end to match the impl in getNativeKeyInfo(...)
122131
{CKA_NETSCAPE_DB, 0, 0},
123132
};
124133

0 commit comments

Comments
 (0)