mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8285263: Minor cleanup could be done in java.security
Reviewed-by: weijun
This commit is contained in:
parent
b97a4f6cdc
commit
17695962ac
94 changed files with 480 additions and 601 deletions
|
@ -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
|
||||
|
@ -44,10 +44,10 @@ import java.math.BigInteger;
|
|||
|
||||
public class DSAPrivateKeySpec implements KeySpec {
|
||||
|
||||
private BigInteger x;
|
||||
private BigInteger p;
|
||||
private BigInteger q;
|
||||
private BigInteger g;
|
||||
private final BigInteger x;
|
||||
private final BigInteger p;
|
||||
private final BigInteger q;
|
||||
private final BigInteger g;
|
||||
|
||||
/**
|
||||
* Creates a new DSAPrivateKeySpec with the specified parameter values.
|
||||
|
|
|
@ -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
|
||||
|
@ -44,10 +44,10 @@ import java.math.BigInteger;
|
|||
|
||||
public class DSAPublicKeySpec implements KeySpec {
|
||||
|
||||
private BigInteger y;
|
||||
private BigInteger p;
|
||||
private BigInteger q;
|
||||
private BigInteger g;
|
||||
private final BigInteger y;
|
||||
private final BigInteger p;
|
||||
private final BigInteger q;
|
||||
private final BigInteger g;
|
||||
|
||||
/**
|
||||
* Creates a new DSAPublicKeySpec with the specified parameter values.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 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
|
||||
|
@ -24,9 +24,6 @@
|
|||
*/
|
||||
package java.security.spec;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This interface represents an elliptic curve (EC) finite field.
|
||||
* All specialized EC fields must implements this interface.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2019, 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
|
||||
|
@ -39,8 +39,8 @@ import java.util.Arrays;
|
|||
*/
|
||||
public class ECFieldF2m implements ECField {
|
||||
|
||||
private int m;
|
||||
private int[] ks;
|
||||
private final int m;
|
||||
private final int[] ks;
|
||||
private BigInteger rp;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2019, 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 java.security.spec;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This immutable class defines an elliptic curve (EC) prime
|
||||
|
@ -39,7 +38,7 @@ import java.util.Arrays;
|
|||
*/
|
||||
public class ECFieldFp implements ECField {
|
||||
|
||||
private BigInteger p;
|
||||
private final BigInteger p;
|
||||
|
||||
/**
|
||||
* Creates an elliptic curve prime finite field
|
||||
|
@ -63,7 +62,7 @@ public class ECFieldFp implements ECField {
|
|||
*/
|
||||
public int getFieldSize() {
|
||||
return p.bitLength();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the prime {@code p} of this prime finite field.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2019, 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
|
||||
|
@ -39,8 +39,8 @@ import java.math.BigInteger;
|
|||
*/
|
||||
public class ECPrivateKeySpec implements KeySpec {
|
||||
|
||||
private BigInteger s;
|
||||
private ECParameterSpec params;
|
||||
private final BigInteger s;
|
||||
private final ECParameterSpec params;
|
||||
|
||||
/**
|
||||
* Creates a new ECPrivateKeySpec with the specified
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2019, 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
|
||||
|
@ -38,8 +38,8 @@ package java.security.spec;
|
|||
*/
|
||||
public class ECPublicKeySpec implements KeySpec {
|
||||
|
||||
private ECPoint w;
|
||||
private ECParameterSpec params;
|
||||
private final ECPoint w;
|
||||
private final ECParameterSpec params;
|
||||
|
||||
/**
|
||||
* Creates a new ECPublicKeySpec with the specified
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 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
|
||||
|
@ -53,7 +53,7 @@ public class EdDSAParameterSpec implements AlgorithmParameterSpec {
|
|||
* Construct an {@code EdDSAParameterSpec} by specifying whether the prehash mode
|
||||
* is used. No context is provided so this constructor specifies a mode
|
||||
* in which the context is null. Note that this mode may be different
|
||||
* than the mode in which an empty array is used as the context.
|
||||
* from the mode in which an empty array is used as the context.
|
||||
*
|
||||
* @param prehash whether the prehash mode is specified.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2019, 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
|
||||
|
@ -26,7 +26,6 @@
|
|||
package java.security.spec;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This immutable class holds the necessary values needed to represent
|
||||
|
|
|
@ -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
|
||||
|
@ -25,7 +25,6 @@
|
|||
|
||||
package java.security.spec;
|
||||
|
||||
import jdk.internal.access.JavaSecuritySpecAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -47,20 +46,15 @@ import java.util.Arrays;
|
|||
|
||||
public abstract class EncodedKeySpec implements KeySpec {
|
||||
|
||||
private byte[] encodedKey;
|
||||
private final byte[] encodedKey;
|
||||
private String algorithmName;
|
||||
|
||||
static {
|
||||
SharedSecrets.setJavaSecuritySpecAccess(
|
||||
new JavaSecuritySpecAccess() {
|
||||
@Override
|
||||
public void clearEncodedKeySpec(EncodedKeySpec keySpec) {
|
||||
keySpec.clear();
|
||||
}
|
||||
});
|
||||
EncodedKeySpec::clear);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Creates a new {@code EncodedKeySpec} with the given encoded key.
|
||||
*
|
||||
* @param encodedKey the encoded key. The contents of the
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 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
|
||||
|
@ -68,7 +68,7 @@ public class NamedParameterSpec implements AlgorithmParameterSpec {
|
|||
public static final NamedParameterSpec ED448
|
||||
= new NamedParameterSpec("Ed448");
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Creates a parameter specification using a standard (or predefined)
|
||||
|
|
|
@ -225,12 +225,10 @@ public class PSSParameterSpec implements AlgorithmParameterSpec {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("PSSParameterSpec[");
|
||||
sb.append("hashAlgorithm=" + mdName + ", ")
|
||||
.append("maskGenAlgorithm=" + mgfSpec + ", ")
|
||||
.append("saltLength=" + saltLen + ", ")
|
||||
.append("trailerField=" + trailerField)
|
||||
.append(']');
|
||||
return sb.toString();
|
||||
return "PSSParameterSpec[" + "hashAlgorithm=" + mdName + ", " +
|
||||
"maskGenAlgorithm=" + mgfSpec + ", " +
|
||||
"saltLength=" + saltLen + ", " +
|
||||
"trailerField=" + trailerField +
|
||||
']';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2018, 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
|
||||
|
@ -26,7 +26,6 @@
|
|||
package java.security.spec;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
|
||||
/**
|
||||
* This class specifies the set of parameters used to generate an RSA
|
||||
|
@ -41,9 +40,9 @@ import java.security.spec.AlgorithmParameterSpec;
|
|||
|
||||
public class RSAKeyGenParameterSpec implements AlgorithmParameterSpec {
|
||||
|
||||
private int keysize;
|
||||
private BigInteger publicExponent;
|
||||
private AlgorithmParameterSpec keyParams;
|
||||
private final int keysize;
|
||||
private final BigInteger publicExponent;
|
||||
private final AlgorithmParameterSpec keyParams;
|
||||
|
||||
/**
|
||||
* The public-exponent value F0 = 3.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001, 2020, 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
|
||||
|
@ -78,7 +78,7 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec {
|
|||
* specified if there are only two prime factors
|
||||
* (p and q)
|
||||
* @throws NullPointerException if any of the specified parameters
|
||||
* with the exception of {@code otherPrimeInfo} is null
|
||||
* except {@code otherPrimeInfo} is null
|
||||
* @throws IllegalArgumentException if an empty, i.e. 0-length,
|
||||
* {@code otherPrimeInfo} is specified
|
||||
*/
|
||||
|
@ -118,7 +118,7 @@ public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec {
|
|||
* (p and q)
|
||||
* @param keyParams the parameters associated with key
|
||||
* @throws NullPointerException if any of the specified parameters
|
||||
* with the exception of {@code otherPrimeInfo} and {@code keyParams}
|
||||
* except {@code otherPrimeInfo} and {@code keyParams}
|
||||
* is null
|
||||
* @throws IllegalArgumentException if an empty, i.e. 0-length,
|
||||
* {@code otherPrimeInfo} is specified
|
||||
|
|
|
@ -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
|
||||
|
@ -53,9 +53,9 @@ import java.math.BigInteger;
|
|||
|
||||
public class RSAOtherPrimeInfo {
|
||||
|
||||
private BigInteger prime;
|
||||
private BigInteger primeExponent;
|
||||
private BigInteger crtCoefficient;
|
||||
private final BigInteger prime;
|
||||
private final BigInteger primeExponent;
|
||||
private final BigInteger crtCoefficient;
|
||||
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue