jdk/src/share/classes/sun/security/rsa/RSAPrivateCrtKeyImpl.java
author wetmore
Fri, 22 Aug 2008 18:48:00 -0700
changeset 2596 a1964c157e68
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
6497740: Limit the size of RSA public keys Reviewed-by: andreas, valeriep, vinnie
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
     2
 * Copyright 2003-2008 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.rsa;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.math.BigInteger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.security.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.security.interfaces.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import sun.security.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.security.x509.AlgorithmId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.security.pkcs.PKCS8Key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * Key implementation for RSA private keys, CRT form. For non-CRT private
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * keys, see RSAPrivateKeyImpl. We need separate classes to ensure
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * correct behavior in instanceof checks, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * Note: RSA keys must be at least 512 bits long
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * @see RSAPrivateKeyImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @see RSAKeyFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * @since   1.5
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * @author  Andreas Sterbenz
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
public final class RSAPrivateCrtKeyImpl
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        extends PKCS8Key implements RSAPrivateCrtKey {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private static final long serialVersionUID = -1326088454257084918L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private BigInteger n;       // modulus
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private BigInteger e;       // public exponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    private BigInteger d;       // private exponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private BigInteger p;       // prime p
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private BigInteger q;       // prime q
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private BigInteger pe;      // prime exponent p
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private BigInteger qe;      // prime exponent q
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private BigInteger coeff;   // CRT coeffcient
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    // algorithmId used to identify RSA keys
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    final static AlgorithmId rsaId =
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        new AlgorithmId(AlgorithmId.RSAEncryption_oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * Generate a new key from its encoding. Returns a CRT key if possible
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * and a non-CRT key otherwise. Used by RSAKeyFactory.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    public static RSAPrivateKey newKey(byte[] encoded)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        RSAPrivateCrtKeyImpl key = new RSAPrivateCrtKeyImpl(encoded);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        if (key.getPublicExponent().signum() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
            // public exponent is missing, return a non-CRT key
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            return new RSAPrivateKeyImpl(
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
                key.getModulus(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                key.getPrivateExponent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            return key;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     * Construct a key from its encoding. Called from newKey above.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    RSAPrivateCrtKeyImpl(byte[] encoded) throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        decode(encoded);
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
    92
        RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * Construct a key from its components. Used by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * RSAKeyFactory and the RSAKeyPairGenerator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    RSAPrivateCrtKeyImpl(BigInteger n, BigInteger e, BigInteger d,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            BigInteger p, BigInteger q, BigInteger pe, BigInteger qe,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
            BigInteger coeff) throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        this.n = n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        this.e = e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        this.d = d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        this.p = p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        this.q = q;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        this.pe = pe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        this.qe = qe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        this.coeff = coeff;
2596
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   110
        RSAKeyFactory.checkRSAProviderKeyLengths(n.bitLength(), e);
a1964c157e68 6497740: Limit the size of RSA public keys
wetmore
parents: 2
diff changeset
   111
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        // generate the encoding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        algid = rsaId;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
            DerOutputStream out = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            out.putInteger(0); // version must be 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
            out.putInteger(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            out.putInteger(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
            out.putInteger(d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            out.putInteger(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            out.putInteger(q);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            out.putInteger(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            out.putInteger(qe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            out.putInteger(coeff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
            DerValue val =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                new DerValue(DerValue.tag_Sequence, out.toByteArray());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            key = val.toByteArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        } catch (IOException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            // should never occur
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            throw new InvalidKeyException(exc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    // see JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    public String getAlgorithm() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        return "RSA";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    // see JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public BigInteger getModulus() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        return n;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    // see JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    public BigInteger getPublicExponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        return e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    // see JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public BigInteger getPrivateExponent() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        return d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    // see JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    public BigInteger getPrimeP() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        return p;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    // see JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public BigInteger getPrimeQ() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        return q;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    // see JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    public BigInteger getPrimeExponentP() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        return pe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    // see JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    public BigInteger getPrimeExponentQ() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        return qe;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    // see JCA doc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    public BigInteger getCrtCoefficient() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        return coeff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * Parse the key. Called by PKCS8Key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    protected void parseKeyBits() throws InvalidKeyException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            DerInputStream in = new DerInputStream(key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            DerValue derValue = in.getDerValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            if (derValue.tag != DerValue.tag_Sequence) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                throw new IOException("Not a SEQUENCE");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            DerInputStream data = derValue.data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            int version = data.getInteger();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            if (version != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                throw new IOException("Version must be 0");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            n = getBigInteger(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            e = getBigInteger(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            d = getBigInteger(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            p = getBigInteger(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            q = getBigInteger(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            pe = getBigInteger(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            qe = getBigInteger(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            coeff = getBigInteger(data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            if (derValue.data.available() != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
                throw new IOException("Extra data available");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        } catch (IOException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
            throw new InvalidKeyException("Invalid RSA private key", e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * Read a BigInteger from the DerInputStream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    static BigInteger getBigInteger(DerInputStream data) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        BigInteger b = data.getBigInteger();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
         * Some implementations do not correctly encode ASN.1 INTEGER values
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
         * in 2's complement format, resulting in a negative integer when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
         * decoded. Correct the error by converting it to a positive integer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
         *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
         * See CR 6255949
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
         */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        if (b.signum() < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            b = new BigInteger(1, b.toByteArray());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        return b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    // return a string representation of this key for debugging
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        StringBuffer sb = new StringBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        sb.append("Sun RSA private CRT key, ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        sb.append(n.bitLength());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        sb.append(" bits\n  modulus:          ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        sb.append(n);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        sb.append("\n  public exponent:  ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        sb.append(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        sb.append("\n  private exponent: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        sb.append(d);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        sb.append("\n  prime p:          ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        sb.append(p);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        sb.append("\n  prime q:          ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        sb.append(q);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        sb.append("\n  prime exponent p: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        sb.append(pe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        sb.append("\n  prime exponent q: ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        sb.append(qe);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        sb.append("\n  crt coefficient:  ");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        sb.append(coeff);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        return sb.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
}