jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java
changeset 4809 c00eed67999d
parent 2 90ce3da70b43
child 5506 202f599c92aa
--- a/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java	Tue Jan 19 11:43:45 2010 +0800
+++ b/jdk/src/share/classes/sun/security/pkcs11/P11ECKeyFactory.java	Thu Jan 21 23:59:41 2010 +0000
@@ -40,6 +40,8 @@
 import sun.security.pkcs11.wrapper.*;
 import static sun.security.pkcs11.wrapper.PKCS11Constants.*;
 
+import sun.security.util.DerValue;
+
 /**
  * EC KeyFactory implemenation.
  *
@@ -201,7 +203,16 @@
 
     private PublicKey generatePublic(ECPoint point, ECParameterSpec params) throws PKCS11Exception {
         byte[] encodedParams = ECParameters.encodeParameters(params);
-        byte[] encodedPoint = ECParameters.encodePoint(point, params.getCurve());
+        byte[] encodedPoint = null;
+        DerValue pkECPoint = new DerValue(DerValue.tag_OctetString,
+            ECParameters.encodePoint(point, params.getCurve()));
+
+        try {
+            encodedPoint = pkECPoint.toByteArray();
+        } catch (IOException e) {
+            throw new IllegalArgumentException("Could not DER encode point", e);
+        }
+
         CK_ATTRIBUTE[] attributes = new CK_ATTRIBUTE[] {
             new CK_ATTRIBUTE(CKA_CLASS, CKO_PUBLIC_KEY),
             new CK_ATTRIBUTE(CKA_KEY_TYPE, CKK_EC),