8185934: keytool shows "Signature algorithm: SHA1withECDSA, -1-bit key"

Reviewed-by: mullan
This commit is contained in:
Weijun Wang 2017-08-08 21:37:38 +08:00
parent 36378834a9
commit 43ead07d44
4 changed files with 16 additions and 4 deletions

View File

@ -3071,8 +3071,14 @@ public final class Main {
private String withWeak(PublicKey key) {
if (DISABLED_CHECK.permits(SIG_PRIMITIVE_SET, key)) {
return String.format(rb.getString("key.bit"),
KeyUtil.getKeySize(key), key.getAlgorithm());
int kLen = KeyUtil.getKeySize(key);
if (kLen >= 0) {
return String.format(rb.getString("key.bit"),
kLen, key.getAlgorithm());
} else {
return String.format(
rb.getString("unknown.size.1"), key.getAlgorithm());
}
} else {
return String.format(rb.getString("key.bit.weak"),
KeyUtil.getKeySize(key), key.getAlgorithm());

View File

@ -462,6 +462,7 @@ public class Resources extends java.util.ListResourceBundle {
{"with.weak", "%s (weak)"},
{"key.bit", "%d-bit %s key"},
{"key.bit.weak", "%d-bit %s key (weak)"},
{"unknown.size.1", "unknown size %s key"},
{".PATTERN.printX509Cert.with.weak",
"Owner: {0}\nIssuer: {1}\nSerial number: {2}\nValid from: {3} until: {4}\nCertificate fingerprints:\n\t SHA1: {5}\n\t SHA256: {6}\nSignature algorithm name: {7}\nSubject Public Key Algorithm: {8}\nVersion: {9}"},
{"PKCS.10.with.weak",

View File

@ -1088,8 +1088,12 @@ public class Main {
private String withWeak(PublicKey key) {
if (DISABLED_CHECK.permits(SIG_PRIMITIVE_SET, key)) {
return String.format(
rb.getString("key.bit"), KeyUtil.getKeySize(key));
int kLen = KeyUtil.getKeySize(key);
if (kLen >= 0) {
return String.format(rb.getString("key.bit"), kLen);
} else {
return rb.getString("unknown.size");
}
} else {
seeWeak = true;
return String.format(

View File

@ -164,6 +164,7 @@ public class Resources extends java.util.ListResourceBundle {
{"with.weak", "%s (weak)"},
{"key.bit", "%d-bit key"},
{"key.bit.weak", "%d-bit key (weak)"},
{"unknown.size", "unknown size"},
{"jarsigner.", "jarsigner: "},
{"signature.filename.must.consist.of.the.following.characters.A.Z.0.9.or.",