jdk/src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java
author redestad
Tue, 03 May 2016 15:50:54 +0200
changeset 37781 71ed5645f17c
parent 37593 824750ada3d6
permissions -rw-r--r--
8155775: Re-examine naming of privileged methods to access System properties Reviewed-by: mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
     2
 * Copyright (c) 2003, 2011, Oracle and/or its affiliates. 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
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2596
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2596
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
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
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2596
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2596
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2596
diff changeset
    23
 * questions.
2
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.rsa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.math.BigInteger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.security.interfaces.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.security.spec.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    34
import sun.security.action.GetPropertyAction;
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    35
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * KeyFactory for RSA keys. Keys must be instances of PublicKey or PrivateKey
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * and getAlgorithm() must return "RSA". For such keys, it supports conversion
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * between the following:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * For public keys:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *  . PublicKey with an X.509 encoding
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *  . RSAPublicKey
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *  . RSAPublicKeySpec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *  . X509EncodedKeySpec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * For private keys:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 *  . PrivateKey with a PKCS#8 encoding
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *  . RSAPrivateKey
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *  . RSAPrivateCrtKey
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *  . RSAPrivateKeySpec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *  . RSAPrivateCrtKeySpec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *  . PKCS8EncodedKeySpec
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * (of course, CRT variants only for CRT keys)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * Note: as always, RSA keys should be at least 512 bits long
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * @since   1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * @author  Andreas Sterbenz
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
public final class RSAKeyFactory extends KeyFactorySpi {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 30374
diff changeset
    63
    private static final Class<?> rsaPublicKeySpecClass =
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
                                                RSAPublicKeySpec.class;
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 30374
diff changeset
    65
    private static final Class<?> rsaPrivateKeySpecClass =
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                                                RSAPrivateKeySpec.class;
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 30374
diff changeset
    67
    private static final Class<?> rsaPrivateCrtKeySpecClass =
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                                                RSAPrivateCrtKeySpec.class;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 30374
diff changeset
    70
    private static final Class<?> x509KeySpecClass  = X509EncodedKeySpec.class;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 30374
diff changeset
    71
    private static final Class<?> pkcs8KeySpecClass = PKCS8EncodedKeySpec.class;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 30374
diff changeset
    73
    public static final int MIN_MODLEN = 512;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 30374
diff changeset
    74
    public static final int MAX_MODLEN = 16384;
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    75
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    76
    /*
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    77
     * If the modulus length is above this value, restrict the size of
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    78
     * the exponent to something that can be reasonably computed.  We
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    79
     * could simply hardcode the exp len to something like 64 bits, but
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    80
     * this approach allows flexibility in case impls would like to use
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    81
     * larger module and exponent values.
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    82
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 30374
diff changeset
    83
    public static final int MAX_MODLEN_RESTRICT_EXP = 3072;
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 30374
diff changeset
    84
    public static final int MAX_RESTRICTED_EXPLEN = 64;
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    85
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    86
    private static final boolean restrictExpLen =
37781
71ed5645f17c 8155775: Re-examine naming of privileged methods to access System properties
redestad
parents: 37593
diff changeset
    87
        "true".equalsIgnoreCase(GetPropertyAction.privilegedGetProperty(
37593
824750ada3d6 8154231: Simplify access to System properties from JDK code
redestad
parents: 32649
diff changeset
    88
                "sun.security.rsa.restrictRSAExponent", "true"));
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    89
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    // instance used for static translateKey();
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 30374
diff changeset
    91
    private static final RSAKeyFactory INSTANCE = new RSAKeyFactory();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    public RSAKeyFactory() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        // empty
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    98
     * Static method to convert Key into an instance of RSAPublicKeyImpl
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    99
     * or RSAPrivate(Crt)KeyImpl. If the key is not an RSA key or cannot be
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   100
     * used, throw an InvalidKeyException.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * Used by RSASignature and RSACipher.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    public static RSAKey toRSAKey(Key key) throws InvalidKeyException {
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   105
        if ((key instanceof RSAPrivateKeyImpl) ||
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   106
            (key instanceof RSAPrivateCrtKeyImpl) ||
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   107
            (key instanceof RSAPublicKeyImpl)) {
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   108
            return (RSAKey)key;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            return (RSAKey)INSTANCE.engineTranslateKey(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   114
    /*
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   115
     * Single test entry point for all of the mechanisms in the SunRsaSign
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   116
     * provider (RSA*KeyImpls).  All of the tests are the same.
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   117
     *
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   118
     * For compatibility, we round up to the nearest byte here:
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   119
     * some Key impls might pass in a value within a byte of the
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   120
     * real value.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     */
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   122
    static void checkRSAProviderKeyLengths(int modulusLen, BigInteger exponent)
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   123
            throws InvalidKeyException {
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   124
        checkKeyLengths(((modulusLen + 7) & ~7), exponent,
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   125
            RSAKeyFactory.MIN_MODLEN, Integer.MAX_VALUE);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   129
     * Check the length of an RSA key modulus/exponent to make sure it
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   130
     * is not too short or long.  Some impls have their own min and
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   131
     * max key sizes that may or may not match with a system defined value.
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   132
     *
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   133
     * @param modulusLen the bit length of the RSA modulus.
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   134
     * @param exponent the RSA exponent
30374
2abaf49910ea 8079478: some docs cleanup for sun.security
avstepan
parents: 25859
diff changeset
   135
     * @param minModulusLen if {@literal > 0}, check to see if modulusLen is at
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   136
     *        least this long, otherwise unused.
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   137
     * @param maxModulusLen caller will allow this max number of bits.
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   138
     *        Allow the smaller of the system-defined maximum and this param.
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   139
     *
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   140
     * @throws InvalidKeyException if any of the values are unacceptable.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     */
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   142
     public static void checkKeyLengths(int modulusLen, BigInteger exponent,
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   143
            int minModulusLen, int maxModulusLen) throws InvalidKeyException {
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   144
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   145
        if ((minModulusLen > 0) && (modulusLen < (minModulusLen))) {
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   146
            throw new InvalidKeyException( "RSA keys must be at least " +
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   147
                minModulusLen + " bits long");
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   148
        }
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   149
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   150
        // Even though our policy file may allow this, we don't want
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   151
        // either value (mod/exp) to be too big.
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   152
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   153
        int maxLen = Math.min(maxModulusLen, MAX_MODLEN);
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   154
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   155
        // If a RSAPrivateKey/RSAPublicKey, make sure the
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   156
        // modulus len isn't too big.
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   157
        if (modulusLen > maxLen) {
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   158
            throw new InvalidKeyException(
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   159
                "RSA keys must be no longer than " + maxLen + " bits");
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   160
        }
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   161
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   162
        // If a RSAPublicKey, make sure the exponent isn't too big.
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   163
        if (restrictExpLen && (exponent != null) &&
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   164
                (modulusLen > MAX_MODLEN_RESTRICT_EXP) &&
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   165
                (exponent.bitLength() > MAX_RESTRICTED_EXPLEN)) {
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   166
            throw new InvalidKeyException(
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   167
                "RSA exponents can be no longer than " +
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   168
                MAX_RESTRICTED_EXPLEN + " bits " +
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   169
                " if modulus is greater than " +
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   170
                MAX_MODLEN_RESTRICT_EXP + " bits");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Translate an RSA key into a SunRsaSign RSA key. If conversion is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * not possible, throw an InvalidKeyException.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * See also JCA doc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    protected Key engineTranslateKey(Key key) throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        if (key == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            throw new InvalidKeyException("Key must not be null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        String keyAlg = key.getAlgorithm();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        if (keyAlg.equals("RSA") == false) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            throw new InvalidKeyException("Not an RSA key: " + keyAlg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        if (key instanceof PublicKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            return translatePublicKey((PublicKey)key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        } else if (key instanceof PrivateKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            return translatePrivateKey((PrivateKey)key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            throw new InvalidKeyException("Neither a public nor a private key");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    // see JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    protected PublicKey engineGeneratePublic(KeySpec keySpec)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            throws InvalidKeySpecException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            return generatePublic(keySpec);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        } catch (InvalidKeySpecException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        } catch (GeneralSecurityException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            throw new InvalidKeySpecException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    // see JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    protected PrivateKey engineGeneratePrivate(KeySpec keySpec)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
            throws InvalidKeySpecException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
            return generatePrivate(keySpec);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        } catch (InvalidKeySpecException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        } catch (GeneralSecurityException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            throw new InvalidKeySpecException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    // internal implementation of translateKey() for public keys. See JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    private PublicKey translatePublicKey(PublicKey key)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        if (key instanceof RSAPublicKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            if (key instanceof RSAPublicKeyImpl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                return key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
            RSAPublicKey rsaKey = (RSAPublicKey)key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                return new RSAPublicKeyImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                    rsaKey.getModulus(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                    rsaKey.getPublicExponent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            } catch (RuntimeException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                // catch providers that incorrectly implement RSAPublicKey
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
                throw new InvalidKeyException("Invalid key", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        } else if ("X.509".equals(key.getFormat())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            byte[] encoded = key.getEncoded();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            return new RSAPublicKeyImpl(encoded);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            throw new InvalidKeyException("Public keys must be instance "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                + "of RSAPublicKey or have X.509 encoding");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    // internal implementation of translateKey() for private keys. See JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    private PrivateKey translatePrivateKey(PrivateKey key)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        if (key instanceof RSAPrivateCrtKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            if (key instanceof RSAPrivateCrtKeyImpl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                return key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            RSAPrivateCrtKey rsaKey = (RSAPrivateCrtKey)key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                return new RSAPrivateCrtKeyImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                    rsaKey.getModulus(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                    rsaKey.getPublicExponent(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                    rsaKey.getPrivateExponent(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                    rsaKey.getPrimeP(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
                    rsaKey.getPrimeQ(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                    rsaKey.getPrimeExponentP(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                    rsaKey.getPrimeExponentQ(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                    rsaKey.getCrtCoefficient()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            } catch (RuntimeException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                // catch providers that incorrectly implement RSAPrivateCrtKey
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                throw new InvalidKeyException("Invalid key", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        } else if (key instanceof RSAPrivateKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            if (key instanceof RSAPrivateKeyImpl) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                return key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            RSAPrivateKey rsaKey = (RSAPrivateKey)key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                return new RSAPrivateKeyImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                    rsaKey.getModulus(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                    rsaKey.getPrivateExponent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            } catch (RuntimeException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                // catch providers that incorrectly implement RSAPrivateKey
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
                throw new InvalidKeyException("Invalid key", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        } else if ("PKCS#8".equals(key.getFormat())) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            byte[] encoded = key.getEncoded();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            return RSAPrivateCrtKeyImpl.newKey(encoded);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            throw new InvalidKeyException("Private keys must be instance "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                + "of RSAPrivate(Crt)Key or have PKCS#8 encoding");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    // internal implementation of generatePublic. See JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    private PublicKey generatePublic(KeySpec keySpec)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            throws GeneralSecurityException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        if (keySpec instanceof X509EncodedKeySpec) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            X509EncodedKeySpec x509Spec = (X509EncodedKeySpec)keySpec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            return new RSAPublicKeyImpl(x509Spec.getEncoded());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        } else if (keySpec instanceof RSAPublicKeySpec) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
            RSAPublicKeySpec rsaSpec = (RSAPublicKeySpec)keySpec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            return new RSAPublicKeyImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                rsaSpec.getModulus(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                rsaSpec.getPublicExponent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
            throw new InvalidKeySpecException("Only RSAPublicKeySpec "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                + "and X509EncodedKeySpec supported for RSA public keys");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    // internal implementation of generatePrivate. See JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    private PrivateKey generatePrivate(KeySpec keySpec)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            throws GeneralSecurityException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        if (keySpec instanceof PKCS8EncodedKeySpec) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            PKCS8EncodedKeySpec pkcsSpec = (PKCS8EncodedKeySpec)keySpec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            return RSAPrivateCrtKeyImpl.newKey(pkcsSpec.getEncoded());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        } else if (keySpec instanceof RSAPrivateCrtKeySpec) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
            RSAPrivateCrtKeySpec rsaSpec = (RSAPrivateCrtKeySpec)keySpec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            return new RSAPrivateCrtKeyImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                rsaSpec.getModulus(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                rsaSpec.getPublicExponent(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                rsaSpec.getPrivateExponent(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                rsaSpec.getPrimeP(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                rsaSpec.getPrimeQ(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                rsaSpec.getPrimeExponentP(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                rsaSpec.getPrimeExponentQ(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                rsaSpec.getCrtCoefficient()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
            );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        } else if (keySpec instanceof RSAPrivateKeySpec) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            RSAPrivateKeySpec rsaSpec = (RSAPrivateKeySpec)keySpec;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            return new RSAPrivateKeyImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                rsaSpec.getModulus(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                rsaSpec.getPrivateExponent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
            );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            throw new InvalidKeySpecException("Only RSAPrivate(Crt)KeySpec "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                + "and PKCS8EncodedKeySpec supported for RSA private keys");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    protected <T extends KeySpec> T engineGetKeySpec(Key key, Class<T> keySpec)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            throws InvalidKeySpecException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            // convert key to one of our keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
            // this also verifies that the key is a valid RSA key and ensures
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            // that the encoding is X.509/PKCS#8 for public/private keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            key = engineTranslateKey(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        } catch (InvalidKeyException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
            throw new InvalidKeySpecException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        if (key instanceof RSAPublicKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            RSAPublicKey rsaKey = (RSAPublicKey)key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            if (rsaPublicKeySpecClass.isAssignableFrom(keySpec)) {
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   353
                return keySpec.cast(new RSAPublicKeySpec(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                    rsaKey.getModulus(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                    rsaKey.getPublicExponent()
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   356
                ));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            } else if (x509KeySpecClass.isAssignableFrom(keySpec)) {
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   358
                return keySpec.cast(new X509EncodedKeySpec(key.getEncoded()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                throw new InvalidKeySpecException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                        ("KeySpec must be RSAPublicKeySpec or "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                        + "X509EncodedKeySpec for RSA public keys");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        } else if (key instanceof RSAPrivateKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            if (pkcs8KeySpecClass.isAssignableFrom(keySpec)) {
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   366
                return keySpec.cast(new PKCS8EncodedKeySpec(key.getEncoded()));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            } else if (rsaPrivateCrtKeySpecClass.isAssignableFrom(keySpec)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
                if (key instanceof RSAPrivateCrtKey) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
                    RSAPrivateCrtKey crtKey = (RSAPrivateCrtKey)key;
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   370
                    return keySpec.cast(new RSAPrivateCrtKeySpec(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                        crtKey.getModulus(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                        crtKey.getPublicExponent(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                        crtKey.getPrivateExponent(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                        crtKey.getPrimeP(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                        crtKey.getPrimeQ(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                        crtKey.getPrimeExponentP(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
                        crtKey.getPrimeExponentQ(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
                        crtKey.getCrtCoefficient()
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   379
                    ));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                    throw new InvalidKeySpecException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                    ("RSAPrivateCrtKeySpec can only be used with CRT keys");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
            } else if (rsaPrivateKeySpecClass.isAssignableFrom(keySpec)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                RSAPrivateKey rsaKey = (RSAPrivateKey)key;
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   386
                return keySpec.cast(new RSAPrivateKeySpec(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                    rsaKey.getModulus(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                    rsaKey.getPrivateExponent()
10336
0bb1999251f8 7064075: Security libraries don't build with javac -Xlint:all,-deprecation -Werror
jjg
parents: 5506
diff changeset
   389
                ));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                throw new InvalidKeySpecException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                        ("KeySpec must be RSAPrivate(Crt)KeySpec or "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                        + "PKCS8EncodedKeySpec for RSA private keys");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            // should not occur, caught in engineTranslateKey()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            throw new InvalidKeySpecException("Neither public nor private key");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
}