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

JCERSAPrivateKey

public class JCERSAPrivateKey extends Object implements RSAPrivateKey, org.bouncycastle.jce.interfaces.PKCS12BagAttributeCarrier

Fields Summary
protected BigInteger
modulus
protected BigInteger
privateExponent
private Hashtable
pkcs12Attributes
private Vector
pkcs12Ordering
Constructors Summary
protected JCERSAPrivateKey()


     
    
    
JCERSAPrivateKey(org.bouncycastle.crypto.params.RSAKeyParameters key)

        this.modulus = key.getModulus();
        this.privateExponent = key.getExponent();
    
JCERSAPrivateKey(RSAPrivateKeySpec spec)

        this.modulus = spec.getModulus();
        this.privateExponent = spec.getPrivateExponent();
    
JCERSAPrivateKey(RSAPrivateKey key)

        this.modulus = key.getModulus();
        this.privateExponent = key.getPrivateExponent();
    
Methods Summary
public booleanequals(java.lang.Object o)

        if (!(o instanceof RSAPrivateKey))
        {
            return false;
        }

        if (o == this)
        {
            return true;
        }

        RSAPrivateKey key = (RSAPrivateKey)o;

        return getModulus().equals(key.getModulus())
            && getPrivateExponent().equals(key.getPrivateExponent());
    
public java.lang.StringgetAlgorithm()

        return "RSA";
    
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 null;
    
public java.lang.StringgetFormat()

        return "NULL";
    
public java.math.BigIntegergetModulus()

        return modulus;
    
public java.math.BigIntegergetPrivateExponent()

        return privateExponent;
    
public inthashCode()

        return getModulus().hashCode() ^ getPrivateExponent().hashCode();
    
private voidreadObject(java.io.ObjectInputStream in)

        this.modulus = (BigInteger)in.readObject();

        Object  obj = in.readObject();

        if (obj instanceof Hashtable)
        {
            this.pkcs12Attributes = (Hashtable)obj;
            this.pkcs12Ordering = (Vector)in.readObject();
        }
        else
        {
            this.pkcs12Attributes = new Hashtable();
            this.pkcs12Ordering = new Vector();

            ASN1InputStream         aIn = new ASN1InputStream((byte[])obj);

            DERObjectIdentifier    oid;

            while ((oid = (DERObjectIdentifier)aIn.readObject()) != null)
            {
                this.setBagAttribute(oid, aIn.readObject());
            }
        }

        this.privateExponent = (BigInteger)in.readObject();
    
public voidsetBagAttribute(org.bouncycastle.asn1.DERObjectIdentifier oid, org.bouncycastle.asn1.DEREncodable attribute)

        pkcs12Attributes.put(oid, attribute);
        pkcs12Ordering.addElement(oid);
    
private voidwriteObject(java.io.ObjectOutputStream out)

        out.writeObject(modulus);

        if (pkcs12Ordering.size() == 0)
        {
            out.writeObject(pkcs12Attributes);
            out.writeObject(pkcs12Ordering);
        }
        else
        {
            ByteArrayOutputStream   bOut = new ByteArrayOutputStream();
            ASN1OutputStream        aOut = new ASN1OutputStream(bOut);

            Enumeration             e = this.getBagAttributeKeys();

            while (e.hasMoreElements())
            {
                DEREncodable    oid = (DEREncodable)e.nextElement();

                aOut.writeObject(oid);
                aOut.writeObject(pkcs12Attributes.get(oid));
            }

            out.writeObject(bOut.toByteArray());
        }

        out.writeObject(privateExponent);