37 import sun.security.x509.*; 38 39 /** 40 * Key implementation for EC public keys. 41 * 42 * @since 1.6 43 * @author Andreas Sterbenz 44 */ 45 public final class ECPublicKeyImpl extends X509Key implements ECPublicKey { 46 47 private static final long serialVersionUID = -2462037275160462289L; 48 49 private ECPoint w; 50 private ECParameterSpec params; 51 52 /** 53 * Construct a key from its components. Used by the 54 * ECKeyFactory. 55 */ 56 @SuppressWarnings("deprecation") 57 ECPublicKeyImpl(ECPoint w, ECParameterSpec params) 58 throws InvalidKeyException { 59 this.w = w; 60 this.params = params; 61 // generate the encoding 62 algid = new AlgorithmId 63 (AlgorithmId.EC_oid, ECParameters.getAlgorithmParameters(params)); 64 key = ECUtil.encodePoint(w, params.getCurve()); 65 } 66 67 /** 68 * Construct a key from its encoding. 69 */ 70 ECPublicKeyImpl(byte[] encoded) throws InvalidKeyException { 71 decode(encoded); 72 } 73 74 // see JCA doc 75 public String getAlgorithm() { 76 return "EC"; 77 } 78 79 // see JCA doc 80 public ECPoint getW() { 81 return w; 82 } 83 84 // see JCA doc 85 public ECParameterSpec getParams() { 86 return params; 87 } 88 89 // Internal API to get the encoded point. Currently used by SunPKCS11. 90 // This may change/go away depending on what we do with the public API. | 37 import sun.security.x509.*; 38 39 /** 40 * Key implementation for EC public keys. 41 * 42 * @since 1.6 43 * @author Andreas Sterbenz 44 */ 45 public final class ECPublicKeyImpl extends X509Key implements ECPublicKey { 46 47 private static final long serialVersionUID = -2462037275160462289L; 48 49 private ECPoint w; 50 private ECParameterSpec params; 51 52 /** 53 * Construct a key from its components. Used by the 54 * ECKeyFactory. 55 */ 56 @SuppressWarnings("deprecation") 57 public ECPublicKeyImpl(ECPoint w, ECParameterSpec params) 58 throws InvalidKeyException { 59 this.w = w; 60 this.params = params; 61 // generate the encoding 62 algid = new AlgorithmId 63 (AlgorithmId.EC_oid, ECParameters.getAlgorithmParameters(params)); 64 key = ECUtil.encodePoint(w, params.getCurve()); 65 } 66 67 /** 68 * Construct a key from its encoding. 69 */ 70 public ECPublicKeyImpl(byte[] encoded) throws InvalidKeyException { 71 decode(encoded); 72 } 73 74 // see JCA doc 75 public String getAlgorithm() { 76 return "EC"; 77 } 78 79 // see JCA doc 80 public ECPoint getW() { 81 return w; 82 } 83 84 // see JCA doc 85 public ECParameterSpec getParams() { 86 return params; 87 } 88 89 // Internal API to get the encoded point. Currently used by SunPKCS11. 90 // This may change/go away depending on what we do with the public API. |