src/jdk.crypto.ec/share/classes/sun/security/ec/SunEC.java
author bpb
Fri, 14 Sep 2018 09:00:22 -0700
changeset 51746 07ae9da7a230
parent 50053 9bc1e6487cbb
permissions -rw-r--r--
8210741: Typo in Java API documentation of java.nio.file.Paths Reviewed-by: alanb, rriggs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3492
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     1
/*
50053
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
     2
 * Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved.
3492
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     4
 *
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3863
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
3492
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3863
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
3492
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    10
 *
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    15
 * accompanied this code).
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    16
 *
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3863
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3863
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3863
diff changeset
    23
 * questions.
3492
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    24
 */
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    25
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    26
package sun.security.ec;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    27
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    28
import java.util.*;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    29
import java.security.*;
31270
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    30
import java.util.regex.Pattern;
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    31
import sun.security.util.CurveDB;
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    32
import sun.security.util.NamedCurve;
50053
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
    33
40416
5d91b2fd668c 8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents: 33991
diff changeset
    34
import static sun.security.util.SecurityConstants.PROVIDER_VER;
3492
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    35
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    36
/**
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    37
 * Provider class for the Elliptic Curve provider.
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    38
 * Supports EC keypair and parameter generation, ECDSA signing and
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    39
 * ECDH key agreement.
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    40
 *
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    41
 * IMPLEMENTATION NOTE:
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    42
 * The Java classes in this provider access a native ECC implementation
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    43
 * via JNI to a C++ wrapper class which in turn calls C functions.
27565
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 25859
diff changeset
    44
 * The Java classes are packaged into the jdk.crypto.sunec module and the
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 25859
diff changeset
    45
 * C++ and C functions are packaged into libsunec.so or sunec.dll in the
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 25859
diff changeset
    46
 * JRE native libraries directory.  If the native library is not present
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 25859
diff changeset
    47
 * then this provider is registered with support for fewer ECC algorithms
729f9700483a 8049367: Modular Run-Time Images
chegar
parents: 25859
diff changeset
    48
 * (KeyPairGenerator, Signature and KeyAgreement are omitted).
3492
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    49
 *
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    50
 * @since   1.7
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    51
 */
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    52
public final class SunEC extends Provider {
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    53
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    54
    private static final long serialVersionUID = -2279741672933606418L;
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    55
3863
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    56
    // flag indicating whether the full EC implementation is present
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    57
    // (when native library is absent then fewer EC algorithms are available)
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    58
    private static boolean useFullImplementation = true;
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    59
    static {
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    60
        try {
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    61
            AccessController.doPrivileged(new PrivilegedAction<Void>() {
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    62
                public Void run() {
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    63
                    System.loadLibrary("sunec"); // check for native library
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    64
                    return null;
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    65
                }
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    66
            });
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    67
        } catch (UnsatisfiedLinkError e) {
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    68
            useFullImplementation = false;
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    69
        }
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    70
    }
8e0f58b1c072 6884175: CR cleanup for 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents: 3492
diff changeset
    71
31270
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    72
    private static class ProviderService extends Provider.Service {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    73
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    74
        ProviderService(Provider p, String type, String algo, String cn) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    75
            super(p, type, algo, cn, null, null);
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    76
        }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    77
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    78
        ProviderService(Provider p, String type, String algo, String cn,
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    79
            String[] aliases, HashMap<String, String> attrs) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    80
            super(p, type, algo, cn,
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    81
                  (aliases == null? null : Arrays.asList(aliases)), attrs);
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    82
        }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    83
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    84
        @Override
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    85
        public Object newInstance(Object ctrParamObj)
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    86
            throws NoSuchAlgorithmException {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    87
            String type = getType();
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    88
            if (ctrParamObj != null) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    89
                throw new InvalidParameterException
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    90
                    ("constructorParameter not used with " + type + " engines");
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    91
            }
3492
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
    92
