Skip to content

Commit

Permalink
8325254: CKA_TOKEN private and secret keys are not necessarily sensitive
Browse files Browse the repository at this point in the history
Backporting a fix from OpenJDK in advance that changes the sensitivity
check for a key to only include CKA_TOKEN if it's using NSS.

Signed-off-by: Bob Du <[email protected]>
  • Loading branch information
Bob Du committed Feb 28, 2024
1 parent bf83787 commit 338cf0d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,9 @@ static PrivateKey privateKey(Session session, long keyID, String algorithm,
new CK_ATTRIBUTE(CKA_EXTRACTABLE),
});

boolean keySensitive = (attrs[0].getBoolean() ||
attrs[1].getBoolean() || !attrs[2].getBoolean());
boolean keySensitive =
(attrs[0].getBoolean() && P11Util.isNSS(session.token)) ||
attrs[1].getBoolean() || !attrs[2].getBoolean();

if (keySensitive && (SunPKCS11.mysunpkcs11 != null) && "RSA".equals(algorithm)) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ private P11Util() {
// empty
}

static boolean isNSS(Token token) {
char[] tokenLabel = token.tokenInfo.label;
if (tokenLabel != null && tokenLabel.length >= 3) {
return (tokenLabel[0] == 'N' && tokenLabel[1] == 'S'
&& tokenLabel[2] == 'S');
}
return false;
}

static Provider getSunProvider() {
Provider p = sun;
if (p == null) {
Expand Down

0 comments on commit 338cf0d

Please sign in to comment.