47 private ECPoint w; |
47 private ECPoint w; |
48 private ECParameterSpec params; |
48 private ECParameterSpec params; |
49 |
49 |
50 /** |
50 /** |
51 * Construct a key from its components. Used by the |
51 * Construct a key from its components. Used by the |
52 * ECKeyFactory and SunPKCS11. |
52 * ECKeyFactory. |
53 */ |
53 */ |
54 @SuppressWarnings("deprecation") |
54 @SuppressWarnings("deprecation") |
55 public ECPublicKeyImpl(ECPoint w, ECParameterSpec params) |
55 ECPublicKeyImpl(ECPoint w, ECParameterSpec params) |
56 throws InvalidKeyException { |
56 throws InvalidKeyException { |
57 this.w = w; |
57 this.w = w; |
58 this.params = params; |
58 this.params = params; |
59 // generate the encoding |
59 // generate the encoding |
60 algid = new AlgorithmId |
60 algid = new AlgorithmId |
61 (AlgorithmId.EC_oid, ECParameters.getAlgorithmParameters(params)); |
61 (AlgorithmId.EC_oid, ECParameters.getAlgorithmParameters(params)); |
62 key = ECParameters.encodePoint(w, params.getCurve()); |
62 key = ECUtil.encodePoint(w, params.getCurve()); |
63 } |
63 } |
64 |
64 |
65 /** |
65 /** |
66 * Construct a key from its encoding. Used by RSAKeyFactory. |
66 * Construct a key from its encoding. |
67 */ |
67 */ |
68 public ECPublicKeyImpl(byte[] encoded) throws InvalidKeyException { |
68 ECPublicKeyImpl(byte[] encoded) throws InvalidKeyException { |
69 decode(encoded); |
69 decode(encoded); |
70 } |
70 } |
71 |
71 |
72 // see JCA doc |
72 // see JCA doc |
73 public String getAlgorithm() { |
73 public String getAlgorithm() { |
102 "encoded in the algorithm identifier"); |
102 "encoded in the algorithm identifier"); |
103 } |
103 } |
104 |
104 |
105 try { |
105 try { |
106 params = algParams.getParameterSpec(ECParameterSpec.class); |
106 params = algParams.getParameterSpec(ECParameterSpec.class); |
107 w = ECParameters.decodePoint(key, params.getCurve()); |
107 w = ECUtil.decodePoint(key, params.getCurve()); |
108 } catch (IOException e) { |
108 } catch (IOException e) { |
109 throw new InvalidKeyException("Invalid EC key", e); |
109 throw new InvalidKeyException("Invalid EC key", e); |
110 } catch (InvalidParameterSpecException e) { |
110 } catch (InvalidParameterSpecException e) { |
111 throw new InvalidKeyException("Invalid EC key", e); |
111 throw new InvalidKeyException("Invalid EC key", e); |
112 } |
112 } |