31270
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    93
            String algo = getAlgorithm();
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    94
            try {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    95
                if (type.equals("Signature")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    96
                    boolean inP1363 = algo.endsWith("inP1363Format");
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    97
                    if (inP1363) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    98
                        algo = algo.substring(0, algo.length() - 13);
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
    99
                    }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   100
                    if (algo.equals("SHA1withECDSA")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   101
                        return (inP1363? new ECDSASignature.SHA1inP1363Format() :
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   102
                            new ECDSASignature.SHA1());
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   103
                    } else if (algo.equals("SHA224withECDSA")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   104
                        return (inP1363? new ECDSASignature.SHA224inP1363Format() :
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   105
                            new ECDSASignature.SHA224());
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   106
                    } else if (algo.equals("SHA256withECDSA")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   107
                        return (inP1363? new ECDSASignature.SHA256inP1363Format() :
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   108
                            new ECDSASignature.SHA256());
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   109
                    } else if (algo.equals("SHA384withECDSA")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   110
                        return (inP1363? new ECDSASignature.SHA384inP1363Format() :
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   111
                            new ECDSASignature.SHA384());
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   112
                    } else if (algo.equals("SHA512withECDSA")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   113
                        return (inP1363? new ECDSASignature.SHA512inP1363Format() :
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   114
                            new ECDSASignature.SHA512());
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   115
                    } else if (algo.equals("NONEwithECDSA")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   116
                        return (inP1363? new ECDSASignature.RawinP1363Format() :
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   117
                            new ECDSASignature.Raw());
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   118
                    }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   119
                } else  if (type.equals("KeyFactory")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   120
                    if (algo.equals("EC")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   121
                        return new ECKeyFactory();
50053
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   122
                    } else if (algo.equals("XDH")) {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   123
                        return new XDHKeyFactory();
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   124
                    } else if (algo.equals("X25519")) {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   125
                        return new XDHKeyFactory.X25519();
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   126
                    } else if (algo.equals("X448")) {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   127
                        return new XDHKeyFactory.X448();
31270
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   128
                    }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   129
                } else  if (type.equals("AlgorithmParameters")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   130
                    if (algo.equals("EC")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   131
                        return new sun.security.util.ECParameters();
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   132
                    }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   133
                } else  if (type.equals("KeyPairGenerator")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   134
                    if (algo.equals("EC")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   135
                        return new ECKeyPairGenerator();
50053
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   136
                    } else if (algo.equals("XDH")) {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   137
                        return new XDHKeyPairGenerator();
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   138
                    } else if (algo.equals("X25519")) {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   139
                        return new XDHKeyPairGenerator.X25519();
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   140
                    } else if (algo.equals("X448")) {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   141
                        return new XDHKeyPairGenerator.X448();
31270
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   142
                    }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   143
                } else  if (type.equals("KeyAgreement")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   144
                    if (algo.equals("ECDH")) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   145
                        return new ECDHKeyAgreement();
50053
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   146
                    } else if (algo.equals("XDH")) {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   147
                        return new XDHKeyAgreement();
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   148
                    } else if (algo.equals("X25519")) {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   149
                        return new XDHKeyAgreement.X25519();
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   150
                    } else if (algo.equals("X448")) {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   151
                        return new XDHKeyAgreement.X448();
31270
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   152
                    }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   153
                }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   154
            } catch (Exception ex) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   155
                throw new NoSuchAlgorithmException("Error constructing " +
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   156
                    type + " for " + algo + " using SunEC", ex);
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   157
            }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   158
            throw new ProviderException("No impl for " + algo +
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   159
                " " + type);
