8233884: Avoid looking up standard charsets in security libraries

Reviewed-by: coffeys
This commit is contained in:
Ivan Gerasimov 2019-11-12 01:36:17 -08:00
parent 301e068935
commit 8e859259bc
48 changed files with 317 additions and 391 deletions

View file

@ -29,7 +29,6 @@ import java.io.ObjectStreamException;
import java.lang.ref.Reference;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Locale;
import java.security.MessageDigest;
@ -41,6 +40,8 @@ import javax.crypto.Mac;
import javax.crypto.SecretKey;
import javax.crypto.spec.PBEKeySpec;
import static java.nio.charset.StandardCharsets.UTF_8;
import jdk.internal.ref.CleanerFactory;
/**
@ -66,9 +67,8 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
private Mac prf;
private static byte[] getPasswordBytes(char[] passwd) {
Charset utf8 = Charset.forName("UTF-8");
CharBuffer cb = CharBuffer.wrap(passwd);
ByteBuffer bb = utf8.encode(cb);
ByteBuffer bb = UTF_8.encode(cb);
int len = bb.limit();
byte[] passwdBytes = new byte[len];