home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 1999 April / DPPCPRO0499.ISO / April / Notes / 50b2wic.exe / DATA1.CAB / NotesProgramFilesJavaSupport / rt.jar / sun / security / provider / DSAPrivateKey.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-04-23  |  2.4 KB  |  74 lines

  1. package sun.security.provider;
  2.  
  3. import java.io.IOException;
  4. import java.io.Serializable;
  5. import java.math.BigInteger;
  6. import java.security.InvalidKeyException;
  7. import java.security.ProviderException;
  8. import java.security.interfaces.DSAParams;
  9. import sun.security.pkcs.PKCS8Key;
  10. import sun.security.util.DerInputStream;
  11. import sun.security.util.DerValue;
  12. import sun.security.x509.AlgIdDSA;
  13.  
  14. public final class DSAPrivateKey extends PKCS8Key implements java.security.interfaces.DSAPrivateKey, Serializable {
  15.    // $FF: renamed from: x java.math.BigInteger
  16.    private BigInteger field_0;
  17.  
  18.    public DSAPrivateKey() {
  19.    }
  20.  
  21.    public DSAPrivateKey(byte[] var1) throws InvalidKeyException {
  22.       ((PKCS8Key)this).decode(var1);
  23.    }
  24.  
  25.    public DSAPrivateKey(BigInteger var1, BigInteger var2, BigInteger var3, BigInteger var4) throws InvalidKeyException {
  26.       super.algid = new AlgIdDSA(var2, var3, var4);
  27.  
  28.       try {
  29.          super.key = (new DerValue((byte)2, var1.toByteArray())).toByteArray();
  30.          ((PKCS8Key)this).encode();
  31.       } catch (IOException var6) {
  32.          throw new InvalidKeyException("counld not DER encode y: " + ((Throwable)var6).getMessage());
  33.       }
  34.  
  35.       this.field_0 = var1;
  36.    }
  37.  
  38.    public DSAParams getParams() {
  39.       try {
  40.          if (super.algid instanceof DSAParams) {
  41.             return (DSAParams)super.algid;
  42.          } else {
  43.             byte[] var1 = super.algid.encode();
  44.             super.algid = new AlgIdDSA(var1);
  45.             return (DSAParams)super.algid;
  46.          }
  47.       } catch (IOException var2) {
  48.          throw new ProviderException("unable to parse algorithm params.");
  49.       }
  50.    }
  51.  
  52.    public BigInteger getX() {
  53.       return this.field_0;
  54.    }
  55.  
  56.    protected void parseKeyBits() throws InvalidKeyException {
  57.       DerInputStream var1 = new DerInputStream(super.key);
  58.  
  59.       try {
  60.          this.field_0 = var1.getInteger().toBigInteger();
  61.       } catch (IOException var3) {
  62.          throw new InvalidKeyException(((Throwable)var3).getMessage());
  63.       }
  64.    }
  65.  
  66.    byte[] getEncodedKey() throws InvalidKeyException {
  67.       return ((PKCS8Key)this).getEncoded();
  68.    }
  69.  
  70.    public String toString() {
  71.       return "Sun DSA Private Key \nparameters:" + super.algid + "\nx: " + this.field_0.toString(16) + "\n";
  72.    }
  73. }
  74.