3492
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   160
        }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   161
    }
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   162
31270
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   163
    public SunEC() {
40416
5d91b2fd668c 8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents: 33991
diff changeset
   164
        super("SunEC", PROVIDER_VER,
5d91b2fd668c 8130181: Deprecate java.security.Provider(String, double, String), add Provider(Strin
valeriep
parents: 33991
diff changeset
   165
            "Sun Elliptic Curve provider (EC, ECDSA, ECDH)");
31270
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   166
        AccessController.doPrivileged(new PrivilegedAction<Void>() {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   167
            public Void run() {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   168
                putEntries(useFullImplementation);
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   169
                return null;
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   170
            }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   171
        });
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   172
    }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   173
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   174
    void putEntries(boolean useFullImplementation) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   175
        HashMap<String, String> ATTRS = new HashMap<>(3);
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   176
        ATTRS.put("ImplementedIn", "Software");
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   177
        String ecKeyClasses = "java.security.interfaces.ECPublicKey" +
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   178
                 "|java.security.interfaces.ECPrivateKey";
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   179
        ATTRS.put("SupportedKeyClasses", ecKeyClasses);
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   180
        ATTRS.put("KeySize", "256");
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   181
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   182
        /*
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   183
         *  Key Factory engine
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   184
         */
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   185
        putService(new ProviderService(this, "KeyFactory",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   186
            "EC", "sun.security.ec.ECKeyFactory",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   187
            new String[] { "EllipticCurve" }, ATTRS));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   188
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   189
        /*
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   190
         * Algorithm Parameter engine
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   191
         */
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   192
        // "AlgorithmParameters.EC SupportedCurves" prop used by unit test
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   193
        boolean firstCurve = true;
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   194
        StringBuilder names = new StringBuilder();
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   195
        Pattern nameSplitPattern = Pattern.compile(CurveDB.SPLIT_PATTERN);
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   196
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   197
        Collection<? extends NamedCurve> supportedCurves =
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   198
            CurveDB.getSupportedCurves();
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   199
        for (NamedCurve namedCurve : supportedCurves) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   200
            if (!firstCurve) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   201
                names.append("|");
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   202
            } else {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   203
                firstCurve = false;
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   204
            }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   205
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   206
            names.append("[");
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   207
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   208
            String[] commonNames = nameSplitPattern.split(namedCurve.getName());
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   209
            for (String commonName : commonNames) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   210
                names.append(commonName.trim());
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   211
                names.append(",");
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   212
            }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   213
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   214
            names.append(namedCurve.getObjectId());
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   215
            names.append("]");
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   216
        }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   217
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   218
        HashMap<String, String> apAttrs = new HashMap<>(ATTRS);
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   219
        apAttrs.put("SupportedCurves", names.toString());
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   220
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   221
        putService(new ProviderService(this, "AlgorithmParameters",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   222
            "EC", "sun.security.util.ECParameters",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   223
            new String[] { "EllipticCurve", "1.2.840.10045.2.1", "OID.1.2.840.10045.2.1" },
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   224
            apAttrs));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   225
50053
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   226
        putXDHEntries();
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   227
31270
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   228
        /*
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   229
         * Register the algorithms below only when the full ECC implementation
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   230
         * is available
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   231
         */
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   232
        if (!useFullImplementation) {
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   233
            return;
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   234
        }
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   235
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   236
        /*
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   237
         * Signature engines
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   238
         */
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   239
        putService(new ProviderService(this, "Signature",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   240
            "NONEwithECDSA", "sun.security.ec.ECDSASignature$Raw",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   241
            null, ATTRS));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   242
        putService(new ProviderService(this, "Signature",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   243
            "SHA1withECDSA", "sun.security.ec.ECDSASignature$SHA1",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   244
            new String[] { "1.2.840.10045.4.1", "OID.1.2.840.10045.4.1" },
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   245
            ATTRS));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   246
        putService(new ProviderService(this, "Signature",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   247
            "SHA224withECDSA", "sun.security.ec.ECDSASignature$SHA224",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   248
            new String[] { "1.2.840.10045.4.3.1", "OID.1.2.840.10045.4.3.1"},
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   249
            ATTRS));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   250
        putService(new ProviderService(this, "Signature",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   251
            "SHA256withECDSA", "sun.security.ec.ECDSASignature$SHA256",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   252
            new String[] { "1.2.840.10045.4.3.2", "OID.1.2.840.10045.4.3.2"},
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   253
            ATTRS));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   254
        putService(new ProviderService(this, "Signature",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   255
            "SHA384withECDSA", "sun.security.ec.ECDSASignature$SHA384",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   256
            new String[] { "1.2.840.10045.4.3.3", "OID.1.2.840.10045.4.3.3" },
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   257
            ATTRS));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   258
        putService(new ProviderService(this, "Signature",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   259
            "SHA512withECDSA", "sun.security.ec.ECDSASignature$SHA512",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   260
            new String[] { "1.2.840.10045.4.3.4", "OID.1.2.840.10045.4.3.4" },
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   261
            ATTRS));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   262
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   263
        putService(new ProviderService(this, "Signature",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   264
             "NONEwithECDSAinP1363Format",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   265
             "sun.security.ec.ECDSASignature$RawinP1363Format"));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   266
        putService(new ProviderService(this, "Signature",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   267
             "SHA1withECDSAinP1363Format",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   268
             "sun.security.ec.ECDSASignature$SHA1inP1363Format"));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   269
        putService(new ProviderService(this, "Signature",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   270
             "SHA224withECDSAinP1363Format",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   271
             "sun.security.ec.ECDSASignature$SHA224inP1363Format"));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   272
        putService(new ProviderService(this, "Signature",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   273
             "SHA256withECDSAinP1363Format",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   274
             "sun.security.ec.ECDSASignature$SHA256inP1363Format"));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   275
        putService(new ProviderService(this, "Signature",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   276
            "SHA384withECDSAinP1363Format",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   277
            "sun.security.ec.ECDSASignature$SHA384inP1363Format"));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   278
        putService(new ProviderService(this, "Signature",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   279
            "SHA512withECDSAinP1363Format",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   280
            "sun.security.ec.ECDSASignature$SHA512inP1363Format"));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   281
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   282
        /*
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   283
         *  Key Pair Generator engine
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   284
         */
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   285
        putService(new ProviderService(this, "KeyPairGenerator",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   286
            "EC", "sun.security.ec.ECKeyPairGenerator",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   287
            new String[] { "EllipticCurve" }, ATTRS));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   288
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   289
        /*
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   290
         * Key Agreement engine
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   291
         */
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   292
        putService(new ProviderService(this, "KeyAgreement",
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   293
            "ECDH", "sun.security.ec.ECDHKeyAgreement", null, ATTRS));
