src/java.base/share/classes/sun/security/ssl/XDHKeyExchange.java
changeset 57718 a93b7b28f644
parent 55353 946f7f2d321c
child 58679 9c3209ff7550
equal deleted inserted replaced
57716:bfcdcd00e4fb 57718:a93b7b28f644
    27 import java.io.IOException;
    27 import java.io.IOException;
    28 import java.math.BigInteger;
    28 import java.math.BigInteger;
    29 import java.security.*;
    29 import java.security.*;
    30 import java.security.interfaces.XECPublicKey;
    30 import java.security.interfaces.XECPublicKey;
    31 import java.security.spec.*;
    31 import java.security.spec.*;
    32 import sun.security.ssl.NamedGroup.NamedGroupType;
    32 import sun.security.ssl.NamedGroup.NamedGroupSpec;
    33 import sun.security.util.*;
    33 import sun.security.util.*;
    34 
    34 
    35 /**
    35 /**
    36  * Specifics for XEC/XDH Keys/Exchanges
    36  * Specifics for XEC/XDH Keys/Exchanges
    37  */
    37  */
    66          */
    66          */
    67         static XDHECredentials valueOf(NamedGroup namedGroup,
    67         static XDHECredentials valueOf(NamedGroup namedGroup,
    68                 byte[] encodedPoint) throws IOException,
    68                 byte[] encodedPoint) throws IOException,
    69                 GeneralSecurityException {
    69                 GeneralSecurityException {
    70 
    70 
    71             if (namedGroup.type != NamedGroupType.NAMED_GROUP_XDH) {
    71             if (namedGroup.spec != NamedGroupSpec.NAMED_GROUP_XDH) {
    72                 throw new RuntimeException(
    72                 throw new RuntimeException(
    73                         "Credentials decoding:  Not XDH named group");
    73                         "Credentials decoding:  Not XDH named group");
    74             }
    74             }
    75 
    75 
    76             if (encodedPoint == null || encodedPoint.length == 0) {
    76             if (encodedPoint == null || encodedPoint.length == 0) {
    99 
    99 
   100         XDHEPossession(NamedGroup namedGroup, SecureRandom random) {
   100         XDHEPossession(NamedGroup namedGroup, SecureRandom random) {
   101             try {
   101             try {
   102                 KeyPairGenerator kpg
   102                 KeyPairGenerator kpg
   103                         = KeyPairGenerator.getInstance(namedGroup.algorithm);
   103                         = KeyPairGenerator.getInstance(namedGroup.algorithm);
   104                 AlgorithmParameterSpec params = namedGroup.getParameterSpec();
   104                 kpg.initialize(namedGroup.keAlgParamSpec, random);
   105                 kpg.initialize(params, random);
       
   106                 KeyPair kp = kpg.generateKeyPair();
   105                 KeyPair kp = kpg.generateKeyPair();
   107                 privateKey = kp.getPrivate();
   106                 privateKey = kp.getPrivate();
   108                 publicKey = (XECPublicKey) kp.getPublic();
   107                 publicKey = (XECPublicKey) kp.getPublic();
   109             } catch (GeneralSecurityException e) {
   108             } catch (GeneralSecurityException e) {
   110                 throw new RuntimeException(
   109                 throw new RuntimeException(