--- a/jdk/src/share/classes/sun/security/pkcs11/P11Key.java Wed Oct 12 12:12:25 2011 -0700
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11Key.java Thu Oct 13 12:00:51 2011 +0100
@@ -1028,28 +1028,21 @@
try {
params = P11ECKeyFactory.decodeParameters
(attributes[1].getByteArray());
-
- /*
- * An uncompressed EC point may be in either of two formats.
- * First try the OCTET STRING encoding:
- * 04 <length> 04 <X-coordinate> <Y-coordinate>
- *
- * Otherwise try the raw encoding:
- * 04 <X-coordinate> <Y-coordinate>
- */
byte[] ecKey = attributes[0].getByteArray();
- try {
+ // Check whether the X9.63 encoding of an EC point is wrapped
+ // in an ASN.1 OCTET STRING
+ if (!token.config.getUseEcX963Encoding()) {
DerValue wECPoint = new DerValue(ecKey);
- if (wECPoint.getTag() != DerValue.tag_OctetString)
- throw new IOException("Unexpected tag: " +
- wECPoint.getTag());
+ if (wECPoint.getTag() != DerValue.tag_OctetString) {
+ throw new IOException("Could not DER decode EC point." +
+ " Unexpected tag: " + wECPoint.getTag());
+ }
w = P11ECKeyFactory.decodePoint
(wECPoint.getDataBytes(), params.getCurve());
- } catch (IOException e) {
- // Failover
+ } else {
w = P11ECKeyFactory.decodePoint(ecKey, params.getCurve());
}