Skip to content

Commit 15ce8c6

Browse files
author
Valerie Peng
committedApr 20, 2022
8284553: Deprecate the DEFAULT static field of OAEPParameterSpec
Reviewed-by: mullan
1 parent e8016f7 commit 15ce8c6

File tree

2 files changed

+35
-38
lines changed

2 files changed

+35
-38
lines changed
 

‎src/java.base/share/classes/java/security/spec/PSSParameterSpec.java

-6
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,6 @@ public class PSSParameterSpec implements AlgorithmParameterSpec {
112112
("SHA-1", "MGF1", MGF1ParameterSpec.SHA1, 20, TRAILER_FIELD_BC);
113113

114114

115-
// disallowed
116-
private PSSParameterSpec() {
117-
throw new RuntimeException("default constructor not allowed");
118-
}
119-
120-
121115
/**
122116
* Creates a new {@code PSSParameterSpec} as defined in
123117
* the PKCS #1 standard using the specified message digest,

‎src/java.base/share/classes/javax/crypto/spec/OAEPParameterSpec.java

+35-32
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,6 @@
7171
* }
7272
* EncodingParameters ::= OCTET STRING(SIZE(0..MAX))
7373
* </pre>
74-
* <p>Note: the OAEPParameterSpec.DEFAULT uses the following:
75-
* <pre>
76-
* message digest -- "SHA-1"
77-
* mask generation function (mgf) -- "MGF1"
78-
* parameters for mgf -- MGF1ParameterSpec.SHA1
79-
* source of encoding input -- PSource.PSpecified.DEFAULT
80-
* </pre>
8174
*
8275
* @see java.security.spec.MGF1ParameterSpec
8376
* @see PSource
@@ -88,39 +81,49 @@
8881
*/
8982
public class OAEPParameterSpec implements AlgorithmParameterSpec {
9083

91-
private String mdName = "SHA-1";
92-
private String mgfName = "MGF1";
93-
private AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1;
94-
private PSource pSrc = PSource.PSpecified.DEFAULT;
95-
96-
/**
97-
* The OAEP parameter set with all default values.
98-
*/
99-
public static final OAEPParameterSpec DEFAULT = new OAEPParameterSpec();
84+
private final String mdName;
85+
private final String mgfName;
86+
private final AlgorithmParameterSpec mgfSpec;
87+
private final PSource pSrc;
10088

10189
/**
102-
* Constructs a parameter set for OAEP padding as defined in
103-
* the PKCS #1 standard using the default values.
90+
* The OAEP parameter set with all default values, i.e. "SHA-1" as message
91+
* digest algorithm, "MGF1" as mask generation function (mgf) algorithm,
92+
* {@code MGF1ParameterSpec.SHA1} as parameters for the mask generation
93+
* function, and {@code PSource.PSpecified.DEFAULT} as the source of the
94+
* encoding input.
95+
*
96+
* @deprecated This field uses the default values defined in the PKCS #1
97+
* standard. Some of these defaults are no longer recommended due
98+
* to advances in cryptanalysis -- see
99+
* <a href="https://www.rfc-editor.org/rfc/rfc8017#appendix-B.1">Appendix B.1 of PKCS #1</a>
100+
* for more details. Thus, it is recommended to create
101+
* a new {@code OAEPParameterSpec} with the desired parameter values
102+
* using the
103+
* {@link #OAEPParameterSpec(String, String, AlgorithmParameterSpec, PSource)} constructor.
104+
*
104105
*/
105-
private OAEPParameterSpec() {
106-
}
106+
@Deprecated(since="19")
107+
public static final OAEPParameterSpec DEFAULT = new OAEPParameterSpec(
108+
"SHA-1", "MGF1", MGF1ParameterSpec.SHA1,
109+
PSource.PSpecified.DEFAULT);
107110

108111
/**
109112
* Constructs a parameter set for OAEP padding as defined in
110113
* the PKCS #1 standard using the specified message digest
111-
* algorithm <code>mdName</code>, mask generation function
112-
* algorithm <code>mgfName</code>, parameters for the mask
113-
* generation function <code>mgfSpec</code>, and source of
114-
* the encoding input P <code>pSrc</code>.
114+
* algorithm {@code mdName}, mask generation function
115+
* algorithm {@code mgfName}, parameters for the mask
116+
* generation function {@code mgfSpec}, and source of
117+
* the encoding input P {@code pSrc}.
115118
*
116-
* @param mdName the algorithm name for the message digest.
117-
* @param mgfName the algorithm name for the mask generation
118-
* function.
119-
* @param mgfSpec the parameters for the mask generation function.
120-
* If null is specified, null will be returned by getMGFParameters().
121-
* @param pSrc the source of the encoding input P.
122-
* @exception NullPointerException if <code>mdName</code>,
123-
* <code>mgfName</code>, or <code>pSrc</code> is null.
119+
* @param mdName the algorithm name for the message digest
120+
* @param mgfName the algorithm name for the mask generation function
121+
* @param mgfSpec the parameters for the mask generation function;
122+
* if {@code null} is specified, {@code null} will be returned by
123+
* {@link #getMGFParameters()}
124+
* @param pSrc the source of the encoding input P
125+
* @throws NullPointerException if {@code mdName},
126+
* {@code mgfName}, or {@code pSrc} is {@code null}
124127
*/
125128
public OAEPParameterSpec(String mdName, String mgfName,
126129
AlgorithmParameterSpec mgfSpec,

0 commit comments

Comments
 (0)
Please sign in to comment.