8256363: Define toString() for MGF1ParameterSpec

Reviewed-by: mullan
This commit is contained in:
Weijun Wang 2020-11-18 13:14:11 +00:00
parent eab170c0af
commit 486d6f631b
3 changed files with 15 additions and 11 deletions

View File

@ -25,8 +25,6 @@
package java.security.spec;
import java.security.spec.AlgorithmParameterSpec;
/**
* This class specifies the set of parameters used with mask generation
* function MGF1 in OAEP Padding and RSASSA-PSS signature scheme, as
@ -162,4 +160,9 @@ public class MGF1ParameterSpec implements AlgorithmParameterSpec {
public String getDigestAlgorithm() {
return mdName;
}
@Override
public String toString() {
return "MGF1ParameterSpec[hashAlgorithm=" + mdName + "]";
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2020, 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
@ -220,11 +220,12 @@ public class PSSParameterSpec implements AlgorithmParameterSpec {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("MD: " + mdName + "\n")
.append("MGF: " + mgfSpec + "\n")
.append("SaltLength: " + saltLen + "\n")
.append("TrailerField: " + trailerField + "\n");
StringBuilder sb = new StringBuilder("PSSParameterSpec[");
sb.append("hashAlgorithm=" + mdName + ", ")
.append("maskGenAlgorithm=" + mgfSpec + ", ")
.append("saltLength=" + saltLen + ", ")
.append("trailerField=" + trailerField)
.append(']');
return sb.toString();
}
}

View File

@ -510,15 +510,15 @@ public class SignatureUtil {
private static class PSSParamsHolder {
final static PSSParameterSpec PSS_256_SPEC = new PSSParameterSpec(
"SHA-256", "MGF1",
new MGF1ParameterSpec("SHA-256"),
MGF1ParameterSpec.SHA256,
32, PSSParameterSpec.TRAILER_FIELD_BC);
final static PSSParameterSpec PSS_384_SPEC = new PSSParameterSpec(
"SHA-384", "MGF1",
new MGF1ParameterSpec("SHA-384"),
MGF1ParameterSpec.SHA384,
48, PSSParameterSpec.TRAILER_FIELD_BC);
final static PSSParameterSpec PSS_512_SPEC = new PSSParameterSpec(
"SHA-512", "MGF1",
new MGF1ParameterSpec("SHA-512"),
MGF1ParameterSpec.SHA512,
64, PSSParameterSpec.TRAILER_FIELD_BC);
}