8284112: Minor cleanup could be done in javax.crypto
Reviewed-by: wetmore
This commit is contained in:
parent
897d6c0dc7
commit
41fc078323
@ -221,7 +221,7 @@ public class Cipher {
|
||||
private CipherSpi spi;
|
||||
|
||||
// The transformation
|
||||
private String transformation;
|
||||
private final String transformation;
|
||||
|
||||
// Crypto permission representing the maximum allowable cryptographic
|
||||
// strength that this Cipher object can be used for. (The cryptographic
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,11 +25,9 @@
|
||||
|
||||
package javax.crypto;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.FilterInputStream;
|
||||
import java.io.IOException;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* A CipherInputStream is composed of an InputStream and a Cipher so
|
||||
@ -77,15 +75,15 @@ import javax.crypto.IllegalBlockSizeException;
|
||||
public class CipherInputStream extends FilterInputStream {
|
||||
|
||||
// the cipher engine to use to process stream data
|
||||
private Cipher cipher;
|
||||
private final Cipher cipher;
|
||||
|
||||
// the underlying input stream
|
||||
private InputStream input;
|
||||
private final InputStream input;
|
||||
|
||||
/* the buffer holding data that have been read in from the
|
||||
underlying stream, but have not been processed by the cipher
|
||||
engine. the size 512 bytes is somewhat randomly chosen */
|
||||
private byte[] ibuffer = new byte[512];
|
||||
private final byte[] ibuffer = new byte[512];
|
||||
|
||||
// having reached the end of the underlying input stream
|
||||
private boolean done = false;
|
||||
@ -215,7 +213,7 @@ public class CipherInputStream extends FilterInputStream {
|
||||
if (i == -1) return -1;
|
||||
}
|
||||
return ((int) obuffer[ostart++] & 0xff);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads up to <code>b.length</code> bytes of data from this input
|
||||
@ -233,7 +231,7 @@ public class CipherInputStream extends FilterInputStream {
|
||||
* @see java.io.InputStream#read(byte[], int, int)
|
||||
*/
|
||||
@Override
|
||||
public int read(byte b[]) throws IOException {
|
||||
public int read(byte[] b) throws IOException {
|
||||
return read(b, 0, b.length);
|
||||
}
|
||||
|
||||
@ -254,7 +252,7 @@ public class CipherInputStream extends FilterInputStream {
|
||||
* @see java.io.InputStream#read()
|
||||
*/
|
||||
@Override
|
||||
public int read(byte b[], int off, int len) throws IOException {
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
if (ostart >= ofinish) {
|
||||
// we loop for new data as the spec says we are blocking
|
||||
int i = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -71,13 +71,13 @@ import java.io.*;
|
||||
public class CipherOutputStream extends FilterOutputStream {
|
||||
|
||||
// the cipher engine to use to process stream data
|
||||
private Cipher cipher;
|
||||
private final Cipher cipher;
|
||||
|
||||
// the underlying output stream
|
||||
private OutputStream output;
|
||||
private final OutputStream output;
|
||||
|
||||
/* the buffer holding one byte of incoming data */
|
||||
private byte[] ibuffer = new byte[1];
|
||||
private final byte[] ibuffer = new byte[1];
|
||||
|
||||
// the buffer holding data ready to be written out
|
||||
private byte[] obuffer = null;
|
||||
@ -113,7 +113,7 @@ public class CipherOutputStream extends FilterOutputStream {
|
||||
super(os);
|
||||
output = os;
|
||||
cipher = c;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a CipherOutputStream from an OutputStream without
|
||||
@ -149,7 +149,7 @@ public class CipherOutputStream extends FilterOutputStream {
|
||||
// should never happen; re-throw just in case
|
||||
throw new IOException(sbe);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes <code>b.length</code> bytes from the specified byte array
|
||||
@ -166,7 +166,7 @@ public class CipherOutputStream extends FilterOutputStream {
|
||||
* @see javax.crypto.CipherOutputStream#write(byte[], int, int)
|
||||
*/
|
||||
@Override
|
||||
public void write(byte b[]) throws IOException {
|
||||
public void write(byte[] b) throws IOException {
|
||||
write(b, 0, b.length);
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ public class CipherOutputStream extends FilterOutputStream {
|
||||
* @exception IOException if an I/O error occurs.
|
||||
*/
|
||||
@Override
|
||||
public void write(byte b[], int off, int len) throws IOException {
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
ensureCapacity(len);
|
||||
try {
|
||||
int ostored = cipher.update(b, off, len, obuffer);
|
||||
|
@ -25,16 +25,9 @@
|
||||
|
||||
package javax.crypto;
|
||||
|
||||
import java.security.AlgorithmParameters;
|
||||
import java.security.Key;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.ProviderException;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.*;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
/**
|
||||
* This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
|
||||
@ -540,7 +533,7 @@ public abstract class CipherSpi {
|
||||
* process ByteBuffers more efficiently than byte arrays.
|
||||
*
|
||||
* @param input the input ByteBuffer
|
||||
* @param output the output ByteByffer
|
||||
* @param output the output ByteBuffer
|
||||
*
|
||||
* @return the number of bytes stored in <code>output</code>
|
||||
*
|
||||
@ -701,7 +694,7 @@ public abstract class CipherSpi {
|
||||
* process ByteBuffers more efficiently than byte arrays.
|
||||
*
|
||||
* @param input the input ByteBuffer
|
||||
* @param output the output ByteByffer
|
||||
* @param output the output ByteBuffer
|
||||
*
|
||||
* @return the number of bytes stored in <code>output</code>
|
||||
*
|
||||
@ -771,8 +764,9 @@ public abstract class CipherSpi {
|
||||
byte[] inArray = input.array();
|
||||
int inOfs = input.arrayOffset() + inPos;
|
||||
|
||||
byte[] outArray;
|
||||
if (a2) { // output has an accessible byte[]
|
||||
byte[] outArray = output.array();
|
||||
outArray = output.array();
|
||||
int outPos = output.position();
|
||||
int outOfs = output.arrayOffset() + outPos;
|
||||
|
||||
@ -797,10 +791,7 @@ public abstract class CipherSpi {
|
||||
// adjust output position manually
|
||||
output.position(outPos + total);
|
||||
}
|
||||
// adjust input position manually
|
||||
input.position(inLimit);
|
||||
} else { // output does not have an accessible byte[]
|
||||
byte[] outArray = null;
|
||||
if (isUpdate) {
|
||||
outArray = engineUpdate(inArray, inOfs, inLen);
|
||||
} else {
|
||||
@ -810,9 +801,9 @@ public abstract class CipherSpi {
|
||||
output.put(outArray);
|
||||
total = outArray.length;
|
||||
}
|
||||
// adjust input position manually
|
||||
input.position(inLimit);
|
||||
}
|
||||
// adjust input position manually
|
||||
input.position(inLimit);
|
||||
} else { // input does not have an accessible byte[]
|
||||
// have to assume the worst, since we have no way of determine
|
||||
// if input and output overlaps or not
|
||||
@ -934,7 +925,7 @@ public abstract class CipherSpi {
|
||||
}
|
||||
|
||||
/**
|
||||
* Continues a multi-part update of the Additional Authentication
|
||||
* Continues a multipart update of the Additional Authentication
|
||||
* Data (AAD), using a subset of the provided buffer.
|
||||
* <p>
|
||||
* Calls to this method provide AAD to the cipher when operating in
|
||||
@ -964,7 +955,7 @@ public abstract class CipherSpi {
|
||||
}
|
||||
|
||||
/**
|
||||
* Continues a multi-part update of the Additional Authentication
|
||||
* Continues a multipart update of the Additional Authentication
|
||||
* Data (AAD).
|
||||
* <p>
|
||||
* Calls to this method provide AAD to the cipher when operating in
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,6 +25,7 @@
|
||||
|
||||
package javax.crypto;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.security.*;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.io.Serializable;
|
||||
@ -52,7 +53,7 @@ class CryptoPermission extends java.security.Permission {
|
||||
@java.io.Serial
|
||||
private static final long serialVersionUID = 8987399626114087514L;
|
||||
|
||||
private String alg;
|
||||
private final String alg;
|
||||
private int maxKeySize = Integer.MAX_VALUE; // no restriction on maxKeySize
|
||||
private String exemptionMechanism = null;
|
||||
@SuppressWarnings("serial") // Not statically typed as Serializable
|
||||
@ -219,11 +220,9 @@ class CryptoPermission extends java.security.Permission {
|
||||
* implied by this permission, false otherwise.
|
||||
*/
|
||||
public boolean implies(Permission p) {
|
||||
if (!(p instanceof CryptoPermission))
|
||||
if (!(p instanceof CryptoPermission cp))
|
||||
return false;
|
||||
|
||||
CryptoPermission cp = (CryptoPermission)p;
|
||||
|
||||
if ((!alg.equalsIgnoreCase(cp.alg)) &&
|
||||
(!alg.equalsIgnoreCase(ALG_NAME_WILDCARD))) {
|
||||
return false;
|
||||
@ -238,9 +237,7 @@ class CryptoPermission extends java.security.Permission {
|
||||
}
|
||||
|
||||
// check exemptionMechanism.
|
||||
if (impliesExemptionMechanism(cp.exemptionMechanism)) {
|
||||
return true;
|
||||
}
|
||||
return impliesExemptionMechanism(cp.exemptionMechanism);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -261,11 +258,9 @@ class CryptoPermission extends java.security.Permission {
|
||||
if (obj == this)
|
||||
return true;
|
||||
|
||||
if (!(obj instanceof CryptoPermission))
|
||||
if (!(obj instanceof CryptoPermission that))
|
||||
return false;
|
||||
|
||||
CryptoPermission that = (CryptoPermission) obj;
|
||||
|
||||
if (!(alg.equalsIgnoreCase(that.alg)) ||
|
||||
(maxKeySize != that.maxKeySize)) {
|
||||
return false;
|
||||
@ -300,7 +295,7 @@ class CryptoPermission extends java.security.Permission {
|
||||
|
||||
/**
|
||||
* There is no action defined for a CryptoPermission
|
||||
* onject.
|
||||
* object.
|
||||
*/
|
||||
public String getActions()
|
||||
{
|
||||
@ -398,11 +393,7 @@ class CryptoPermission extends java.security.Permission {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.exemptionMechanism.equals(exemptionMechanism)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return this.exemptionMechanism.equals(exemptionMechanism);
|
||||
}
|
||||
|
||||
private boolean impliesParameterSpec(boolean checkParam,
|
||||
@ -442,20 +433,15 @@ class CryptoPermission extends java.security.Permission {
|
||||
|
||||
// For classes we don't know, the following
|
||||
// may be the best try.
|
||||
if (this.algParamSpec.equals(algParamSpec)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} else if (this.checkParam) {
|
||||
return false;
|
||||
return this.algParamSpec.equals(algParamSpec);
|
||||
} else {
|
||||
return true;
|
||||
return !this.checkParam;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean equalObjects(Object obj1, Object obj2) {
|
||||
if (obj1 == null) {
|
||||
return (obj2 == null ? true : false);
|
||||
return (obj2 == null);
|
||||
}
|
||||
|
||||
return obj1.equals(obj2);
|
||||
@ -475,16 +461,17 @@ class CryptoPermission extends java.security.Permission {
|
||||
final class CryptoPermissionCollection extends PermissionCollection
|
||||
implements Serializable
|
||||
{
|
||||
@Serial
|
||||
private static final long serialVersionUID = -511215555898802763L;
|
||||
|
||||
private Vector<Permission> permissions;
|
||||
private final Vector<Permission> permissions;
|
||||
|
||||
/**
|
||||
* Creates an empty CryptoPermissionCollection
|
||||
* object.
|
||||
*/
|
||||
CryptoPermissionCollection() {
|
||||
permissions = new Vector<Permission>(3);
|
||||
permissions = new Vector<>(3);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -516,11 +503,9 @@ final class CryptoPermissionCollection extends PermissionCollection
|
||||
* CryptoPermissionCollection, false if not.
|
||||
*/
|
||||
public boolean implies(Permission permission) {
|
||||
if (!(permission instanceof CryptoPermission))
|
||||
if (!(permission instanceof CryptoPermission cp))
|
||||
return false;
|
||||
|
||||
CryptoPermission cp = (CryptoPermission)permission;
|
||||
|
||||
Enumeration<Permission> e = permissions.elements();
|
||||
|
||||
while (e.hasMoreElements()) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -143,11 +143,10 @@ implements Serializable {
|
||||
"object");
|
||||
}
|
||||
|
||||
if (!(permission instanceof CryptoPermission)) {
|
||||
if (!(permission instanceof CryptoPermission cryptoPerm)) {
|
||||
return;
|
||||
}
|
||||
|
||||
CryptoPermission cryptoPerm = (CryptoPermission)permission;
|
||||
PermissionCollection pc =
|
||||
getPermissionCollection(cryptoPerm);
|
||||
pc.add(cryptoPerm);
|
||||
@ -156,7 +155,7 @@ implements Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this object's PermissionCollection for permissons
|
||||
* Checks if this object's PermissionCollection for permissions
|
||||
* of the specified permission's algorithm implies the specified
|
||||
* permission. Returns true if the checking succeeded.
|
||||
*
|
||||
@ -168,12 +167,10 @@ implements Serializable {
|
||||
*/
|
||||
@Override
|
||||
public boolean implies(Permission permission) {
|
||||
if (!(permission instanceof CryptoPermission)) {
|
||||
if (!(permission instanceof CryptoPermission cryptoPerm)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
CryptoPermission cryptoPerm = (CryptoPermission)permission;
|
||||
|
||||
PermissionCollection pc =
|
||||
getPermissionCollection(cryptoPerm.getAlgorithm());
|
||||
|
||||
@ -299,7 +296,7 @@ implements Serializable {
|
||||
* Get the minimum of the two given PermissionCollection
|
||||
* <code>thisPc</code> and <code>thatPc</code>.
|
||||
*
|
||||
* @param thisPc the first given PermissionColloection
|
||||
* @param thisPc the first given PermissionCollection
|
||||
* object.
|
||||
*
|
||||
* @param thatPc the second given PermissionCollection
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -66,7 +66,7 @@ import java.lang.reflect.*;
|
||||
|
||||
final class CryptoPolicyParser {
|
||||
|
||||
private Vector<GrantEntry> grantEntries;
|
||||
private final Vector<GrantEntry> grantEntries;
|
||||
|
||||
// Convenience variables for parsing
|
||||
private StreamTokenizer st;
|
||||
@ -76,7 +76,7 @@ final class CryptoPolicyParser {
|
||||
* Creates a CryptoPolicyParser object.
|
||||
*/
|
||||
CryptoPolicyParser() {
|
||||
grantEntries = new Vector<GrantEntry>();
|
||||
grantEntries = new Vector<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,8 +141,7 @@ final class CryptoPolicyParser {
|
||||
while (lookahead != StreamTokenizer.TT_EOF) {
|
||||
if (peek("grant")) {
|
||||
GrantEntry ge = parseGrantEntry(processedPermissions);
|
||||
if (ge != null)
|
||||
grantEntries.addElement(ge);
|
||||
grantEntries.addElement(ge);
|
||||
} else {
|
||||
throw new ParsingException(st.lineno(), "expected grant " +
|
||||
"statement");
|
||||
@ -280,11 +279,11 @@ final class CryptoPolicyParser {
|
||||
return e;
|
||||
}
|
||||
|
||||
private static final AlgorithmParameterSpec getInstance(String type,
|
||||
Integer[] params)
|
||||
private static AlgorithmParameterSpec getInstance(String type,
|
||||
Integer[] params)
|
||||
throws ParsingException
|
||||
{
|
||||
AlgorithmParameterSpec ret = null;
|
||||
AlgorithmParameterSpec ret;
|
||||
|
||||
try {
|
||||
Class<?> apsClass = Class.forName(type);
|
||||
@ -496,7 +495,7 @@ final class CryptoPolicyParser {
|
||||
exemptionMechanism == null ? "none" : exemptionMechanism;
|
||||
|
||||
if (processedPermissions == null) {
|
||||
processedPermissions = new Hashtable<String, Vector<String>>();
|
||||
processedPermissions = new Hashtable<>();
|
||||
Vector<String> exemptionMechanisms = new Vector<>(1);
|
||||
exemptionMechanisms.addElement(thisExemptionMechanism);
|
||||
processedPermissions.put(alg, exemptionMechanisms);
|
||||
@ -515,7 +514,7 @@ final class CryptoPolicyParser {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
exemptionMechanisms = new Vector<String>(1);
|
||||
exemptionMechanisms = new Vector<>(1);
|
||||
}
|
||||
|
||||
exemptionMechanisms.addElement(thisExemptionMechanism);
|
||||
@ -553,10 +552,10 @@ final class CryptoPolicyParser {
|
||||
|
||||
private static class GrantEntry {
|
||||
|
||||
private Vector<CryptoPermissionEntry> permissionEntries;
|
||||
private final Vector<CryptoPermissionEntry> permissionEntries;
|
||||
|
||||
GrantEntry() {
|
||||
permissionEntries = new Vector<CryptoPermissionEntry>();
|
||||
permissionEntries = new Vector<>();
|
||||
}
|
||||
|
||||
void add(CryptoPermissionEntry pe)
|
||||
@ -643,11 +642,9 @@ final class CryptoPolicyParser {
|
||||
if (obj == this)
|
||||
return true;
|
||||
|
||||
if (!(obj instanceof CryptoPermissionEntry))
|
||||
if (!(obj instanceof CryptoPermissionEntry that))
|
||||
return false;
|
||||
|
||||
CryptoPermissionEntry that = (CryptoPermissionEntry) obj;
|
||||
|
||||
if (this.cryptoPermission == null) {
|
||||
if (that.cryptoPermission != null) return false;
|
||||
} else {
|
||||
@ -668,14 +665,10 @@ final class CryptoPolicyParser {
|
||||
if (this.checkParam != that.checkParam) return false;
|
||||
|
||||
if (this.algParamSpec == null) {
|
||||
if (that.algParamSpec != null) return false;
|
||||
return that.algParamSpec == null;
|
||||
} else {
|
||||
if (!this.algParamSpec.equals(that.algParamSpec))
|
||||
return false;
|
||||
return this.algParamSpec.equals(that.algParamSpec);
|
||||
}
|
||||
|
||||
// everything matched -- the 2 objects are equal
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -58,16 +58,16 @@ import sun.security.util.DerOutputStream;
|
||||
public class EncryptedPrivateKeyInfo {
|
||||
|
||||
// the "encryptionAlgorithm" field
|
||||
private AlgorithmId algid;
|
||||
private final AlgorithmId algid;
|
||||
|
||||
// the algorithm name of the encrypted private key
|
||||
private String keyAlg;
|
||||
|
||||
// the "encryptedData" field
|
||||
private byte[] encryptedData;
|
||||
private final byte[] encryptedData;
|
||||
|
||||
// the ASN.1 encoded contents of this class
|
||||
private byte[] encoded = null;
|
||||
private byte[] encoded;
|
||||
|
||||
/**
|
||||
* Constructs (i.e., parses) an <code>EncryptedPrivateKeyInfo</code> from
|
||||
@ -124,7 +124,7 @@ public class EncryptedPrivateKeyInfo {
|
||||
* Java Security Standard Algorithm Names</a> document
|
||||
* for information about standard Cipher algorithm names.
|
||||
* @param encryptedData encrypted data. The contents of
|
||||
* <code>encrypedData</code> are copied to protect against subsequent
|
||||
* <code>encryptedData</code> are copied to protect against subsequent
|
||||
* modification when constructing this object.
|
||||
* @exception NullPointerException if <code>algName</code> or
|
||||
* <code>encryptedData</code> is null.
|
||||
@ -162,10 +162,10 @@ public class EncryptedPrivateKeyInfo {
|
||||
* @param algParams the algorithm parameters for the encryption
|
||||
* algorithm. <code>algParams.getEncoded()</code> should return
|
||||
* the ASN.1 encoded bytes of the <code>parameters</code> field
|
||||
* of the <code>AlgorithmIdentifer</code> component of the
|
||||
* of the <code>AlgorithmIdentifier</code> component of the
|
||||
* <code>EncryptedPrivateKeyInfo</code> type.
|
||||
* @param encryptedData encrypted data. The contents of
|
||||
* <code>encrypedData</code> are copied to protect against
|
||||
* <code>encryptedData</code> are copied to protect against
|
||||
* subsequent modification when constructing this object.
|
||||
* @exception NullPointerException if <code>algParams</code> or
|
||||
* <code>encryptedData</code> is null.
|
||||
@ -248,7 +248,7 @@ public class EncryptedPrivateKeyInfo {
|
||||
*/
|
||||
public PKCS8EncodedKeySpec getKeySpec(Cipher cipher)
|
||||
throws InvalidKeySpecException {
|
||||
byte[] encoded = null;
|
||||
byte[] encoded;
|
||||
try {
|
||||
encoded = cipher.doFinal(encryptedData);
|
||||
checkPKCS8Encoding(encoded);
|
||||
@ -264,7 +264,7 @@ public class EncryptedPrivateKeyInfo {
|
||||
private PKCS8EncodedKeySpec getKeySpecImpl(Key decryptKey,
|
||||
Provider provider) throws NoSuchAlgorithmException,
|
||||
InvalidKeyException {
|
||||
byte[] encoded = null;
|
||||
byte[] encoded;
|
||||
Cipher c;
|
||||
try {
|
||||
if (provider == null) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -52,13 +52,13 @@ import sun.security.jca.GetInstance.Instance;
|
||||
public class ExemptionMechanism {
|
||||
|
||||
// The provider
|
||||
private Provider provider;
|
||||
private final Provider provider;
|
||||
|
||||
// The provider implementation (delegate)
|
||||
private ExemptionMechanismSpi exmechSpi;
|
||||
private final ExemptionMechanismSpi exmechSpi;
|
||||
|
||||
// The name of the exemption mechanism.
|
||||
private String mechanism;
|
||||
private final String mechanism;
|
||||
|
||||
// Flag which indicates whether this ExemptionMechanism
|
||||
// result is generated successfully.
|
||||
@ -118,7 +118,7 @@ public class ExemptionMechanism {
|
||||
* {@code jdk.security.provider.preferred}
|
||||
* {@link Security#getProperty(String) Security} property to determine
|
||||
* the preferred provider order for the specified algorithm. This
|
||||
* may be different than the order of providers returned by
|
||||
* may be different from the order of providers returned by
|
||||
* {@link Security#getProviders() Security.getProviders()}.
|
||||
*
|
||||
* @param algorithm the standard name of the requested exemption
|
||||
@ -228,7 +228,7 @@ public class ExemptionMechanism {
|
||||
* @see java.security.Provider
|
||||
*/
|
||||
public static final ExemptionMechanism getInstance(String algorithm,
|
||||
Provider provider) throws NoSuchAlgorithmException {
|
||||
Provider provider) throws NoSuchAlgorithmException {
|
||||
Objects.requireNonNull(algorithm, "null algorithm name");
|
||||
Instance instance = JceSecurity.getInstance("ExemptionMechanism",
|
||||
ExemptionMechanismSpi.class, algorithm, provider);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -90,7 +90,7 @@ final class JceSecurityManager {
|
||||
CryptoPermission getCryptoPermission(String theAlg) {
|
||||
|
||||
// Need to convert to uppercase since the crypto perm
|
||||
// lookup is case sensitive.
|
||||
// lookup is case-sensitive.
|
||||
final String alg = theAlg.toUpperCase(Locale.ENGLISH);
|
||||
|
||||
// If CryptoAllPermission is granted by default, we return that.
|
||||
@ -199,7 +199,6 @@ final class JceSecurityManager {
|
||||
return cp;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return defaultPerm;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -157,7 +157,7 @@ public class KeyAgreement {
|
||||
* {@code jdk.security.provider.preferred}
|
||||
* {@link Security#getProperty(String) Security} property to determine
|
||||
* the preferred provider order for the specified algorithm. This
|
||||
* may be different than the order of providers returned by
|
||||
* may be different from the order of providers returned by
|
||||
* {@link Security#getProviders() Security.getProviders()}.
|
||||
*
|
||||
* @param algorithm the standard name of the requested key agreement
|
||||
@ -186,7 +186,7 @@ public class KeyAgreement {
|
||||
Iterator<Service> t = services.iterator();
|
||||
while (t.hasNext()) {
|
||||
Service s = t.next();
|
||||
if (JceSecurity.canUseProvider(s.getProvider()) == false) {
|
||||
if (!JceSecurity.canUseProvider(s.getProvider())) {
|
||||
continue;
|
||||
}
|
||||
return new KeyAgreement(s, t, algorithm);
|
||||
@ -319,12 +319,12 @@ public class KeyAgreement {
|
||||
} else {
|
||||
s = serviceIterator.next();
|
||||
}
|
||||
if (JceSecurity.canUseProvider(s.getProvider()) == false) {
|
||||
if (!JceSecurity.canUseProvider(s.getProvider())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
Object obj = s.newInstance(null);
|
||||
if (obj instanceof KeyAgreementSpi == false) {
|
||||
if (!(obj instanceof KeyAgreementSpi)) {
|
||||
continue;
|
||||
}
|
||||
spi = (KeyAgreementSpi)obj;
|
||||
@ -377,10 +377,10 @@ public class KeyAgreement {
|
||||
s = serviceIterator.next();
|
||||
}
|
||||
// if provider says it does not support this key, ignore it
|
||||
if (s.supportsParameter(key) == false) {
|
||||
if (!s.supportsParameter(key)) {
|
||||
continue;
|
||||
}
|
||||
if (JceSecurity.canUseProvider(s.getProvider()) == false) {
|
||||
if (!JceSecurity.canUseProvider(s.getProvider())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
@ -563,7 +563,7 @@ public class KeyAgreement {
|
||||
* @param key the key for this phase. For example, in the case of
|
||||
* Diffie-Hellman between 2 parties, this would be the other party's
|
||||
* Diffie-Hellman public key.
|
||||
* @param lastPhase flag which indicates whether or not this is the last
|
||||
* @param lastPhase flag which indicates whether this is the last
|
||||
* phase of this key agreement.
|
||||
*
|
||||
* @return the (intermediate) key resulting from this phase, or null
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -118,7 +118,7 @@ public abstract class KeyAgreementSpi {
|
||||
* @param key the key for this phase. For example, in the case of
|
||||
* Diffie-Hellman between 2 parties, this would be the other party's
|
||||
* Diffie-Hellman public key.
|
||||
* @param lastPhase flag which indicates whether or not this is the last
|
||||
* @param lastPhase flag which indicates whether this is the last
|
||||
* phase of this key agreement.
|
||||
*
|
||||
* @return the (intermediate) key resulting from this phase, or null if
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -218,7 +218,7 @@ public class KeyGenerator {
|
||||
* {@code jdk.security.provider.preferred}
|
||||
* {@link Security#getProperty(String) Security} property to determine
|
||||
* the preferred provider order for the specified algorithm. This
|
||||
* may be different than the order of providers returned by
|
||||
* may be different from the order of providers returned by
|
||||
* {@link Security#getProviders() Security.getProviders()}.
|
||||
*
|
||||
* @param algorithm the standard name of the requested key algorithm.
|
||||
@ -359,16 +359,15 @@ public class KeyGenerator {
|
||||
}
|
||||
while (serviceIterator.hasNext()) {
|
||||
Service s = serviceIterator.next();
|
||||
if (JceSecurity.canUseProvider(s.getProvider()) == false) {
|
||||
if (!JceSecurity.canUseProvider(s.getProvider())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
Object inst = s.newInstance(null);
|
||||
// ignore non-spis
|
||||
if (inst instanceof KeyGeneratorSpi == false) {
|
||||
if (!(inst instanceof KeyGeneratorSpi spi)) {
|
||||
continue;
|
||||
}
|
||||
KeyGeneratorSpi spi = (KeyGeneratorSpi)inst;
|
||||
if (reinit) {
|
||||
if (initType == I_SIZE) {
|
||||
spi.engineInit(initKeySize, initRandom);
|
||||
@ -489,10 +488,7 @@ public class KeyGenerator {
|
||||
if (failure instanceof InvalidAlgorithmParameterException) {
|
||||
throw (InvalidAlgorithmParameterException)failure;
|
||||
}
|
||||
if (failure instanceof RuntimeException) {
|
||||
throw (RuntimeException)failure;
|
||||
}
|
||||
throw new InvalidAlgorithmParameterException("init() failed", failure);
|
||||
throw (RuntimeException)failure;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -156,7 +156,7 @@ public class Mac implements Cloneable {
|
||||
* {@code jdk.security.provider.preferred}
|
||||
* {@link Security#getProperty(String) Security} property to determine
|
||||
* the preferred provider order for the specified algorithm. This
|
||||
* may be different than the order of providers returned by
|
||||
* may be different from the order of providers returned by
|
||||
* {@link Security#getProviders() Security.getProviders()}.
|
||||
*
|
||||
* @param algorithm the standard name of the requested MAC algorithm.
|
||||
@ -182,7 +182,7 @@ public class Mac implements Cloneable {
|
||||
Iterator<Service> t = services.iterator();
|
||||
while (t.hasNext()) {
|
||||
Service s = t.next();
|
||||
if (JceSecurity.canUseProvider(s.getProvider()) == false) {
|
||||
if (!JceSecurity.canUseProvider(s.getProvider())) {
|
||||
continue;
|
||||
}
|
||||
return new Mac(s, t, algorithm);
|
||||
@ -310,12 +310,12 @@ public class Mac implements Cloneable {
|
||||
} else {
|
||||
s = serviceIterator.next();
|
||||
}
|
||||
if (JceSecurity.canUseProvider(s.getProvider()) == false) {
|
||||
if (!JceSecurity.canUseProvider(s.getProvider())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
Object obj = s.newInstance(null);
|
||||
if (obj instanceof MacSpi == false) {
|
||||
if (!(obj instanceof MacSpi)) {
|
||||
continue;
|
||||
}
|
||||
spi = (MacSpi)obj;
|
||||
@ -354,10 +354,10 @@ public class Mac implements Cloneable {
|
||||
s = serviceIterator.next();
|
||||
}
|
||||
// if provider says it does not support this key, ignore it
|
||||
if (s.supportsParameter(key) == false) {
|
||||
if (!s.supportsParameter(key)) {
|
||||
continue;
|
||||
}
|
||||
if (JceSecurity.canUseProvider(s.getProvider()) == false) {
|
||||
if (!JceSecurity.canUseProvider(s.getProvider())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
@ -481,7 +481,7 @@ public class Mac implements Cloneable {
|
||||
*/
|
||||
public final void update(byte input) throws IllegalStateException {
|
||||
chooseFirstProvider();
|
||||
if (initialized == false) {
|
||||
if (!initialized) {
|
||||
throw new IllegalStateException("MAC not initialized");
|
||||
}
|
||||
spi.engineUpdate(input);
|
||||
@ -497,7 +497,7 @@ public class Mac implements Cloneable {
|
||||
*/
|
||||
public final void update(byte[] input) throws IllegalStateException {
|
||||
chooseFirstProvider();
|
||||
if (initialized == false) {
|
||||
if (!initialized) {
|
||||
throw new IllegalStateException("MAC not initialized");
|
||||
}
|
||||
if (input != null) {
|
||||
@ -519,7 +519,7 @@ public class Mac implements Cloneable {
|
||||
public final void update(byte[] input, int offset, int len)
|
||||
throws IllegalStateException {
|
||||
chooseFirstProvider();
|
||||
if (initialized == false) {
|
||||
if (!initialized) {
|
||||
throw new IllegalStateException("MAC not initialized");
|
||||
}
|
||||
|
||||
@ -544,7 +544,7 @@ public class Mac implements Cloneable {
|
||||
*/
|
||||
public final void update(ByteBuffer input) {
|
||||
chooseFirstProvider();
|
||||
if (initialized == false) {
|
||||
if (!initialized) {
|
||||
throw new IllegalStateException("MAC not initialized");
|
||||
}
|
||||
if (input == null) {
|
||||
@ -574,7 +574,7 @@ public class Mac implements Cloneable {
|
||||
*/
|
||||
public final byte[] doFinal() throws IllegalStateException {
|
||||
chooseFirstProvider();
|
||||
if (initialized == false) {
|
||||
if (!initialized) {
|
||||
throw new IllegalStateException("MAC not initialized");
|
||||
}
|
||||
byte[] mac = spi.engineDoFinal();
|
||||
@ -612,7 +612,7 @@ public class Mac implements Cloneable {
|
||||
throws ShortBufferException, IllegalStateException
|
||||
{
|
||||
chooseFirstProvider();
|
||||
if (initialized == false) {
|
||||
if (!initialized) {
|
||||
throw new IllegalStateException("MAC not initialized");
|
||||
}
|
||||
int macLen = getMacLength();
|
||||
@ -622,7 +622,6 @@ public class Mac implements Cloneable {
|
||||
}
|
||||
byte[] mac = doFinal();
|
||||
System.arraycopy(mac, 0, output, outOffset, macLen);
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -648,7 +647,7 @@ public class Mac implements Cloneable {
|
||||
public final byte[] doFinal(byte[] input) throws IllegalStateException
|
||||
{
|
||||
chooseFirstProvider();
|
||||
if (initialized == false) {
|
||||
if (!initialized) {
|
||||
throw new IllegalStateException("MAC not initialized");
|
||||
}
|
||||
update(input);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -104,7 +104,7 @@ public abstract class MacSpi {
|
||||
* @since 1.5
|
||||
*/
|
||||
protected void engineUpdate(ByteBuffer input) {
|
||||
if (input.hasRemaining() == false) {
|
||||
if (!input.hasRemaining()) {
|
||||
return;
|
||||
}
|
||||
if (input.hasArray()) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -58,8 +58,7 @@ final class NullCipherSpi extends CipherSpi {
|
||||
}
|
||||
|
||||
protected byte[] engineGetIV() {
|
||||
byte[] x = new byte[8];
|
||||
return x;
|
||||
return new byte[8];
|
||||
}
|
||||
|
||||
protected AlgorithmParameters engineGetParameters() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -46,9 +46,8 @@ import java.util.jar.*;
|
||||
final class ProviderVerifier {
|
||||
|
||||
// The URL for the JAR file we want to verify.
|
||||
private URL jarURL;
|
||||
private Provider provider;
|
||||
private boolean savePerms;
|
||||
private final URL jarURL;
|
||||
private final boolean savePerms;
|
||||
private CryptoPermissions appPerms = null;
|
||||
|
||||
/**
|
||||
@ -72,7 +71,6 @@ final class ProviderVerifier {
|
||||
*/
|
||||
ProviderVerifier(URL jarURL, Provider provider, boolean savePerms) {
|
||||
this.jarURL = jarURL;
|
||||
this.provider = provider;
|
||||
this.savePerms = savePerms;
|
||||
}
|
||||
|
||||
@ -94,7 +92,7 @@ final class ProviderVerifier {
|
||||
// construct a JAR URL so we can open a JarURLConnection
|
||||
// for verifying this provider.
|
||||
final URL url = jarURL.getProtocol().equalsIgnoreCase("jar")?
|
||||
jarURL : new URL("jar:" + jarURL.toString() + "!/");
|
||||
jarURL : new URL("jar:" + jarURL + "!/");
|
||||
|
||||
JarFile jf = null;
|
||||
try {
|
||||
@ -103,19 +101,17 @@ final class ProviderVerifier {
|
||||
try {
|
||||
@SuppressWarnings("removal")
|
||||
var tmp = AccessController.doPrivileged(
|
||||
new PrivilegedExceptionAction<JarFile>() {
|
||||
public JarFile run() throws Exception {
|
||||
JarURLConnection conn =
|
||||
(JarURLConnection) url.openConnection();
|
||||
// You could do some caching here as
|
||||
// an optimization.
|
||||
conn.setUseCaches(false);
|
||||
return conn.getJarFile();
|
||||
}
|
||||
});
|
||||
(PrivilegedExceptionAction<JarFile>) () -> {
|
||||
JarURLConnection conn =
|
||||
(JarURLConnection) url.openConnection();
|
||||
// You could do some caching here as
|
||||
// an optimization.
|
||||
conn.setUseCaches(false);
|
||||
return conn.getJarFile();
|
||||
});
|
||||
jf = tmp;
|
||||
} catch (java.security.PrivilegedActionException pae) {
|
||||
throw new SecurityException("Cannot load " + url.toString(),
|
||||
throw new SecurityException("Cannot load " + url,
|
||||
pae.getCause());
|
||||
}
|
||||
|
||||
@ -130,8 +126,7 @@ final class ProviderVerifier {
|
||||
appPerms.load(jf.getInputStream(je));
|
||||
} catch (Exception ex) {
|
||||
JarException jex =
|
||||
new JarException("Cannot load/parse" +
|
||||
jarURL.toString());
|
||||
new JarException("Cannot load/parse" + jarURL);
|
||||
jex.initCause(ex);
|
||||
throw jex;
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class SealedObject implements Serializable {
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private String sealAlg = null;
|
||||
private final String sealAlg;
|
||||
|
||||
/**
|
||||
* The algorithm of the parameters used.
|
||||
@ -135,7 +135,7 @@ public class SealedObject implements Serializable {
|
||||
* encrypted using the given Cipher, which must be fully initialized.
|
||||
*
|
||||
* <p>Any algorithm parameters that may be used in the encryption
|
||||
* operation are stored inside of the new <code>SealedObject</code>.
|
||||
* operation are stored inside the new <code>SealedObject</code>.
|
||||
*
|
||||
* @param object the object to be sealed; can be null.
|
||||
* @param c the cipher used to seal the object.
|
||||
@ -235,9 +235,9 @@ public class SealedObject implements Serializable {
|
||||
*
|
||||
* @return the original object.
|
||||
*
|
||||
* @exception IOException if an error occurs during de-serialiazation.
|
||||
* @exception IOException if an error occurs during de-serialization.
|
||||
* @exception ClassNotFoundException if an error occurs during
|
||||
* de-serialiazation.
|
||||
* de-serialization.
|
||||
* @exception NoSuchAlgorithmException if the algorithm to unseal the
|
||||
* object is not available.
|
||||
* @exception InvalidKeyException if the given key cannot be used to unseal
|
||||
@ -276,9 +276,9 @@ public class SealedObject implements Serializable {
|
||||
* @return the original object.
|
||||
*
|
||||
* @exception NullPointerException if the given cipher is null.
|
||||
* @exception IOException if an error occurs during de-serialiazation
|
||||
* @exception IOException if an error occurs during de-serialization
|
||||
* @exception ClassNotFoundException if an error occurs during
|
||||
* de-serialiazation
|
||||
* de-serialization
|
||||
* @exception IllegalBlockSizeException if the given cipher is a block
|
||||
* cipher, no padding has been requested, and the total input length is
|
||||
* not a multiple of the cipher's block size
|
||||
@ -291,8 +291,7 @@ public class SealedObject implements Serializable {
|
||||
BadPaddingException
|
||||
{
|
||||
try (ObjectInput a = getExtObjectInputStream(c)) {
|
||||
Object obj = a.readObject();
|
||||
return obj;
|
||||
return a.readObject();
|
||||
}
|
||||
}
|
||||
|
||||
@ -317,9 +316,9 @@ public class SealedObject implements Serializable {
|
||||
*
|
||||
* @exception IllegalArgumentException if the given provider is null
|
||||
* or empty.
|
||||
* @exception IOException if an error occurs during de-serialiazation.
|
||||
* @exception IOException if an error occurs during de-serialization.
|
||||
* @exception ClassNotFoundException if an error occurs during
|
||||
* de-serialiazation.
|
||||
* de-serialization.
|
||||
* @exception NoSuchAlgorithmException if the algorithm to unseal the
|
||||
* object is not available.
|
||||
* @exception NoSuchProviderException if the given provider is not
|
||||
@ -408,8 +407,7 @@ public class SealedObject implements Serializable {
|
||||
}
|
||||
|
||||
try (ObjectInput a = getExtObjectInputStream(c)) {
|
||||
Object obj = a.readObject();
|
||||
return obj;
|
||||
return a.readObject();
|
||||
}
|
||||
}
|
||||
|
||||
@ -442,7 +440,7 @@ public class SealedObject implements Serializable {
|
||||
}
|
||||
|
||||
static {
|
||||
SharedSecrets.setJavaxCryptoSealedObjectAccess((obj,c) -> obj.getExtObjectInputStream(c));
|
||||
SharedSecrets.setJavaxCryptoSealedObjectAccess(SealedObject::getExtObjectInputStream);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -69,5 +69,5 @@ public interface SecretKey extends
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("serial")
|
||||
static final long serialVersionUID = -4795878709595146952L;
|
||||
long serialVersionUID = -4795878709595146952L;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -43,7 +43,7 @@ import sun.security.jca.GetInstance.Instance;
|
||||
* versa.
|
||||
* Secret key factories operate only on secret (symmetric) keys.
|
||||
*
|
||||
* <P> Key factories are bi-directional, i.e., they allow to build an opaque
|
||||
* <P> Key factories are bidirectional, i.e., they allow to build an opaque
|
||||
* key object from a given key specification (key material), or to retrieve
|
||||
* the underlying key material of a key object in a suitable format.
|
||||
*
|
||||
@ -138,7 +138,7 @@ public class SecretKeyFactory {
|
||||
* {@code jdk.security.provider.preferred}
|
||||
* {@link Security#getProperty(String) Security} property to determine
|
||||
* the preferred provider order for the specified algorithm. This
|
||||
* may be different than the order of providers returned by
|
||||
* may be different from the order of providers returned by
|
||||
* {@link Security#getProviders() Security.getProviders()}.
|
||||
*
|
||||
* @param algorithm the standard name of the requested secret-key
|
||||
@ -280,7 +280,7 @@ public class SecretKeyFactory {
|
||||
|
||||
/**
|
||||
* Update the active spi of this class and return the next
|
||||
* implementation for failover. If no more implemenations are
|
||||
* implementation for failover. If no more implementations are
|
||||
* available, this method returns null. However, the active spi of
|
||||
* this class is never set to null.
|
||||
*/
|
||||
@ -296,15 +296,14 @@ public class SecretKeyFactory {
|
||||
}
|
||||
while (serviceIterator.hasNext()) {
|
||||
Service s = serviceIterator.next();
|
||||
if (JceSecurity.canUseProvider(s.getProvider()) == false) {
|
||||
if (!JceSecurity.canUseProvider(s.getProvider())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
Object obj = s.newInstance(null);
|
||||
if (obj instanceof SecretKeyFactorySpi == false) {
|
||||
if (!(obj instanceof SecretKeyFactorySpi spi)) {
|
||||
continue;
|
||||
}
|
||||
SecretKeyFactorySpi spi = (SecretKeyFactorySpi)obj;
|
||||
provider = s.getProvider();
|
||||
this.spi = spi;
|
||||
return spi;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -48,7 +48,7 @@ public interface DHPrivateKey extends DHKey, java.security.PrivateKey {
|
||||
@Deprecated
|
||||
@SuppressWarnings("serial")
|
||||
@java.io.Serial
|
||||
static final long serialVersionUID = 2211791113380396553L;
|
||||
long serialVersionUID = 2211791113380396553L;
|
||||
|
||||
/**
|
||||
* Returns the private value, <code>x</code>.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -48,7 +48,7 @@ public interface DHPublicKey extends DHKey, java.security.PublicKey {
|
||||
@Deprecated
|
||||
@SuppressWarnings("serial")
|
||||
@java.io.Serial
|
||||
static final long serialVersionUID = -6628103563352519193L;
|
||||
long serialVersionUID = -6628103563352519193L;
|
||||
|
||||
/**
|
||||
* Returns the public value, <code>y</code>.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,8 +25,6 @@
|
||||
|
||||
package javax.crypto.interfaces;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* The interface to a PBE key.
|
||||
*
|
||||
@ -48,7 +46,7 @@ public interface PBEKey extends javax.crypto.SecretKey {
|
||||
@Deprecated
|
||||
@SuppressWarnings("serial")
|
||||
@java.io.Serial
|
||||
static final long serialVersionUID = -1430015993304333921L;
|
||||
long serialVersionUID = -1430015993304333921L;
|
||||
|
||||
/**
|
||||
* Returns the password.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -37,7 +37,7 @@
|
||||
* The class itself defines a programming interface to which
|
||||
* applications may write. The implementations themselves may then be
|
||||
* written by independent third-party vendors and plugged in
|
||||
* seamlessly as needed. Therefore application developers may take
|
||||
* seamlessly as needed. Therefore, application developers may take
|
||||
* advantage of any number of provider-based implementations without
|
||||
* having to add or rewrite code.
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -41,7 +41,7 @@ public class DESKeySpec implements java.security.spec.KeySpec {
|
||||
*/
|
||||
public static final int DES_KEY_LEN = 8;
|
||||
|
||||
private byte[] key;
|
||||
private final byte[] key;
|
||||
|
||||
/*
|
||||
* Weak/semi-weak keys copied from FIPS 74.
|
||||
@ -226,13 +226,14 @@ public class DESKeySpec implements java.security.spec.KeySpec {
|
||||
}
|
||||
for (int i = 0; i < WEAK_KEYS.length; i++) {
|
||||
boolean found = true;
|
||||
for (int j = 0; j < DES_KEY_LEN && found == true; j++) {
|
||||
if (WEAK_KEYS[i][j] != key[j+offset]) {
|
||||
for (int j = 0; j < DES_KEY_LEN; j++) {
|
||||
if (WEAK_KEYS[i][j] != key[j + offset]) {
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == true) {
|
||||
return found;
|
||||
if (found) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -41,7 +41,7 @@ public class DESedeKeySpec implements java.security.spec.KeySpec {
|
||||
*/
|
||||
public static final int DES_EDE_KEY_LEN = 24;
|
||||
|
||||
private byte[] key;
|
||||
private final byte[] key;
|
||||
|
||||
/**
|
||||
* Creates a DESedeKeySpec object using the first 24 bytes in
|
||||
@ -116,11 +116,8 @@ public class DESedeKeySpec implements java.security.spec.KeySpec {
|
||||
if (key.length - offset < 24) {
|
||||
throw new InvalidKeyException("Wrong key size");
|
||||
}
|
||||
if (DESKeySpec.isParityAdjusted(key, offset) == false
|
||||
|| DESKeySpec.isParityAdjusted(key, offset + 8) == false
|
||||
|| DESKeySpec.isParityAdjusted(key, offset + 16) == false) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return DESKeySpec.isParityAdjusted(key, offset)
|
||||
&& DESKeySpec.isParityAdjusted(key, offset + 8)
|
||||
&& DESKeySpec.isParityAdjusted(key, offset + 16);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,6 @@
|
||||
|
||||
package javax.crypto.spec;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
/**
|
||||
@ -45,10 +44,10 @@ import java.security.spec.AlgorithmParameterSpec;
|
||||
public class DHGenParameterSpec implements AlgorithmParameterSpec {
|
||||
|
||||
// The size in bits of the prime modulus
|
||||
private int primeSize;
|
||||
private final int primeSize;
|
||||
|
||||
// The size in bits of the random exponent (private value)
|
||||
private int exponentSize;
|
||||
private final int exponentSize;
|
||||
|
||||
/**
|
||||
* Constructs a parameter set for the generation of Diffie-Hellman
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -55,13 +55,13 @@ import java.security.spec.AlgorithmParameterSpec;
|
||||
public class DHParameterSpec implements AlgorithmParameterSpec {
|
||||
|
||||
// The prime modulus
|
||||
private BigInteger p;
|
||||
private final BigInteger p;
|
||||
|
||||
// The base generator
|
||||
private BigInteger g;
|
||||
private final BigInteger g;
|
||||
|
||||
// The size in bits of the random exponent (private value) (optional)
|
||||
private int l;
|
||||
private final int l;
|
||||
|
||||
/**
|
||||
* Constructs a parameter set for Diffie-Hellman, using a prime modulus
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -43,13 +43,13 @@ import java.math.BigInteger;
|
||||
public class DHPrivateKeySpec implements java.security.spec.KeySpec {
|
||||
|
||||
// The private value
|
||||
private BigInteger x;
|
||||
private final BigInteger x;
|
||||
|
||||
// The prime modulus
|
||||
private BigInteger p;
|
||||
private final BigInteger p;
|
||||
|
||||
// The base generator
|
||||
private BigInteger g;
|
||||
private final BigInteger g;
|
||||
|
||||
/**
|
||||
* Constructor that takes a private value <code>x</code>, a prime
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -43,13 +43,13 @@ import java.math.BigInteger;
|
||||
public class DHPublicKeySpec implements java.security.spec.KeySpec {
|
||||
|
||||
// The public value
|
||||
private BigInteger y;
|
||||
private final BigInteger y;
|
||||
|
||||
// The prime modulus
|
||||
private BigInteger p;
|
||||
private final BigInteger p;
|
||||
|
||||
// The base generator
|
||||
private BigInteger g;
|
||||
private final BigInteger g;
|
||||
|
||||
/**
|
||||
* Constructor that takes a public value <code>y</code>, a prime
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -39,7 +39,7 @@ import java.security.spec.AlgorithmParameterSpec;
|
||||
*/
|
||||
public class IvParameterSpec implements AlgorithmParameterSpec {
|
||||
|
||||
private byte[] iv;
|
||||
private final byte[] iv;
|
||||
|
||||
/**
|
||||
* Creates an IvParameterSpec object using the bytes in <code>iv</code>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,6 @@
|
||||
|
||||
package javax.crypto.spec;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import java.security.spec.MGF1ParameterSpec;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -39,8 +39,8 @@ import java.security.spec.AlgorithmParameterSpec;
|
||||
*/
|
||||
public class PBEParameterSpec implements AlgorithmParameterSpec {
|
||||
|
||||
private byte[] salt;
|
||||
private int iterationCount;
|
||||
private final byte[] salt;
|
||||
private final int iterationCount;
|
||||
private AlgorithmParameterSpec paramSpec = null;
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -48,7 +48,7 @@ package javax.crypto.spec;
|
||||
*/
|
||||
public class PSource {
|
||||
|
||||
private String pSrcName;
|
||||
private final String pSrcName;
|
||||
|
||||
/**
|
||||
* Constructs a source of the encoding input P for OAEP
|
||||
@ -82,7 +82,7 @@ public class PSource {
|
||||
*/
|
||||
public static final class PSpecified extends PSource {
|
||||
|
||||
private byte[] p = new byte[0];
|
||||
private final byte[] p;
|
||||
|
||||
/**
|
||||
* The encoding input P whose value equals byte[0].
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -45,7 +45,7 @@ import java.security.spec.AlgorithmParameterSpec;
|
||||
public class RC2ParameterSpec implements AlgorithmParameterSpec {
|
||||
|
||||
private byte[] iv = null;
|
||||
private int effectiveKeyBits;
|
||||
private final int effectiveKeyBits;
|
||||
|
||||
/**
|
||||
* Constructs a parameter set for RC2 from the given effective key size
|
||||
@ -135,10 +135,9 @@ public class RC2ParameterSpec implements AlgorithmParameterSpec {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof RC2ParameterSpec)) {
|
||||
if (!(obj instanceof RC2ParameterSpec other)) {
|
||||
return false;
|
||||
}
|
||||
RC2ParameterSpec other = (RC2ParameterSpec) obj;
|
||||
|
||||
return ((effectiveKeyBits == other.effectiveKeyBits) &&
|
||||
java.util.Arrays.equals(iv, other.iv));
|
||||
@ -155,6 +154,6 @@ public class RC2ParameterSpec implements AlgorithmParameterSpec {
|
||||
retval += iv[i] * i;
|
||||
}
|
||||
}
|
||||
return (retval += effectiveKeyBits);
|
||||
return retval + effectiveKeyBits;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -47,9 +47,9 @@ import java.security.spec.AlgorithmParameterSpec;
|
||||
public class RC5ParameterSpec implements AlgorithmParameterSpec {
|
||||
|
||||
private byte[] iv = null;
|
||||
private int version;
|
||||
private int rounds;
|
||||
private int wordSize; // the word size in bits
|
||||
private final int version;
|
||||
private final int rounds;
|
||||
private final int wordSize; // the word size in bits
|
||||
|
||||
/**
|
||||
* Constructs a parameter set for RC5 from the given version, number of
|
||||
@ -180,10 +180,9 @@ public class RC5ParameterSpec implements AlgorithmParameterSpec {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof RC5ParameterSpec)) {
|
||||
if (!(obj instanceof RC5ParameterSpec other)) {
|
||||
return false;
|
||||
}
|
||||
RC5ParameterSpec other = (RC5ParameterSpec) obj;
|
||||
|
||||
return ((version == other.version) &&
|
||||
(rounds == other.rounds) &&
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,14 +25,13 @@
|
||||
|
||||
package javax.crypto.spec;
|
||||
|
||||
import jdk.internal.access.JavaxCryptoSpecAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
|
||||
import javax.crypto.SecretKey;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.spec.KeySpec;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import javax.crypto.SecretKey;
|
||||
|
||||
/**
|
||||
* This class specifies a secret key in a provider-independent fashion.
|
||||
@ -61,23 +60,18 @@ public class SecretKeySpec implements KeySpec, SecretKey {
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private byte[] key;
|
||||
private final byte[] key;
|
||||
|
||||
/**
|
||||
* The name of the algorithm associated with this key.
|
||||
*
|
||||
* @serial
|
||||
*/
|
||||
private String algorithm;
|
||||
private final String algorithm;
|
||||
|
||||
static {
|
||||
SharedSecrets.setJavaxCryptoSpecAccess(
|
||||
new JavaxCryptoSpecAccess() {
|
||||
@Override
|
||||
public void clearSecretKeySpec(SecretKeySpec keySpec) {
|
||||
keySpec.clear();
|
||||
}
|
||||
});
|
||||
SecretKeySpec::clear);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -210,10 +204,9 @@ public class SecretKeySpec implements KeySpec, SecretKey {
|
||||
retval += this.key[i] * i;
|
||||
}
|
||||
if (this.algorithm.equalsIgnoreCase("TripleDES"))
|
||||
return (retval ^= "desede".hashCode());
|
||||
return retval ^ "desede".hashCode();
|
||||
else
|
||||
return (retval ^=
|
||||
this.algorithm.toLowerCase(Locale.ENGLISH).hashCode());
|
||||
return retval ^ this.algorithm.toLowerCase(Locale.ENGLISH).hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user