--- /home/tromey/gnu/Nightly/classpath/classpath/gnu/java/security/provider/GnuDSAPrivateKey.java 2004-11-08 02:18:57.000000000 -0700 +++ gnu/java/security/provider/GnuDSAPrivateKey.java 2003-04-30 02:19:03.000000000 -0600 @@ -1,5 +1,5 @@ /* GnuDSAPrivateKey.java --- Gnu DSA Private Key - Copyright (C) 1999,2003,2004 Free Software Foundation, Inc. + Copyright (C) 1999 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -7,7 +7,7 @@ it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. - + GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU @@ -38,31 +38,19 @@ package gnu.java.security.provider; -import gnu.java.security.OID; -import gnu.java.security.der.DER; -import gnu.java.security.der.DERValue; -import gnu.java.security.der.DERWriter; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; - import java.math.BigInteger; - import java.security.interfaces.DSAPrivateKey; import java.security.interfaces.DSAParams; import java.security.spec.DSAParameterSpec; -import java.util.ArrayList; - public class GnuDSAPrivateKey implements DSAPrivateKey { - private byte[] encodedKey; BigInteger x; BigInteger p; BigInteger q; BigInteger g; - public GnuDSAPrivateKey(BigInteger x, BigInteger p, BigInteger q, BigInteger g ) + public GnuDSAPrivateKey(BigInteger x, BigInteger p, BigInteger q, BigInteger g ) { this.x = x; this.p = p; @@ -77,56 +65,12 @@ public String getFormat() { - return "PKCS#8"; + return null; } - /** - * Encodes this key as a PrivateKeyInfo, as described in - * PKCS #8. The ASN.1 specification for this structure is: - * - *
-   * PrivateKeyInfo ::= SEQUENCE {
-   *   version Version,
-   *   privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
-   *   privateKey PrivateKey,
-   *   attributes [0] IMPLICIT Attributes OPTIONAL }
-   *
-   * Version ::= INTEGER
-   *
-   * PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
-   *
-   * PrivateKey ::= OCTET STRING
-   *
-   * Attributes ::= SET OF Attribute
-   * 
- * - *

DSA private keys (in Classpath at least) have no attributes. - */ public byte[] getEncoded() { - if (encodedKey != null) - return (byte[]) encodedKey.clone(); - try - { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - ArrayList pki = new ArrayList(3); - pki.add(new DERValue(DER.INTEGER, BigInteger.ZERO)); - ArrayList algId = new ArrayList(2); - algId.add(new DERValue(DER.OBJECT_IDENTIFIER, - new OID("1.2.840.10040.4.1"))); - ArrayList algParams = new ArrayList(3); - algParams.add(new DERValue(DER.INTEGER, p)); - algParams.add(new DERValue(DER.INTEGER, q)); - algParams.add(new DERValue(DER.INTEGER, g)); - algId.add(new DERValue(DER.CONSTRUCTED|DER.SEQUENCE, algParams)); - pki.add(new DERValue(DER.OCTET_STRING, x.toByteArray())); - DERWriter.write(out, new DERValue(DER.CONSTRUCTED|DER.SEQUENCE, pki)); - return (byte[]) (encodedKey = out.toByteArray()).clone(); - } - catch (IOException ioe) - { - return null; - } + return null; } public DSAParams getParams() @@ -141,10 +85,7 @@ public String toString() { - return "GnuDSAPrivateKey: x=" - + (x != null ? x.toString(16) : "null") + " p=" - + (p != null ? p.toString(16) : "null") + " q=" - + (q != null ? q.toString(16) : "null") + " g=" - + (g != null ? g.toString(16) : "null"); + return "GnuDSAPrivateKey: x=" + x.toString(16) + " p=" + p.toString(16) + + " q=" + q.toString(16) + " g=" + g.toString(16); } }