e6470b24700d 7191662: JCE providers should be located via ServiceLoader
valeriep
parents: 27565
diff changeset
   294
    }
50053
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   295
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   296
    private void putXDHEntries() {
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   297
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   298
        HashMap<String, String> ATTRS = new HashMap<>(1);
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   299
        ATTRS.put("ImplementedIn", "Software");
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   300
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   301
        /* XDH does not require native implementation */
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   302
        putService(new ProviderService(this, "KeyFactory",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   303
            "XDH", "sun.security.ec.XDHKeyFactory", null, ATTRS));
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   304
        putService(new ProviderService(this, "KeyFactory",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   305
            "X25519", "sun.security.ec.XDHKeyFactory.X25519",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   306
            new String[]{"1.3.101.110", "OID.1.3.101.110"}, ATTRS));
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   307
        putService(new ProviderService(this, "KeyFactory",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   308
            "X448", "sun.security.ec.XDHKeyFactory.X448",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   309
            new String[]{"1.3.101.111", "OID.1.3.101.111"}, ATTRS));
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   310
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   311
        putService(new ProviderService(this, "KeyPairGenerator",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   312
            "XDH", "sun.security.ec.XDHKeyPairGenerator", null, ATTRS));
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   313
        putService(new ProviderService(this, "KeyPairGenerator",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   314
            "X25519", "sun.security.ec.XDHKeyPairGenerator.X25519",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   315
            new String[]{"1.3.101.110", "OID.1.3.101.110"}, ATTRS));
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   316
        putService(new ProviderService(this, "KeyPairGenerator",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   317
            "X448", "sun.security.ec.XDHKeyPairGenerator.X448",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   318
            new String[]{"1.3.101.111", "OID.1.3.101.111"}, ATTRS));
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   319
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   320
        putService(new ProviderService(this, "KeyAgreement",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   321
            "XDH", "sun.security.ec.XDHKeyAgreement", null, ATTRS));
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   322
        putService(new ProviderService(this, "KeyAgreement",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   323
            "X25519", "sun.security.ec.XDHKeyAgreement.X25519",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   324
            new String[]{"1.3.101.110", "OID.1.3.101.110"}, ATTRS));
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   325
        putService(new ProviderService(this, "KeyAgreement",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   326
            "X448", "sun.security.ec.XDHKeyAgreement.X448",
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   327
            new String[]{"1.3.101.111", "OID.1.3.101.111"}, ATTRS));
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   328
9bc1e6487cbb 8171277: Elliptic Curves for Security in Crypto
apetcher
parents: 47216
diff changeset
   329
    }
3492
e549cea58864 6840752: Provide out-of-the-box support for ECC algorithms
vinnie
parents:
diff changeset
   330
}