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

JCERSAPublicKey

public class JCERSAPublicKey extends Object implements RSAPublicKey

Fields Summary
private BigInteger
modulus
private BigInteger
publicExponent
Constructors Summary
JCERSAPublicKey(org.bouncycastle.crypto.params.RSAKeyParameters key)

        this.modulus = key.getModulus();
        this.publicExponent = key.getExponent();
    
JCERSAPublicKey(RSAPublicKeySpec spec)

        this.modulus = spec.getModulus();
        this.publicExponent = spec.getPublicExponent();
    
JCERSAPublicKey(RSAPublicKey key)

        this.modulus = key.getModulus();
        this.publicExponent = key.getPublicExponent();
    
JCERSAPublicKey(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo info)

        try
        {
            RSAPublicKeyStructure   pubKey = new RSAPublicKeyStructure((ASN1Sequence)info.getPublicKey());

            this.modulus = pubKey.getModulus();
            this.publicExponent = pubKey.getPublicExponent();
        }
        catch (IOException e)
        {
            throw new IllegalArgumentException("invalid info structure in RSA public key");
        }
    
Methods Summary
public booleanequals(java.lang.Object o)

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

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

        RSAPublicKey key = (RSAPublicKey)o;

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

        return "RSA";
    
public byte[]getEncoded()

        // BEGIN android-changed
        SubjectPublicKeyInfo    info = new SubjectPublicKeyInfo(new AlgorithmIdentifier(PKCSObjectIdentifiers.rsaEncryption, DERNull.THE_ONE), new RSAPublicKeyStructure(getModulus(), getPublicExponent()).getDERObject());
        // END android-changed

        return info.getDEREncoded();
    
public java.lang.StringgetFormat()

        return "X.509";
    
public java.math.BigIntegergetModulus()
return the modulus.

return
the modulus.

        return modulus;
    
public java.math.BigIntegergetPublicExponent()
return the public exponent.

return
the public exponent.

        return publicExponent;
    
public java.lang.StringtoString()

        StringBuffer    buf = new StringBuffer();
        String          nl = System.getProperty("line.separator");

        buf.append("RSA Public Key").append(nl);
        buf.append("            modulus: ").append(this.getModulus().toString(16)).append(nl);
        buf.append("    public exponent: ").append(this.getPublicExponent().toString(16)).append(nl);

        return buf.toString();