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; |
195 @Override |
198 @Override |
196 protected SecretKey engineGenerateSecret(String algorithm) |
199 protected SecretKey engineGenerateSecret(String algorithm) |
197 throws IllegalStateException, NoSuchAlgorithmException, |
200 throws IllegalStateException, NoSuchAlgorithmException, |
198 InvalidKeyException { |
201 InvalidKeyException { |
199 |
202 |
200 throw new NoSuchAlgorithmException("Not supported"); |
203 if (algorithm == null) { |
|
204 throw new NoSuchAlgorithmException("Algorithm must not be null"); |
|
205 } |
|
206 if (!(algorithm.equals("TlsPremasterSecret"))) { |
|
207 throw new NoSuchAlgorithmException |
|
208 ("Only supported for algorithm TlsPremasterSecret"); |
|
209 } |
|
210 return new SecretKeySpec(engineGenerateSecret(), "TlsPremasterSecret"); |
201 } |
211 } |
202 |
212 |
203 static class X25519 extends XDHKeyAgreement { |
213 static class X25519 extends XDHKeyAgreement { |
204 |
214 |
205 public X25519() { |
215 public X25519() { |