jdk/src/share/classes/sun/security/x509/AlgorithmId.java
author weijun
Fri, 04 Sep 2009 14:59:20 +0800
changeset 3717 c2ea049a4442
parent 2944 276b6d106714
child 4152 bc36a9f01ac6
permissions -rw-r--r--
6871847: AlgorithmId.get("SHA256withECDSA") not available Reviewed-by: vinnie
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
3717
c2ea049a4442 6871847: AlgorithmId.get("SHA256withECDSA") not available
weijun
parents: 2944
diff changeset
     2
 * Copyright 1996-2009 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.security.x509;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import sun.security.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * This class identifies algorithms, such as cryptographic transforms, each
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * of which may be associated with parameters.  Instances of this base class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * are used when this runtime environment has no special knowledge of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * algorithm type, and may also be used in other cases.  Equivalence is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * defined according to OID and (where relevant) parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <P>Subclasses may be used, for example when when the algorithm ID has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * associated parameters which some code (e.g. code using public keys) needs
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * to have parsed.  Two examples of such algorithms are Diffie-Hellman key
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * exchange, and the Digital Signature Standard Algorithm (DSS/DSA).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * <P>The OID constants defined in this class correspond to some widely
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * used algorithms, for which conventional string names have been defined.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * This class is not a general repository for OIDs, or for such string names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * Note that the mappings between algorithm IDs and algorithm names is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * not one-to-one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @author David Brownell
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @author Amit Kapoor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * @author Hemma Prafullchandra
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
public class AlgorithmId implements Serializable, DerEncoder {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    /** use serialVersionUID from JDK 1.1. for interoperability */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private static final long serialVersionUID = 7205873507486557157L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * The object identitifer being used for this algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    private ObjectIdentifier algid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    // The (parsed) parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private AlgorithmParameters algParams;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private boolean constructedFromDer = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * Parameters for this algorithm.  These are stored in unparsed
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * DER-encoded form; subclasses can be made to automaticaly parse
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * them so there is fast access to these parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    protected DerValue          params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * Constructs an algorithm ID which will be initialized
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * separately, for example by deserialization.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * @deprecated use one of the other constructors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public AlgorithmId() { }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     * Constructs a parameterless algorithm ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * @param oid the identifier for the algorithm
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public AlgorithmId(ObjectIdentifier oid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        algid = oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Constructs an algorithm ID with algorithm parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * @param oid the identifier for the algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * @param algparams the associated algorithm parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    public AlgorithmId(ObjectIdentifier oid, AlgorithmParameters algparams) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        algid = oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        algParams = algparams;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        constructedFromDer = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    private AlgorithmId(ObjectIdentifier oid, DerValue params)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        this.algid = oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        this.params = params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        if (this.params != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            decodeParams();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    protected void decodeParams() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        String algidString = algid.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            algParams = AlgorithmParameters.getInstance(algidString);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        } catch (NoSuchAlgorithmException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                // Try the internal EC code so that we can fully parse EC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                // keys even if the provider is not registered.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                // This code can go away once we have EC in the SUN provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                algParams = AlgorithmParameters.getInstance(algidString,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                                sun.security.ec.ECKeyFactory.ecInternalProvider);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            } catch (NoSuchAlgorithmException ee) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                 * This algorithm parameter type is not supported, so we cannot
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                 * parse the parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                algParams = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        // Decode (parse) the parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        algParams.init(params.toByteArray());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * Marshal a DER-encoded "AlgorithmID" sequence on the DER stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    public final void encode(DerOutputStream out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        derEncode(out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * DER encode this object onto an output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * Implements the <code>DerEncoder</code> interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * @param out
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * the output stream on which to write the DER encoding.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @exception IOException on encoding error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    public void derEncode (OutputStream out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        DerOutputStream bytes = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        DerOutputStream tmp = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        bytes.putOID(algid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        // Setup params from algParams since no DER encoding is given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        if (constructedFromDer == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
            if (algParams != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                params = new DerValue(algParams.getEncoded());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                params = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        if (params == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            // Changes backed out for compatibility with Solaris
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            // Several AlgorithmId should omit the whole parameter part when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            // it's NULL. They are ---
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            // rfc3370 2.1: Implementations SHOULD generate SHA-1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            // AlgorithmIdentifiers with absent parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            // rfc3447 C1: When id-sha1, id-sha256, id-sha384 and id-sha512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            // are used in an AlgorithmIdentifier the parameters (which are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            // optional) SHOULD be omitted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            // rfc3279 2.3.2: The id-dsa algorithm syntax includes optional
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            // domain parameters... When omitted, the parameters component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            // MUST be omitted entirely
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            // rfc3370 3.1: When the id-dsa-with-sha1 algorithm identifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            // is used, the AlgorithmIdentifier parameters field MUST be absent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            /*if (
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                algid.equals((Object)SHA_oid) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                algid.equals((Object)SHA256_oid) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                algid.equals((Object)SHA384_oid) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                algid.equals((Object)SHA512_oid) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                algid.equals((Object)DSA_oid) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                algid.equals((Object)sha1WithDSA_oid)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                ; // no parameter part encoded
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                bytes.putNull();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            }*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            bytes.putNull();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            bytes.putDerValue(params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        tmp.write(DerValue.tag_Sequence, bytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        out.write(tmp.toByteArray());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * Returns the DER-encoded X.509 AlgorithmId as a byte array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public final byte[] encode() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        DerOutputStream out = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        derEncode(out);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        return out.toByteArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * Returns the ISO OID for this algorithm.  This is usually converted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * to a string and used as part of an algorithm name, for example
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * "OID.1.3.14.3.2.13" style notation.  Use the <code>getName</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * call when you do not need to ensure cross-system portability
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * of algorithm names, or need a user friendly name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    public final ObjectIdentifier getOID () {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        return algid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * Returns a name for the algorithm which may be more intelligible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * to humans than the algorithm's OID, but which won't necessarily
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * be comprehensible on other systems.  For example, this might
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * return a name such as "MD5withRSA" for a signature algorithm on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * some systems.  It also returns names like "OID.1.2.3.4", when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * no particular name for the algorithm is known.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    public String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        String algName = nameTable.get(algid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        if (algName != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            return algName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        if ((params != null) && algid.equals(specifiedWithECDSA_oid)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                AlgorithmId paramsId =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                        AlgorithmId.parse(new DerValue(getEncodedParams()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                String paramsName = paramsId.getName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                if (paramsName.equals("SHA")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                    paramsName = "SHA1";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                algName = paramsName + "withECDSA";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                // ignore
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        return (algName == null) ? algid.toString() : algName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    public AlgorithmParameters getParameters() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        return algParams;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * Returns the DER encoded parameter, which can then be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * used to initialize java.security.AlgorithmParamters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * @return DER encoded parameters, or null not present.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    public byte[] getEncodedParams() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        return (params == null) ? null : params.toByteArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * Returns true iff the argument indicates the same algorithm
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * with the same parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    public boolean equals(AlgorithmId other) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        boolean paramsEqual =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
          (params == null ? other.params == null : params.equals(other.params));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        return (algid.equals(other.algid) && paramsEqual);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * Compares this AlgorithmID to another.  If algorithm parameters are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * available, they are compared.  Otherwise, just the object IDs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * for the algorithm are compared.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * @param other preferably an AlgorithmId, else an ObjectIdentifier
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    public boolean equals(Object other) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        if (this == other) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        if (other instanceof AlgorithmId) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            return equals((AlgorithmId) other);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        } else if (other instanceof ObjectIdentifier) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            return equals((ObjectIdentifier) other);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * Compares two algorithm IDs for equality.  Returns true iff
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * they are the same algorithm, ignoring algorithm parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    public final boolean equals(ObjectIdentifier id) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        return algid.equals(id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * Returns a hashcode for this AlgorithmId.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * @return a hashcode for this AlgorithmId.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        StringBuilder sbuf = new StringBuilder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        sbuf.append(algid.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        sbuf.append(paramsToString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        return sbuf.toString().hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * Provides a human-readable description of the algorithm parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * This may be redefined by subclasses which parse those parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    protected String paramsToString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        if (params == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
            return "";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        } else if (algParams != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            return algParams.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            return ", params unparsed";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * Returns a string describing the algorithm and its parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        return getName() + paramsToString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * Parse (unmarshal) an ID from a DER sequence input value.  This form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * parsing might be used when expanding a value which has already been
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * partially unmarshaled as a set or sequence member.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * @exception IOException on error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * @param val the input value, which contains the algid and, if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     *          there are any parameters, those parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * @return an ID for the algorithm.  If the system is configured
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     *          appropriately, this may be an instance of a class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     *          with some kind of special support for this algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     *          In that case, you may "narrow" the type of the ID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    public static AlgorithmId parse(DerValue val) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        if (val.tag != DerValue.tag_Sequence) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            throw new IOException("algid parse error, not a sequence");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
         * Get the algorithm ID and any parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        ObjectIdentifier        algid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        DerValue                params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        DerInputStream          in = val.toDerInputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        algid = in.getOID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        if (in.available() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            params = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            params = in.getDerValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            if (params.tag == DerValue.tag_Null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                if (params.length() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                    throw new IOException("invalid NULL");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                params = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
            if (in.available() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                throw new IOException("Invalid AlgorithmIdentifier: extra data");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        return new AlgorithmId(algid, params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * Returns one of the algorithm IDs most commonly associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * with this algorithm name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * @param algname the name being used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * @deprecated use the short get form of this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     * @exception NoSuchAlgorithmException on error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    @Deprecated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    public static AlgorithmId getAlgorithmId(String algname)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            throws NoSuchAlgorithmException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        return get(algname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * Returns one of the algorithm IDs most commonly associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * with this algorithm name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * @param algname the name being used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * @exception NoSuchAlgorithmException on error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    public static AlgorithmId get(String algname)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            throws NoSuchAlgorithmException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        ObjectIdentifier oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            oid = algOID(algname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            throw new NoSuchAlgorithmException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                ("Invalid ObjectIdentifier " + algname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        if (oid == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            throw new NoSuchAlgorithmException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                ("unrecognized algorithm name: " + algname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        return new AlgorithmId(oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * Returns one of the algorithm IDs most commonly associated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     * with this algorithm parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     * @param algparams the associated algorithm parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * @exception NoSuchAlgorithmException on error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    public static AlgorithmId get(AlgorithmParameters algparams)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            throws NoSuchAlgorithmException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        ObjectIdentifier oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        String algname = algparams.getAlgorithm();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            oid = algOID(algname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        } catch (IOException ioe) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            throw new NoSuchAlgorithmException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                ("Invalid ObjectIdentifier " + algname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        if (oid == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            throw new NoSuchAlgorithmException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                ("unrecognized algorithm name: " + algname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        return new AlgorithmId(oid, algparams);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * Translates from some common algorithm names to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * OID with which they're usually associated ... this mapping
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * is the reverse of the one below, except in those cases
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * where synonyms are supported or where a given algorithm
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * is commonly associated with multiple OIDs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * XXX This method needs to be enhanced so that we can also pass the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * scope of the algorithm name to it, e.g., the algorithm name "DSA"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * may have a different OID when used as a "Signature" algorithm than when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * used as a "KeyPairGenerator" algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
    private static ObjectIdentifier algOID(String name) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        // See if algname is in printable OID ("dot-dot") notation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        if (name.indexOf('.') != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
            if (name.startsWith("OID.")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                return new ObjectIdentifier(name.substring("OID.".length()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                return new ObjectIdentifier(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        // Digesting algorithms
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        if (name.equalsIgnoreCase("MD5")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
            return AlgorithmId.MD5_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        if (name.equalsIgnoreCase("MD2")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
            return AlgorithmId.MD2_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        if (name.equalsIgnoreCase("SHA") || name.equalsIgnoreCase("SHA1")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            || name.equalsIgnoreCase("SHA-1")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            return AlgorithmId.SHA_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        if (name.equalsIgnoreCase("SHA-256") ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
            name.equalsIgnoreCase("SHA256")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
            return AlgorithmId.SHA256_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        if (name.equalsIgnoreCase("SHA-384") ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            name.equalsIgnoreCase("SHA384")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
            return AlgorithmId.SHA384_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        if (name.equalsIgnoreCase("SHA-512") ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            name.equalsIgnoreCase("SHA512")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
            return AlgorithmId.SHA512_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        // Various public key algorithms
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        if (name.equalsIgnoreCase("RSA")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
            return AlgorithmId.RSAEncryption_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        if (name.equalsIgnoreCase("Diffie-Hellman")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
            || name.equalsIgnoreCase("DH")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
            return AlgorithmId.DH_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        if (name.equalsIgnoreCase("DSA")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            return AlgorithmId.DSA_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
        if (name.equalsIgnoreCase("EC")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
            return EC_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        // Common signature types
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
        if (name.equalsIgnoreCase("MD5withRSA")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
            || name.equalsIgnoreCase("MD5/RSA")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
            return AlgorithmId.md5WithRSAEncryption_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        if (name.equalsIgnoreCase("MD2withRSA")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
            || name.equalsIgnoreCase("MD2/RSA")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
            return AlgorithmId.md2WithRSAEncryption_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        if (name.equalsIgnoreCase("SHAwithDSA")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            || name.equalsIgnoreCase("SHA1withDSA")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            || name.equalsIgnoreCase("SHA/DSA")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
            || name.equalsIgnoreCase("SHA1/DSA")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
            || name.equalsIgnoreCase("DSAWithSHA1")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            || name.equalsIgnoreCase("DSS")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            || name.equalsIgnoreCase("SHA-1/DSA")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
            return AlgorithmId.sha1WithDSA_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        if (name.equalsIgnoreCase("SHA1WithRSA")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
            || name.equalsIgnoreCase("SHA1/RSA")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
            return AlgorithmId.sha1WithRSAEncryption_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        if (name.equalsIgnoreCase("SHA1withECDSA")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
                || name.equalsIgnoreCase("ECDSA")) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            return AlgorithmId.sha1WithECDSA_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
        }
3717
c2ea049a4442 6871847: AlgorithmId.get("SHA256withECDSA") not available
weijun
parents: 2944
diff changeset
   534
        if (name.equalsIgnoreCase("SHA224withECDSA")) {
c2ea049a4442 6871847: AlgorithmId.get("SHA256withECDSA") not available
weijun
parents: 2944
diff changeset
   535
            return AlgorithmId.sha224WithECDSA_oid;
c2ea049a4442 6871847: AlgorithmId.get("SHA256withECDSA") not available
weijun
parents: 2944
diff changeset
   536
        }
c2ea049a4442 6871847: AlgorithmId.get("SHA256withECDSA") not available
weijun
parents: 2944
diff changeset
   537
        if (name.equalsIgnoreCase("SHA256withECDSA")) {
c2ea049a4442 6871847: AlgorithmId.get("SHA256withECDSA") not available
weijun
parents: 2944
diff changeset
   538
            return AlgorithmId.sha256WithECDSA_oid;
c2ea049a4442 6871847: AlgorithmId.get("SHA256withECDSA") not available
weijun
parents: 2944
diff changeset
   539
        }
c2ea049a4442 6871847: AlgorithmId.get("SHA256withECDSA") not available
weijun
parents: 2944
diff changeset
   540
        if (name.equalsIgnoreCase("SHA384withECDSA")) {
c2ea049a4442 6871847: AlgorithmId.get("SHA256withECDSA") not available
weijun
parents: 2944
diff changeset
   541
            return AlgorithmId.sha384WithECDSA_oid;
c2ea049a4442 6871847: AlgorithmId.get("SHA256withECDSA") not available
weijun
parents: 2944
diff changeset
   542
        }
c2ea049a4442 6871847: AlgorithmId.get("SHA256withECDSA") not available
weijun
parents: 2944
diff changeset
   543
        if (name.equalsIgnoreCase("SHA512withECDSA")) {
c2ea049a4442 6871847: AlgorithmId.get("SHA256withECDSA") not available
weijun
parents: 2944
diff changeset
   544
            return AlgorithmId.sha512WithECDSA_oid;
c2ea049a4442 6871847: AlgorithmId.get("SHA256withECDSA") not available
weijun
parents: 2944
diff changeset
   545
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        // See if any of the installed providers supply a mapping from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        // the given algorithm name to an OID string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        String oidString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        if (!initOidTable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
            Provider[] provs = Security.getProviders();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            for (int i=0; i<provs.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                for (Enumeration<Object> enum_ = provs[i].keys();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                     enum_.hasMoreElements(); ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
                    String alias = (String)enum_.nextElement();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
                    int index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
                    if (alias.toUpperCase().startsWith("ALG.ALIAS") &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
                        (index=alias.toUpperCase().indexOf("OID.", 0)) != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                        index += "OID.".length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                        if (index == alias.length()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
                            // invalid alias entry
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                        if (oidTable == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                            oidTable = new HashMap<String,ObjectIdentifier>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
                        oidString = alias.substring(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
                        String stdAlgName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                            = provs[i].getProperty(alias).toUpperCase();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
                        if (oidTable.get(stdAlgName) == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                            oidTable.put(stdAlgName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
                                         new ObjectIdentifier(oidString));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            initOidTable = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
        return oidTable.get(name.toUpperCase());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    private static ObjectIdentifier oid(int ... values) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        return ObjectIdentifier.newInternal(values);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    private static boolean initOidTable = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    private static Map<String,ObjectIdentifier> oidTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    private static final Map<ObjectIdentifier,String> nameTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    /*****************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * HASHING ALGORITHMS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * Algorithm ID for the MD2 Message Digest Algorthm, from RFC 1319.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * OID = 1.2.840.113549.2.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
    public static final ObjectIdentifier MD2_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 2, 2});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * Algorithm ID for the MD5 Message Digest Algorthm, from RFC 1321.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * OID = 1.2.840.113549.2.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
    public static final ObjectIdentifier MD5_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 2, 5});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * Algorithm ID for the SHA1 Message Digest Algorithm, from FIPS 180-1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     * This is sometimes called "SHA", though that is often confusing since
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * many people refer to FIPS 180 (which has an error) as defining SHA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     * OID = 1.3.14.3.2.26. Old SHA-0 OID: 1.3.14.3.2.18.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    public static final ObjectIdentifier SHA_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    ObjectIdentifier.newInternal(new int[] {1, 3, 14, 3, 2, 26});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    public static final ObjectIdentifier SHA256_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
    ObjectIdentifier.newInternal(new int[] {2, 16, 840, 1, 101, 3, 4, 2, 1});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    public static final ObjectIdentifier SHA384_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    ObjectIdentifier.newInternal(new int[] {2, 16, 840, 1, 101, 3, 4, 2, 2});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    public static final ObjectIdentifier SHA512_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    ObjectIdentifier.newInternal(new int[] {2, 16, 840, 1, 101, 3, 4, 2, 3});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * COMMON PUBLIC KEY TYPES
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    private static final int DH_data[] = { 1, 2, 840, 113549, 1, 3, 1 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    private static final int DH_PKIX_data[] = { 1, 2, 840, 10046, 2, 1 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
    private static final int DSA_OIW_data[] = { 1, 3, 14, 3, 2, 12 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    private static final int DSA_PKIX_data[] = { 1, 2, 840, 10040, 4, 1 };
2944
276b6d106714 6570344: Invalid RSA OID in sun.security.x509.AlgorithmId
xuelei
parents: 2
diff changeset
   636
    private static final int RSA_data[] = { 2, 5, 8, 1, 1 };
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    private static final int RSAEncryption_data[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
                                 { 1, 2, 840, 113549, 1, 1, 1 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    public static final ObjectIdentifier DH_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    public static final ObjectIdentifier DH_PKIX_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    public static final ObjectIdentifier DSA_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    public static final ObjectIdentifier DSA_OIW_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    public static final ObjectIdentifier EC_oid = oid(1, 2, 840, 10045, 2, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    public static final ObjectIdentifier RSA_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
    public static final ObjectIdentifier RSAEncryption_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * COMMON SIGNATURE ALGORITHMS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
    private static final int md2WithRSAEncryption_data[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                                       { 1, 2, 840, 113549, 1, 1, 2 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    private static final int md5WithRSAEncryption_data[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
                                       { 1, 2, 840, 113549, 1, 1, 4 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    private static final int sha1WithRSAEncryption_data[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                                       { 1, 2, 840, 113549, 1, 1, 5 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    private static final int sha1WithRSAEncryption_OIW_data[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
                                       { 1, 3, 14, 3, 2, 29 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    private static final int sha256WithRSAEncryption_data[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
                                       { 1, 2, 840, 113549, 1, 1, 11 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    private static final int sha384WithRSAEncryption_data[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
                                       { 1, 2, 840, 113549, 1, 1, 12 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    private static final int sha512WithRSAEncryption_data[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
                                       { 1, 2, 840, 113549, 1, 1, 13 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    private static final int shaWithDSA_OIW_data[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
                                       { 1, 3, 14, 3, 2, 13 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    private static final int sha1WithDSA_OIW_data[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                                       { 1, 3, 14, 3, 2, 27 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    private static final int dsaWithSHA1_PKIX_data[] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                                       { 1, 2, 840, 10040, 4, 3 };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    public static final ObjectIdentifier md2WithRSAEncryption_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    public static final ObjectIdentifier md5WithRSAEncryption_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
    public static final ObjectIdentifier sha1WithRSAEncryption_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    public static final ObjectIdentifier sha1WithRSAEncryption_OIW_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    public static final ObjectIdentifier sha256WithRSAEncryption_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
    public static final ObjectIdentifier sha384WithRSAEncryption_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    public static final ObjectIdentifier sha512WithRSAEncryption_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    public static final ObjectIdentifier shaWithDSA_OIW_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    public static final ObjectIdentifier sha1WithDSA_OIW_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
    public static final ObjectIdentifier sha1WithDSA_oid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    public static final ObjectIdentifier sha1WithECDSA_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                                            oid(1, 2, 840, 10045, 4, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    public static final ObjectIdentifier sha224WithECDSA_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
                                            oid(1, 2, 840, 10045, 4, 3, 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    public static final ObjectIdentifier sha256WithECDSA_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
                                            oid(1, 2, 840, 10045, 4, 3, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    public static final ObjectIdentifier sha384WithECDSA_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
                                            oid(1, 2, 840, 10045, 4, 3, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    public static final ObjectIdentifier sha512WithECDSA_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
                                            oid(1, 2, 840, 10045, 4, 3, 4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    public static final ObjectIdentifier specifiedWithECDSA_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
                                            oid(1, 2, 840, 10045, 4, 3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * Algorithm ID for the PBE encryption algorithms from PKCS#5 and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * PKCS#12.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    public static final ObjectIdentifier pbeWithMD5AndDES_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
        ObjectIdentifier.newInternal(new int[]{1, 2, 840, 113549, 1, 5, 3});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    public static final ObjectIdentifier pbeWithMD5AndRC2_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 5, 6});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    public static final ObjectIdentifier pbeWithSHA1AndDES_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
        ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 5, 10});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
    public static final ObjectIdentifier pbeWithSHA1AndRC2_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 5, 11});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    public static ObjectIdentifier pbeWithSHA1AndDESede_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
        ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 3});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    public static ObjectIdentifier pbeWithSHA1AndRC2_40_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        ObjectIdentifier.newInternal(new int[] {1, 2, 840, 113549, 1, 12, 1, 6});
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * Note the preferred OIDs are named simply with no "OIW" or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * "PKIX" in them, even though they may point to data from these
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * specs; e.g. SHA_oid, DH_oid, DSA_oid, SHA1WithDSA_oid...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * Algorithm ID for Diffie Hellman Key agreement, from PKCS #3.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * Parameters include public values P and G, and may optionally specify
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * the length of the private key X.  Alternatively, algorithm parameters
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * may be derived from another source such as a Certificate Authority's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * OID = 1.2.840.113549.1.3.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        DH_oid = ObjectIdentifier.newInternal(DH_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     * Algorithm ID for the Diffie Hellman Key Agreement (DH), from RFC 3279.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     * Parameters may include public values P and G.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
     * OID = 1.2.840.10046.2.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        DH_PKIX_oid = ObjectIdentifier.newInternal(DH_PKIX_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     * Algorithm ID for the Digital Signing Algorithm (DSA), from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * NIST OIW Stable Agreements part 12.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     * Parameters may include public values P, Q, and G; or these may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * derived from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     * another source such as a Certificate Authority's certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     * OID = 1.3.14.3.2.12
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        DSA_OIW_oid = ObjectIdentifier.newInternal(DSA_OIW_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     * Algorithm ID for the Digital Signing Algorithm (DSA), from RFC 3279.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     * Parameters may include public values P, Q, and G; or these may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
     * derived from another source such as a Certificate Authority's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
     * certificate.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
     * OID = 1.2.840.10040.4.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        DSA_oid = ObjectIdentifier.newInternal(DSA_PKIX_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
     * Algorithm ID for RSA keys used for any purpose, as defined in X.509.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
     * The algorithm parameter is a single value, the number of bits in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     * public modulus.
2944
276b6d106714 6570344: Invalid RSA OID in sun.security.x509.AlgorithmId
xuelei
parents: 2
diff changeset
   760
     * OID = 2.5.8.1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
        RSA_oid = ObjectIdentifier.newInternal(RSA_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * Algorithm ID for RSA keys used with RSA encryption, as defined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     * in PKCS #1.  There are no parameters associated with this algorithm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * OID = 1.2.840.113549.1.1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
        RSAEncryption_oid = ObjectIdentifier.newInternal(RSAEncryption_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * Identifies a signing algorithm where an MD2 digest is encrypted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * using an RSA private key; defined in PKCS #1.  Use of this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * signing algorithm is discouraged due to MD2 vulnerabilities.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * OID = 1.2.840.113549.1.1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
        md2WithRSAEncryption_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
            ObjectIdentifier.newInternal(md2WithRSAEncryption_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * Identifies a signing algorithm where an MD5 digest is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     * encrypted using an RSA private key; defined in PKCS #1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     * OID = 1.2.840.113549.1.1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
        md5WithRSAEncryption_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
            ObjectIdentifier.newInternal(md5WithRSAEncryption_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * Identifies a signing algorithm where a SHA1 digest is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * encrypted using an RSA private key; defined by RSA DSI.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * OID = 1.2.840.113549.1.1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
        sha1WithRSAEncryption_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
            ObjectIdentifier.newInternal(sha1WithRSAEncryption_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     * Identifies a signing algorithm where a SHA1 digest is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * encrypted using an RSA private key; defined in NIST OIW.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     * OID = 1.3.14.3.2.29
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
        sha1WithRSAEncryption_OIW_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
            ObjectIdentifier.newInternal(sha1WithRSAEncryption_OIW_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * Identifies a signing algorithm where a SHA256 digest is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     * encrypted using an RSA private key; defined by PKCS #1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     * OID = 1.2.840.113549.1.1.11
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
        sha256WithRSAEncryption_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
            ObjectIdentifier.newInternal(sha256WithRSAEncryption_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
     * Identifies a signing algorithm where a SHA384 digest is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
     * encrypted using an RSA private key; defined by PKCS #1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     * OID = 1.2.840.113549.1.1.12
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
        sha384WithRSAEncryption_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
            ObjectIdentifier.newInternal(sha384WithRSAEncryption_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
     * Identifies a signing algorithm where a SHA512 digest is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     * encrypted using an RSA private key; defined by PKCS #1.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
     * OID = 1.2.840.113549.1.1.13
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
        sha512WithRSAEncryption_oid =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
            ObjectIdentifier.newInternal(sha512WithRSAEncryption_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * Identifies the FIPS 186 "Digital Signature Standard" (DSS), where a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     * SHA digest is signed using the Digital Signing Algorithm (DSA).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * This should not be used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * OID = 1.3.14.3.2.13
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
        shaWithDSA_OIW_oid = ObjectIdentifier.newInternal(shaWithDSA_OIW_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     * Identifies the FIPS 186 "Digital Signature Standard" (DSS), where a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * SHA1 digest is signed using the Digital Signing Algorithm (DSA).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     * OID = 1.3.14.3.2.27
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
        sha1WithDSA_OIW_oid = ObjectIdentifier.newInternal(sha1WithDSA_OIW_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     * Identifies the FIPS 186 "Digital Signature Standard" (DSS), where a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     * SHA1 digest is signed using the Digital Signing Algorithm (DSA).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     * OID = 1.2.840.10040.4.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        sha1WithDSA_oid = ObjectIdentifier.newInternal(dsaWithSHA1_PKIX_data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
        nameTable = new HashMap<ObjectIdentifier,String>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
        nameTable.put(MD5_oid, "MD5");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
        nameTable.put(MD2_oid, "MD2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
        nameTable.put(SHA_oid, "SHA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
        nameTable.put(SHA256_oid, "SHA256");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
        nameTable.put(SHA384_oid, "SHA384");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
        nameTable.put(SHA512_oid, "SHA512");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
        nameTable.put(RSAEncryption_oid, "RSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
        nameTable.put(RSA_oid, "RSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
        nameTable.put(DH_oid, "Diffie-Hellman");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
        nameTable.put(DH_PKIX_oid, "Diffie-Hellman");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
        nameTable.put(DSA_oid, "DSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
        nameTable.put(DSA_OIW_oid, "DSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
        nameTable.put(EC_oid, "EC");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
        nameTable.put(sha1WithECDSA_oid, "SHA1withECDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
        nameTable.put(sha224WithECDSA_oid, "SHA224withECDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
        nameTable.put(sha256WithECDSA_oid, "SHA256withECDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
        nameTable.put(sha384WithECDSA_oid, "SHA384withECDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
        nameTable.put(sha512WithECDSA_oid, "SHA512withECDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
        nameTable.put(md5WithRSAEncryption_oid, "MD5withRSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
        nameTable.put(md2WithRSAEncryption_oid, "MD2withRSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
        nameTable.put(sha1WithDSA_oid, "SHA1withDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
        nameTable.put(sha1WithDSA_OIW_oid, "SHA1withDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
        nameTable.put(shaWithDSA_OIW_oid, "SHA1withDSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
        nameTable.put(sha1WithRSAEncryption_oid, "SHA1withRSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
        nameTable.put(sha1WithRSAEncryption_OIW_oid, "SHA1withRSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
        nameTable.put(sha256WithRSAEncryption_oid, "SHA256withRSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
        nameTable.put(sha384WithRSAEncryption_oid, "SHA384withRSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
        nameTable.put(sha512WithRSAEncryption_oid, "SHA512withRSA");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
        nameTable.put(pbeWithMD5AndDES_oid, "PBEWithMD5AndDES");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
        nameTable.put(pbeWithMD5AndRC2_oid, "PBEWithMD5AndRC2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
        nameTable.put(pbeWithSHA1AndDES_oid, "PBEWithSHA1AndDES");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        nameTable.put(pbeWithSHA1AndRC2_oid, "PBEWithSHA1AndRC2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
        nameTable.put(pbeWithSHA1AndDESede_oid, "PBEWithSHA1AndDESede");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
        nameTable.put(pbeWithSHA1AndRC2_40_oid, "PBEWithSHA1AndRC2_40");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
}