src/java.base/share/classes/sun/security/ssl/PredefinedDHParameterSpecs.java
author xuelei
Tue, 19 Jun 2018 09:05:57 -0700
branchJDK-8145252-TLS13-branch
changeset 56782 b472b5917a1b
parent 56542 56aaa6cb3693
permissions -rw-r--r--
typo, format and copyrigth corrections
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45064
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
     1
/*
56782
b472b5917a1b typo, format and copyrigth corrections
xuelei
parents: 56542
diff changeset
     2
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
45064
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
     4
 *
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    10
 *
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    15
 * accompanied this code).
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    16
 *
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    20
 *
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    23
 * questions.
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    24
 */
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    25
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    26
package sun.security.ssl;
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    27
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
    28
import java.math.BigInteger;
45064
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    29
import java.security.*;
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
    30
import java.util.Collections;
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
    31
import java.util.HashMap;
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
    32
import java.util.Map;
45064
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    33
import java.util.regex.Matcher;
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
    34
import java.util.regex.Pattern;
45064
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    35
import javax.crypto.spec.DHParameterSpec;
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    36
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    37
/**
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    38
 * Predefined default DH ephemeral parameters.
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    39
 */
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    40
final class PredefinedDHParameterSpecs {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    41
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    42
    //
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    43
    // Default DH ephemeral parameters
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    44
    //
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    45
    private static final BigInteger p512 = new BigInteger(       // generated
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    46
            "D87780E15FF50B4ABBE89870188B049406B5BEA98AB23A02" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    47
            "41D88EA75B7755E669C08093D3F0CA7FC3A5A25CF067DCB9" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    48
            "A43DD89D1D90921C6328884461E0B6D3", 16);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    49
    private static final BigInteger p768 = new BigInteger(       // RFC 2409
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    50
            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    51
            "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    52
            "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    53
            "E485B576625E7EC6F44C42E9A63A3620FFFFFFFFFFFFFFFF", 16);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    54
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    55
    private static final BigInteger p1024 = new BigInteger(      // RFC 2409
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    56
            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    57
            "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    58
            "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    59
            "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    60
            "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    61
            "FFFFFFFFFFFFFFFF", 16);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    62
    private static final BigInteger p1536 = new BigInteger(      // RFC 3526
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    63
            "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    64
            "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    65
            "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    66
            "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    67
            "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    68
            "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    69
            "83655D23DCA3AD961C62F356208552BB9ED529077096966D" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    70
            "670C354E4ABC9804F1746C08CA237327FFFFFFFFFFFFFFFF", 16);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    71
    private static final BigInteger p2048 = new BigInteger(      // TLS FFDHE
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    72
            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    73
            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    74
            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    75
            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    76
            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    77
            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    78
            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    79
            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    80
            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    81
            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    82
            "886B423861285C97FFFFFFFFFFFFFFFF", 16);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    83
    private static final BigInteger p3072 = new BigInteger(      // TLS FFDHE
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    84
            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    85
            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    86
            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    87
            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    88
            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    89
            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    90
            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    91
            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    92
            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    93
            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    94
            "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    95
            "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    96
            "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    97
            "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    98
            "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
    99
            "3C1B20EE3FD59D7C25E41D2B66C62E37FFFFFFFFFFFFFFFF", 16);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   100
    private static final BigInteger p4096 = new BigInteger(      // TLS FFDHE
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   101
            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   102
            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   103
            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   104
            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   105
            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   106
            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   107
            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   108
            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   109
            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   110
            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   111
            "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   112
            "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   113
            "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   114
            "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   115
            "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   116
            "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   117
            "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   118
            "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   119
            "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   120
            "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   121
            "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E655F6A" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   122
            "FFFFFFFFFFFFFFFF", 16);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   123
    private static final BigInteger p6144 = new BigInteger(      // TLS FFDHE
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   124
            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   125
            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   126
            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   127
            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   128
            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   129
            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   130
            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   131
            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   132
            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   133
            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   134
            "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   135
            "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   136
            "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   137
            "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   138
            "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   139
            "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   140
            "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   141
            "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   142
            "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   143
            "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   144
            "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD902" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   145
            "0BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA6" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   146
            "3BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3A" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   147
            "CDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   148
            "A52471F7A9A96910B855322EDB6340D8A00EF092350511E3" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   149
            "0ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   150
            "763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   151
            "B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538C" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   152
            "D72B03746AE77F5E62292C311562A846505DC82DB854338A" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   153
            "E49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B04" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   154
            "5B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   155
            "A41D570D7938DAD4A40E329CD0E40E65FFFFFFFFFFFFFFFF", 16);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   156
    private static final BigInteger p8192 = new BigInteger(      // TLS FFDHE
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   157
            "FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   158
            "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   159
            "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   160
            "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   161
            "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   162
            "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   163
            "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   164
            "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   165
            "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   166
            "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   167
            "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   168
            "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   169
            "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   170
            "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   171
            "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   172
            "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   173
            "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   174
            "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   175
            "A907600A918130C46DC778F971AD0038092999A333CB8B7A" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   176
            "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   177
            "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E0DD902" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   178
            "0BFD64B645036C7A4E677D2C38532A3A23BA4442CAF53EA6" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   179
            "3BB454329B7624C8917BDD64B1C0FD4CB38E8C334C701C3A" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   180
            "CDAD0657FCCFEC719B1F5C3E4E46041F388147FB4CFDB477" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   181
            "A52471F7A9A96910B855322EDB6340D8A00EF092350511E3" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   182
            "0ABEC1FFF9E3A26E7FB29F8C183023C3587E38DA0077D9B4" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   183
            "763E4E4B94B2BBC194C6651E77CAF992EEAAC0232A281BF6" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   184
            "B3A739C1226116820AE8DB5847A67CBEF9C9091B462D538C" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   185
            "D72B03746AE77F5E62292C311562A846505DC82DB854338A" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   186
            "E49F5235C95B91178CCF2DD5CACEF403EC9D1810C6272B04" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   187
            "5B3B71F9DC6B80D63FDD4A8E9ADB1E6962A69526D43161C1" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   188
            "A41D570D7938DAD4A40E329CCFF46AAA36AD004CF600C838" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   189
            "1E425A31D951AE64FDB23FCEC9509D43687FEB69EDD1CC5E" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   190
            "0B8CC3BDF64B10EF86B63142A3AB8829555B2F747C932665" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   191
            "CB2C0F1CC01BD70229388839D2AF05E454504AC78B758282" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   192
            "2846C0BA35C35F5C59160CC046FD8251541FC68C9C86B022" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   193
            "BB7099876A460E7451A8A93109703FEE1C217E6C3826E52C" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   194
            "51AA691E0E423CFC99E9E31650C1217B624816CDAD9A95F9" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   195
            "D5B8019488D9C0A0A1FE3075A577E23183F81D4A3F2FA457" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   196
            "1EFC8CE0BA8A4FE8B6855DFE72B0A66EDED2FBABFBE58A30" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   197
            "FAFABE1C5D71A87E2F741EF8C1FE86FEA6BBFDE530677F0D" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   198
            "97D11D49F7A8443D0822E506A9F4614E011E2A94838FF88C" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   199
            "D68C8BB7C5C6424CFFFFFFFFFFFFFFFF", 16);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   200
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   201
    private static final BigInteger[] supportedPrimes = {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   202
            p512, p768, p1024, p1536, p2048, p3072, p4096, p6144, p8192};
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   203
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   204
    private static final BigInteger[] ffdhePrimes = {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   205
            p2048, p3072, p4096, p6144, p8192};
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   206
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   207
    // a measure of the uncertainty that prime modulus p is not a prime
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   208
    //
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   209
    // see BigInteger.isProbablePrime(int certainty)
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   210
    private static final int PRIME_CERTAINTY = 120;
45064
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   211
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   212
    // the known security property, jdk.tls.server.defaultDHEParameters
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   213
    private static final String PROPERTY_NAME =
45064
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   214
            "jdk.tls.server.defaultDHEParameters";
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   215
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   216
    private static final Pattern spacesPattern = Pattern.compile("\\s+");
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   217
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   218
    private static final Pattern syntaxPattern = Pattern.compile(
45064
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   219
            "(\\{[0-9A-Fa-f]+,[0-9A-Fa-f]+\\})" +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   220
            "(,\\{[0-9A-Fa-f]+,[0-9A-Fa-f]+\\})*");
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   221
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   222
    private static final Pattern paramsPattern = Pattern.compile(
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   223
            "\\{([0-9A-Fa-f]+),([0-9A-Fa-f]+)\\}");
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   224
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   225
    // cache of predefined default DH ephemeral parameters
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   226
    static final Map<Integer, DHParameterSpec> definedParams;
45064
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   227
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   228
    // cache of Finite Field DH Ephemeral parameters (RFC 7919/FFDHE)
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   229
    static final Map<Integer, DHParameterSpec> ffdheParams;
45064
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   230
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   231
    static {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   232
        String property = AccessController.doPrivileged(
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   233
            new PrivilegedAction<String>() {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   234
                public String run() {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   235
                    return Security.getProperty(PROPERTY_NAME);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   236
                }
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   237
            });
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   238
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   239
        if (property != null && !property.isEmpty()) {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   240
            // remove double quote marks from beginning/end of the property
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   241
            if (property.length() >= 2 && property.charAt(0) == '"' &&
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   242
                    property.charAt(property.length() - 1) == '"') {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   243
                property = property.substring(1, property.length() - 1);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   244
            }
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   245
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   246
            property = property.trim();
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   247
        }
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   248
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   249
        if (property != null && !property.isEmpty()) {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   250
            Matcher spacesMatcher = spacesPattern.matcher(property);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   251
            property = spacesMatcher.replaceAll("");
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   252
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   253
            if (SSLLogger.isOn && SSLLogger.isOn("sslctx")) {
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   254
                SSLLogger.fine(
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   255
                        "The Security Property " +
45064
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   256
                        PROPERTY_NAME + ": " + property);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   257
            }
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   258
        }
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   259
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   260
        Map<Integer,DHParameterSpec> defaultParams = new HashMap<>();
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   261
        if (property != null && !property.isEmpty()) {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   262
            Matcher syntaxMatcher = syntaxPattern.matcher(property);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   263
            if (syntaxMatcher.matches()) {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   264
                Matcher paramsFinder = paramsPattern.matcher(property);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   265
                while(paramsFinder.find()) {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   266
                    String primeModulus = paramsFinder.group(1);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   267
                    BigInteger p = new BigInteger(primeModulus, 16);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   268
                    if (!p.isProbablePrime(PRIME_CERTAINTY)) {
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   269
                        if (SSLLogger.isOn && SSLLogger.isOn("sslctx")) {
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   270
                            SSLLogger.fine(
45064
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   271
                                "Prime modulus p in Security Property, " +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   272
                                PROPERTY_NAME + ", is not a prime: " +
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   273
                                primeModulus);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   274
                        }
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   275
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   276
                        continue;
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   277
                    }
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   278
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   279
                    String baseGenerator = paramsFinder.group(2);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   280
                    BigInteger g = new BigInteger(baseGenerator, 16);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   281
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   282
                    DHParameterSpec spec = new DHParameterSpec(p, g);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   283
                    int primeLen = p.bitLength();
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   284
                    defaultParams.put(primeLen, spec);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   285
                }
56542
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   286
            } else if (SSLLogger.isOn && SSLLogger.isOn("sslctx")) {
56aaa6cb3693 Initial TLSv1.3 Implementation
wetmore
parents: 47216
diff changeset
   287
                SSLLogger.fine("Invalid Security Property, " +
45064
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   288
                        PROPERTY_NAME + ", definition");
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   289
            }
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   290
        }
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   291
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   292
        Map<Integer,DHParameterSpec> tempFFDHEs = new HashMap<>();
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   293
        for (BigInteger p : ffdhePrimes) {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   294
            int primeLen = p.bitLength();
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   295
            DHParameterSpec dhps = new DHParameterSpec(p, BigInteger.TWO);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   296
            tempFFDHEs.put(primeLen, dhps);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   297
            defaultParams.putIfAbsent(primeLen, dhps);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   298
        }
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   299
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   300
        for (BigInteger p : supportedPrimes) {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   301
            int primeLen = p.bitLength();
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   302
            if (defaultParams.get(primeLen) == null) {
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   303
                defaultParams.put(primeLen,
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   304
                    new DHParameterSpec(p, BigInteger.TWO));
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   305
            }
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   306
        }
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   307
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   308
        ffdheParams =
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   309
            Collections.<Integer,DHParameterSpec>unmodifiableMap(tempFFDHEs);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   310
        definedParams =
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   311
            Collections.<Integer,DHParameterSpec>unmodifiableMap(defaultParams);
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   312
    }
b1b45177051b 8140436: Negotiated Finite Field Diffie-Hellman Ephemeral Parameters for TLS
xuelei
parents:
diff changeset
   313
}