mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8233884: Avoid looking up standard charsets in security libraries
Reviewed-by: coffeys
This commit is contained in:
parent
301e068935
commit
8e859259bc
48 changed files with 317 additions and 391 deletions
|
@ -51,6 +51,8 @@ import java.security.spec.KeySpec;
|
|||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.util.*;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
import java.security.AlgorithmParameters;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import javax.crypto.spec.PBEParameterSpec;
|
||||
|
@ -687,12 +689,14 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
|||
entry.attributes.addAll(attributes);
|
||||
}
|
||||
// set the keyId to current date
|
||||
entry.keyId = ("Time " + (entry.date).getTime()).getBytes("UTF8");
|
||||
entry.keyId = ("Time " + (entry.date).getTime()).getBytes(UTF_8);
|
||||
// set the alias
|
||||
entry.alias = alias.toLowerCase(Locale.ENGLISH);
|
||||
// add the entry
|
||||
entries.put(alias.toLowerCase(Locale.ENGLISH), entry);
|
||||
|
||||
} catch (KeyStoreException kse) {
|
||||
throw kse;
|
||||
} catch (Exception nsae) {
|
||||
throw new KeyStoreException("Key protection" +
|
||||
" algorithm not found: " + nsae, nsae);
|
||||
|
@ -746,12 +750,8 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
|||
alias + "'");
|
||||
}
|
||||
|
||||
try {
|
||||
// set the keyId to current date
|
||||
entry.keyId = ("Time " + (entry.date).getTime()).getBytes("UTF8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
// Won't happen
|
||||
}
|
||||
// set the keyId to current date
|
||||
entry.keyId = ("Time " + (entry.date).getTime()).getBytes(UTF_8);
|
||||
// set the alias
|
||||
entry.alias = alias.toLowerCase(Locale.ENGLISH);
|
||||
|
||||
|
@ -2499,18 +2499,18 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
|||
// attribute in pkcs12 with one private key entry and
|
||||
// associated cert-chain
|
||||
if (privateKeyCount == 1) {
|
||||
keyId = "01".getBytes("UTF8");
|
||||
keyId = "01".getBytes(UTF_8);
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// keyId in a SecretKeyEntry is not significant
|
||||
keyId = "00".getBytes("UTF8");
|
||||
keyId = "00".getBytes(UTF_8);
|
||||
}
|
||||
}
|
||||
entry.keyId = keyId;
|
||||
// restore date if it exists
|
||||
String keyIdStr = new String(keyId, "UTF8");
|
||||
String keyIdStr = new String(keyId, UTF_8);
|
||||
Date date = null;
|
||||
if (keyIdStr.startsWith("Time ")) {
|
||||
try {
|
||||
|
@ -2547,7 +2547,7 @@ public final class PKCS12KeyStore extends KeyStoreSpi {
|
|||
if ((keyId == null) && (privateKeyCount == 1)) {
|
||||
// insert localKeyID only for EE cert or self-signed cert
|
||||
if (i == 0) {
|
||||
keyId = "01".getBytes("UTF8");
|
||||
keyId = "01".getBytes(UTF_8);
|
||||
}
|
||||
}
|
||||
// Trusted certificate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue