1 /*
   2  * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.security.ec;
  27 
  28 import java.util.Map;
  29 
  30 /**
  31  * Defines the entries of the SunEC provider.
  32  *
  33  * @since 1.7
  34  */
  35 final class SunECEntries {
  36 
  37     private SunECEntries() {
  38         // empty
  39     }
  40 
  41     static void putEntries(Map<Object, Object> map,
  42         boolean useFullImplementation) {
  43 
  44         /*
  45          *  Key Factory engine
  46          */
  47         map.put("KeyFactory.EC", "sun.security.ec.ECKeyFactory");
  48         map.put("Alg.Alias.KeyFactory.EllipticCurve", "EC");
  49 
  50         map.put("KeyFactory.EC ImplementedIn", "Software");
  51 
  52         /*
  53          * Algorithm Parameter engine
  54          */
  55         map.put("AlgorithmParameters.EC", "sun.security.ec.ECParameters");
  56         map.put("Alg.Alias.AlgorithmParameters.EllipticCurve", "EC");
  57 
  58         map.put("AlgorithmParameters.EC KeySize", "256");
  59 
  60         map.put("AlgorithmParameters.EC ImplementedIn", "Software");
  61 
  62         map.put("AlgorithmParameters.EC SupportedCurves",
  63 
  64             // A list comprising lists of curve names and object identifiers.
  65             // '[' ( <curve-name> ',' )+ <curve-object-identifier> ']' '|'
  66 
  67             // SEC 2 prime curves
  68             "[secp112r1,1.3.132.0.6]|" +
  69             "[secp112r2,1.3.132.0.7]|" +
  70             "[secp128r1,1.3.132.0.28]|" +
  71             "[secp128r2,1.3.132.0.29]|" +
  72             "[secp160k1,1.3.132.0.9]|" +
  73             "[secp160r1,1.3.132.0.8]|" +
  74             "[secp160r2,1.3.132.0.30]|" +
  75             "[secp192k1,1.3.132.0.31]|" +
  76             "[secp192r1,NIST P-192,X9.62 prime192v1,1.2.840.10045.3.1.1]|" +
  77             "[secp224k1,1.3.132.0.32]|" +
  78             "[secp224r1,NIST P-224,1.3.132.0.33]|" +
  79             "[secp256k1,1.3.132.0.10]|" +
  80             "[secp256r1,NIST P-256,X9.62 prime256v1,1.2.840.10045.3.1.7]|" +
  81             "[secp384r1,NIST P-384,1.3.132.0.34]|" +
  82             "[secp521r1,NIST P-521,1.3.132.0.35]|" +
  83 
  84             // ANSI X9.62 prime curves
  85             "[X9.62 prime192v2,1.2.840.10045.3.1.2]|" +
  86             "[X9.62 prime192v3,1.2.840.10045.3.1.3]|" +
  87             "[X9.62 prime239v1,1.2.840.10045.3.1.4]|" +
  88             "[X9.62 prime239v2,1.2.840.10045.3.1.5]|" +
  89             "[X9.62 prime239v3,1.2.840.10045.3.1.6]|" +
  90 
  91             // SEC 2 binary curves
  92             "[sect113r1,1.3.132.0.4]|" +
  93             "[sect113r2,1.3.132.0.5]|" +
  94             "[sect131r1,1.3.132.0.22]|" +
  95             "[sect131r2,1.3.132.0.23]|" +
  96             "[sect163k1,NIST K-163,1.3.132.0.1]|" +
  97             "[sect163r1,1.3.132.0.2]|" +
  98             "[sect163r2,NIST B-163,1.3.132.0.15]|" +
  99             "[sect193r1,1.3.132.0.24]|" +
 100             "[sect193r2,1.3.132.0.25]|" +
 101             "[sect233k1,NIST K-233,1.3.132.0.26]|" +
 102             "[sect233r1,NIST B-233,1.3.132.0.27]|" +
 103             "[sect239k1,1.3.132.0.3]|" +
 104             "[sect283k1,NIST K-283,1.3.132.0.16]|" +
 105             "[sect283r1,NIST B-283,1.3.132.0.17]|" +
 106             "[sect409k1,NIST K-409,1.3.132.0.36]|" +
 107             "[sect409r1,NIST B-409,1.3.132.0.37]|" +
 108             "[sect571k1,NIST K-571,1.3.132.0.38]|" +
 109             "[sect571r1,NIST B-571,1.3.132.0.39]|" +
 110 
 111             // ANSI X9.62 binary curves
 112             "[X9.62 c2tnb191v1,1.2.840.10045.3.0.5]|" +
 113             "[X9.62 c2tnb191v2,1.2.840.10045.3.0.6]|" +
 114             "[X9.62 c2tnb191v3,1.2.840.10045.3.0.7]|" +
 115             "[X9.62 c2tnb239v1,1.2.840.10045.3.0.11]|" +
 116             "[X9.62 c2tnb239v2,1.2.840.10045.3.0.12]|" +
 117             "[X9.62 c2tnb239v3,1.2.840.10045.3.0.13]|" +
 118             "[X9.62 c2tnb359v1,1.2.840.10045.3.0.18]|" +
 119             "[X9.62 c2tnb431r1,1.2.840.10045.3.0.20]");
 120 
 121         /*
 122          * Register the algorithms below only when the full ECC implementation
 123          * is available
 124          */
 125         if (!useFullImplementation) {
 126             return;
 127         }
 128 
 129         /*
 130          * Signature engines
 131          */
 132         map.put("Signature.NONEwithECDSA",
 133             "sun.security.ec.ECDSASignature$Raw");
 134         map.put("Signature.SHA1withECDSA",
 135             "sun.security.ec.ECDSASignature$SHA1");
 136         map.put("Signature.SHA256withECDSA",
 137             "sun.security.ec.ECDSASignature$SHA256");
 138         map.put("Signature.SHA384withECDSA",
 139             "sun.security.ec.ECDSASignature$SHA384");
 140         map.put("Signature.SHA512withECDSA",
 141             "sun.security.ec.ECDSASignature$SHA512");
 142 
 143         String ecKeyClasses = "java.security.interfaces.ECPublicKey" +
 144                 "|java.security.interfaces.ECPrivateKey";
 145         map.put("Signature.NONEwithECDSA SupportedKeyClasses", ecKeyClasses);
 146         map.put("Signature.SHA1withECDSA SupportedKeyClasses", ecKeyClasses);
 147         map.put("Signature.SHA256withECDSA SupportedKeyClasses", ecKeyClasses);
 148         map.put("Signature.SHA384withECDSA SupportedKeyClasses", ecKeyClasses);
 149         map.put("Signature.SHA512withECDSA SupportedKeyClasses", ecKeyClasses);
 150 
 151         map.put("Signature.SHA1withECDSA KeySize", "256");
 152 
 153         map.put("Signature.NONEwithECDSA ImplementedIn", "Software");
 154         map.put("Signature.SHA1withECDSA ImplementedIn", "Software");
 155         map.put("Signature.SHA256withECDSA ImplementedIn", "Software");
 156         map.put("Signature.SHA384withECDSA ImplementedIn", "Software");
 157         map.put("Signature.SHA512withECDSA ImplementedIn", "Software");
 158 
 159         /*
 160          *  Key Pair Generator engine
 161          */
 162         map.put("KeyPairGenerator.EC", "sun.security.ec.ECKeyPairGenerator");
 163         map.put("Alg.Alias.KeyPairGenerator.EllipticCurve", "EC");
 164 
 165         map.put("KeyPairGenerator.EC KeySize", "256");
 166 
 167         map.put("KeyPairGenerator.EC ImplementedIn", "Software");
 168 
 169         /*
 170          * Key Agreement engine
 171          */
 172         map.put("KeyAgreement.ECDH", "sun.security.ec.ECDHKeyAgreement");
 173 
 174         map.put("KeyAgreement.ECDH SupportedKeyClasses", ecKeyClasses);
 175 
 176         map.put("KeyAgreement.ECDH ImplementedIn", "Software");
 177     }
 178 }