test/jdk/java/security/KeyAgreement/KeyAgreementTest.java
author apetcher
Tue, 08 May 2018 09:47:28 -0400
changeset 50053 9bc1e6487cbb
child 52330 df10a0cacf3e
permissions -rw-r--r--
8171277: Elliptic Curves for Security in Crypto Summary: Implementations of X25519 and X448 key agreement in SunEC Reviewed-by: mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50053
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
     1
/*
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
     2
 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
     4
 *
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
     8
 *
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    13
 * accompanied this code).
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    14
 *
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    18
 *
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    21
 * questions.
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    22
 */
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    23
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    24
 /*
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    25
 * @test
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    26
 * @bug 4936763 8184359
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    27
 * @summary KeyAgreement Test with all supported algorithms from JCE.
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    28
 *          Arguments order <KeyExchangeAlgorithm> <KeyGenAlgorithm> <Provider>
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    29
 *          It removes com/sun/crypto/provider/KeyAgreement/DHGenSecretKey.java
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    30
 *          as the same functionality for DiffieHellman is covered along with
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    31
 *          this test file was covered before with JDK-4936763.
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    32
 * @run main/othervm -Djdk.crypto.KeyAgreement.legacyKDF=true KeyAgreementTest
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    33
 *          DiffieHellman DH SunJCE
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    34
 * @run main KeyAgreementTest ECDH EC SunEC
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    35
 * @run main KeyAgreementTest XDH XDH SunEC
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    36
 */
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    37
import java.security.KeyPair;
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    38
import java.security.KeyPairGenerator;
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    39
import java.security.spec.NamedParameterSpec;
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    40
import java.security.spec.AlgorithmParameterSpec;
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    41
import java.security.spec.ECGenParameterSpec;
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    42
import java.util.ArrayList;
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    43
import java.util.Arrays;
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    44
import java.util.List;
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    45
import javax.crypto.KeyAgreement;
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    46
import javax.crypto.spec.DHGenParameterSpec;
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    47
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    48
public class KeyAgreementTest {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    49
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    50
    public static void main(String[] args) throws Exception {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    51
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    52
        String kaAlgo = args[0];
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    53
        String kpgAlgo = args[1];
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    54
        String provider = args[2];
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    55
        AlgoSpec aSpec = AlgoSpec.valueOf(AlgoSpec.class, kaAlgo);
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    56
        List<AlgorithmParameterSpec> specs = aSpec.getAlgorithmParameterSpecs();
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    57
        for (AlgorithmParameterSpec spec : specs) {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    58
            testKeyAgreement(provider, kaAlgo, kpgAlgo, spec);
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    59
        }
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    60
    }
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    61
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    62
    /**
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    63
     * Generate AlgorithmParameterSpec using all possible supported curve for
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    64
     * KeyExchangeAlgorithm.
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    65
     */
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    66
    private enum AlgoSpec {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    67
        // EC curve supported for KeyGeneration can found between intersection
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    68
        // of curves define in
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    69
        // "java.base/share/classes/sun/security/util/CurveDB.java"
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    70
        // and
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    71
        // "jdk.crypto.ec/share/native/libsunec/impl/ecdecode.c"
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    72
        ECDH(
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    73
                // SEC2 prime curves
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    74
                "secp112r1", "secp112r2", "secp128r1", "secp128r2", "secp160k1",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    75
                "secp160r1", "secp192k1", "secp192r1", "secp224k1", "secp224r1",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    76
                "secp256k1", "secp256r1", "secp384r1", "secp521r1",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    77
                // ANSI X9.62 prime curves
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    78
                "X9.62 prime192v2", "X9.62 prime192v3", "X9.62 prime239v1",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    79
                "X9.62 prime239v2", "X9.62 prime239v3",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    80
                // SEC2 binary curves
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    81
                "sect113r1", "sect113r2", "sect131r1", "sect131r2", "sect163k1",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    82
                "sect163r1", "sect163r2", "sect193r1", "sect193r2", "sect233k1",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    83
                "sect233r1", "sect239k1", "sect283k1", "sect283r1", "sect409k1",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    84
                "sect409r1", "sect571k1", "sect571r1",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    85
                // ANSI X9.62 binary curves
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    86
                "X9.62 c2tnb191v1", "X9.62 c2tnb191v2", "X9.62 c2tnb191v3",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    87
                "X9.62 c2tnb239v1", "X9.62 c2tnb239v2", "X9.62 c2tnb239v3",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    88
                "X9.62 c2tnb359v1", "X9.62 c2tnb431r1"
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    89
        ),
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    90
        XDH("X25519", "X448"),
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    91
        // There is no curve for DiffieHellman
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    92
        DiffieHellman(new String[]{});
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    93
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    94
        private final List<AlgorithmParameterSpec> specs = new ArrayList<>();
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    95
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    96
        private AlgoSpec(String... curves) {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    97
            // Generate AlgorithmParameterSpec for each KeyExchangeAlgorithm
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    98
            for (String crv : curves) {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
    99
                switch (this.name()) {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   100
                    case "ECDH":
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   101
                        specs.add(new ECGenParameterSpec(crv));
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   102
                        break;
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   103
                    case "XDH":
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   104
                        specs.add(new NamedParameterSpec(crv));
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   105
                        break;
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   106
                    case "DiffieHellman":
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   107
                        specs.add(new DHGenParameterSpec(512, 64));
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   108
                        break;
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   109
                    default:
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   110
                        throw new RuntimeException("Invalid Algo name "
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   111
                                + this.name());
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   112
                }
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   113
            }
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   114
        }
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   115
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   116
        public List<AlgorithmParameterSpec> getAlgorithmParameterSpecs() {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   117
            return this.specs;
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   118
        }
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   119
    }
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   120
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   121
    /**
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   122
     * Perform KeyAgreement operation using native as well as JCE provider.
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   123
     */
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   124
    private static void testKeyAgreement(String provider, String kaAlgo,
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   125
            String kpgAlgo, AlgorithmParameterSpec spec) throws Exception {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   126
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   127
        KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgo, provider);
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   128
        kpg.initialize(spec);
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   129
        KeyPair kp1 = kpg.generateKeyPair();
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   130
        KeyPair kp2 = kpg.generateKeyPair();
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   131
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   132
        // Uses KeyAgreement based on Provider search order.
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   133
        KeyAgreement ka1 = KeyAgreement.getInstance(kaAlgo);
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   134
        ka1.init(kp1.getPrivate());
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   135
        ka1.doPhase(kp2.getPublic(), true);
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   136
        byte[] secret1 = ka1.generateSecret();
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   137
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   138
        // Uses SunJCE provider
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   139
        KeyAgreement ka2 = KeyAgreement.getInstance(kaAlgo, provider);
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   140
        ka2.init(kp2.getPrivate());
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   141
        ka2.doPhase(kp1.getPublic(), true);
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   142
        // Keeping the legacy generateSecret method for DiffieHellman as it was
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   143
        // defined in removed Test file from JDK-4936763,
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   144
        // com/sun/crypto/provider/KeyAgreement/DHGenSecretKey.java.
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   145
        byte[] secret2 = "DiffieHellman".equals(kaAlgo)
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   146
                ? ka2.generateSecret("AES").getEncoded() : ka2.generateSecret();
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   147
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   148
        // With related keypairs, each provider should generate same
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   149
        // KeyAgreement secret.
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   150
        if (!Arrays.equals(secret1, secret2)) {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   151
            throw new Exception("KeyAgreement secret mismatch.");
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   152
        }
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   153
    }
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents:
diff changeset
   154
}