FileDocCategorySizeDatePackage
JDKDSAPrivateKey.javaAPI DocAndroid 1.5 API3889Wed May 06 22:41:06 BST 2009org.bouncycastle.jce.provider

JDKDSAPrivateKey

public class JDKDSAPrivateKey extends Object implements DSAPrivateKey, org.bouncycastle.jce.interfaces.PKCS12BagAttributeCarrier

Fields Summary
BigInteger
x
DSAParams
dsaSpec
private Hashtable
pkcs12Attributes
private Vector
pkcs12Ordering
Constructors Summary
protected JDKDSAPrivateKey()


     
    
    
JDKDSAPrivateKey(DSAPrivateKey key)

        this.x = key.getX();
        this.dsaSpec = key.getParams();
    
JDKDSAPrivateKey(DSAPrivateKeySpec spec)

        this.x = spec.getX();
        this.dsaSpec = new DSAParameterSpec(spec.getP(), spec.getQ(), spec.getG());
    
JDKDSAPrivateKey(org.bouncycastle.asn1.pkcs.PrivateKeyInfo info)

        DSAParameter    params = new DSAParameter((ASN1Sequence)info.getAlgorithmId().getParameters());
        DERInteger      derX = (DERInteger)info.getPrivateKey();

        this.x = derX.getValue();
        this.dsaSpec = new DSAParameterSpec(params.getP(), params.getQ(), params.getG());
    
JDKDSAPrivateKey(org.bouncycastle.crypto.params.DSAPrivateKeyParameters params)

        this.x = params.getX();
        this.dsaSpec = new DSAParameterSpec(params.getParameters().getP(), params.getParameters().getQ(), params.getParameters().getG());
    
Methods Summary
public booleanequals(java.lang.Object o)

        if (!(o instanceof DSAPrivateKey))
        {
            return false;
        }
        
        DSAPrivateKey other = (DSAPrivateKey)o;
        
        return this.getX().equals(other.getX()) 
            && this.getParams().getG().equals(other.getParams().getG()) 
            && this.getParams().getP().equals(other.getParams().getP()) 
            && this.getParams().getQ().equals(other.getParams().getQ());
    
public java.lang.StringgetAlgorithm()

        return "DSA";
    
public org.bouncycastle.asn1.DEREncodablegetBagAttribute(org.bouncycastle.asn1.DERObjectIdentifier oid)

        return (DEREncodable)pkcs12Attributes.get(oid);
    
public java.util.EnumerationgetBagAttributeKeys()

        return pkcs12Ordering.elements();
    
public byte[]getEncoded()
Return a PKCS8 representation of the key. The sequence returned represents a full PrivateKeyInfo object.

return
a PKCS8 representation of the key.

        PrivateKeyInfo          info = new PrivateKeyInfo(new AlgorithmIdentifier(X9ObjectIdentifiers.id_dsa, new DSAParameter(dsaSpec.getP(), dsaSpec.getQ(), dsaSpec.getG()).getDERObject()), new DERInteger(getX()));

        return info.getDEREncoded();
    
public java.lang.StringgetFormat()
return the encoding format we produce in getEncoded().

return
the string "PKCS#8"

        return "PKCS#8";
    
public java.security.interfaces.DSAParamsgetParams()

        return dsaSpec;
    
public java.math.BigIntegergetX()

        return x;
    
public voidsetBagAttribute(org.bouncycastle.asn1.DERObjectIdentifier oid, org.bouncycastle.asn1.DEREncodable attribute)

        pkcs12Attributes.put(oid, attribute);
        pkcs12Ordering.addElement(oid);