mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8172525: Improve key keying case
Reviewed-by: mullan, valeriep, rhalade, ahgross
This commit is contained in:
parent
2ad7c43b76
commit
bb2e7a3311
4 changed files with 30 additions and 5 deletions
|
@ -26,6 +26,7 @@
|
|||
package com.sun.crypto.provider;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.lang.ref.Reference;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
|
@ -208,7 +209,11 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
|
|||
}
|
||||
|
||||
public byte[] getEncoded() {
|
||||
return key.clone();
|
||||
// The key is zeroized by finalize()
|
||||
// The reachability fence ensures finalize() isn't called early
|
||||
byte[] result = key.clone();
|
||||
Reference.reachabilityFence(this);
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getAlgorithm() {
|
||||
|
@ -220,7 +225,11 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
|
|||
}
|
||||
|
||||
public char[] getPassword() {
|
||||
return passwd.clone();
|
||||
// The password is zeroized by finalize()
|
||||
// The reachability fence ensures finalize() isn't called early
|
||||
char[] result = passwd.clone();
|
||||
Reference.reachabilityFence(this);
|
||||
return result;
|
||||
}
|
||||
|
||||
public byte[] getSalt() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue