# HG changeset patch # User weijun # Date 1502199458 -28800 # Node ID 5196af7549571a80d6aed2f8f590b73a9c69640a # Parent 5982afcbf9dce1d2fa4f64c143af8734710d91fb 8185934: keytool shows "Signature algorithm: SHA1withECDSA, -1-bit key" Reviewed-by: mullan diff -r 5982afcbf9dc -r 5196af754957 jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java --- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java Tue Aug 08 12:32:41 2017 +0100 +++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java Tue Aug 08 21:37:38 2017 +0800 @@ -3071,8 +3071,14 @@ 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()); diff -r 5982afcbf9dc -r 5196af754957 jdk/src/java.base/share/classes/sun/security/tools/keytool/Resources.java --- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Resources.java Tue Aug 08 12:32:41 2017 +0100 +++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Resources.java Tue Aug 08 21:37:38 2017 +0800 @@ -462,6 +462,7 @@ {"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", diff -r 5982afcbf9dc -r 5196af754957 jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java --- a/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java Tue Aug 08 12:32:41 2017 +0100 +++ b/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java Tue Aug 08 21:37:38 2017 +0800 @@ -1088,8 +1088,12 @@ 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( diff -r 5982afcbf9dc -r 5196af754957 jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java --- a/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java Tue Aug 08 12:32:41 2017 +0100 +++ b/jdk/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java Tue Aug 08 21:37:38 2017 +0800 @@ -164,6 +164,7 @@ {"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.",