FileDocCategorySizeDatePackage
SubjectPublicKeyInfo.javaAPI DocAndroid 1.5 API3365Wed May 06 22:41:06 BST 2009org.bouncycastle.asn1.x509

SubjectPublicKeyInfo

public class SubjectPublicKeyInfo extends org.bouncycastle.asn1.ASN1Encodable
The object that contains the public key stored in a certficate.

The getEncoded() method in the public keys in the JCE produces a DER encoded one of these.

Fields Summary
private AlgorithmIdentifier
algId
private org.bouncycastle.asn1.DERBitString
keyData
Constructors Summary
public SubjectPublicKeyInfo(AlgorithmIdentifier algId, org.bouncycastle.asn1.DEREncodable publicKey)

        this.keyData = new DERBitString(publicKey);
        this.algId = algId;
    
public SubjectPublicKeyInfo(AlgorithmIdentifier algId, byte[] publicKey)

        this.keyData = new DERBitString(publicKey);
        this.algId = algId;
    
public SubjectPublicKeyInfo(org.bouncycastle.asn1.ASN1Sequence seq)

        if (seq.size() != 2)
        {
            throw new IllegalArgumentException("Bad sequence size: "
                    + seq.size());
        }

        Enumeration         e = seq.getObjects();

        this.algId = AlgorithmIdentifier.getInstance(e.nextElement());
        this.keyData = DERBitString.getInstance(e.nextElement());
    
Methods Summary
public AlgorithmIdentifiergetAlgorithmId()

        return algId;
    
public static org.bouncycastle.asn1.x509.SubjectPublicKeyInfogetInstance(org.bouncycastle.asn1.ASN1TaggedObject obj, boolean explicit)

        return getInstance(ASN1Sequence.getInstance(obj, explicit));
    
public static org.bouncycastle.asn1.x509.SubjectPublicKeyInfogetInstance(java.lang.Object obj)

        if (obj instanceof SubjectPublicKeyInfo)
        {
            return (SubjectPublicKeyInfo)obj;
        }
        else if (obj instanceof ASN1Sequence)
        {
            return new SubjectPublicKeyInfo((ASN1Sequence)obj);
        }

        throw new IllegalArgumentException("unknown object in factory");
    
public org.bouncycastle.asn1.DERObjectgetPublicKey()
for when the public key is an encoded object - if the bitstring can't be decoded this routine throws an IOException.

exception
IOException - if the bit string doesn't represent a DER encoded object.

        ASN1InputStream         aIn = new ASN1InputStream(keyData.getBytes());

        return aIn.readObject();
    
public org.bouncycastle.asn1.DERBitStringgetPublicKeyData()
for when the public key is raw bits...

        return keyData;
    
public org.bouncycastle.asn1.DERObjecttoASN1Object()
Produce an object suitable for an ASN1OutputStream.
SubjectPublicKeyInfo ::= SEQUENCE {
algorithm AlgorithmIdentifier,
publicKey BIT STRING }

        ASN1EncodableVector  v = new ASN1EncodableVector();

        v.add(algId);
        v.add(keyData);

        return new DERSequence(v);