8315974: Make fields final in 'com.sun.crypto.provider' package

Reviewed-by: valeriep
This commit is contained in:
Andrey Turbanov 2023-10-18 08:28:23 +00:00
parent 8dd809642e
commit 4e77b3c378
31 changed files with 91 additions and 106 deletions

View file

@ -53,7 +53,7 @@ final class DHPrivateKey implements PrivateKey,
private static final BigInteger PKCS8_VERSION = BigInteger.ZERO;
// the private key
private BigInteger x;
private final BigInteger x;
// the key bytes, without the algorithm information
private byte[] key;
@ -68,7 +68,7 @@ final class DHPrivateKey implements PrivateKey,
private final BigInteger g;
// the private-value length (optional)
private int l;
private final int l;
/**
* Make a DH private key out of a private value <code>x</code>, a prime
@ -161,6 +161,8 @@ final class DHPrivateKey implements PrivateKey,
// Private-value length is OPTIONAL
if (params.data.available() != 0) {
this.l = params.data.getInteger();
} else {
this.l = 0;
}
if (params.data.available() != 0) {
throw new InvalidKeyException("Extra parameter data");
@ -170,7 +172,9 @@ final class DHPrivateKey implements PrivateKey,
// privateKey
//
this.key = val.data.getOctetString();
parseKeyBits();
DerInputStream in = new DerInputStream(this.key);
this.x = in.getBigInteger();
this.encodedKey = encodedKey.clone();
} catch (IOException | NumberFormatException e) {
@ -271,16 +275,6 @@ final class DHPrivateKey implements PrivateKey,
}
}
private void parseKeyBits() throws InvalidKeyException {
try {
DerInputStream in = new DerInputStream(this.key);
this.x = in.getBigInteger();
} catch (IOException e) {
throw new InvalidKeyException(
"Error parsing key encoding: " + e.getMessage(), e);
}
}
/**
* Calculates a hash code value for the object.
* Objects that are equal will also have the same hashcode.