equal
deleted
inserted
replaced
36 import java.security.spec.AlgorithmParameterSpec; |
36 import java.security.spec.AlgorithmParameterSpec; |
37 import java.security.spec.NamedParameterSpec; |
37 import java.security.spec.NamedParameterSpec; |
38 import javax.crypto.KeyAgreementSpi; |
38 import javax.crypto.KeyAgreementSpi; |
39 import javax.crypto.SecretKey; |
39 import javax.crypto.SecretKey; |
40 import javax.crypto.ShortBufferException; |
40 import javax.crypto.ShortBufferException; |
|
41 import javax.crypto.spec.SecretKeySpec; |
41 import java.util.function.Function; |
42 import java.util.function.Function; |
|
43 |
|
44 import sun.security.util.XECParameters; |
42 |
45 |
43 public class XDHKeyAgreement extends KeyAgreementSpi { |
46 public class XDHKeyAgreement extends KeyAgreementSpi { |
44 |
47 |
45 private byte[] privateKey; |
48 private byte[] privateKey; |
46 private byte[] secret; |
49 private byte[] secret; |
200 @Override |
203 @Override |
201 protected SecretKey engineGenerateSecret(String algorithm) |
204 protected SecretKey engineGenerateSecret(String algorithm) |
202 throws IllegalStateException, NoSuchAlgorithmException, |
205 throws IllegalStateException, NoSuchAlgorithmException, |
203 InvalidKeyException { |
206 InvalidKeyException { |
204 |
207 |
205 throw new NoSuchAlgorithmException("Not supported"); |
208 if (algorithm == null) { |
|
209 throw new NoSuchAlgorithmException("Algorithm must not be null"); |
|
210 } |
|
211 if (!(algorithm.equals("TlsPremasterSecret"))) { |
|
212 throw new NoSuchAlgorithmException |
|
213 ("Only supported for algorithm TlsPremasterSecret"); |
|
214 } |
|
215 return new SecretKeySpec(engineGenerateSecret(), "TlsPremasterSecret"); |
206 } |
216 } |
207 |
217 |
208 static class X25519 extends XDHKeyAgreement { |
218 static class X25519 extends XDHKeyAgreement { |
209 |
219 |
210 public X25519() { |
220 public X25519() { |