FileDocCategorySizeDatePackage
SubjectPublicKeyInfo.javaAPI DocAzureus 3.0.3.43261Tue Jun 08 05:12:56 BST 2004org.bouncycastle.asn1.x509

SubjectPublicKeyInfo

public class SubjectPublicKeyInfo extends Object implements org.bouncycastle.asn1.DEREncodable
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)

        Enumeration         e = seq.getObjects();

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

        return algId;
    
public org.bouncycastle.asn1.DERObjectgetDERObject()
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);
    
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.

        ByteArrayInputStream    bIn = new ByteArrayInputStream(keyData.getBytes());
        DERInputStream          dIn = new DERInputStream(bIn);

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

        return keyData;