org.bouncycastle.asn1.x509

## Class SubjectPublicKeyInfo

- java.lang.Object
- - org.bouncycastle.asn1.ASN1Object
  - - org.bouncycastle.asn1.x509.SubjectPublicKeyInfo

- All Implemented Interfaces:
    ASN1Encodable, Encodable

      public class SubjectPublicKeyInfo
      extends ASN1Object

  The object that contains the public key stored in a certificate.

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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SubjectPublicKeyInfo(AlgorithmIdentifier algId, ASN1BitString publicKey)`
    `SubjectPublicKeyInfo(AlgorithmIdentifier algId, ASN1Encodable publicKey)`
    `SubjectPublicKeyInfo(AlgorithmIdentifier algId, byte[] publicKey)`
    `SubjectPublicKeyInfo(ASN1Sequence seq)` Deprecated. use SubjectPublicKeyInfo.getInstance()

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `AlgorithmIdentifier` | `getAlgorithm()`
    `AlgorithmIdentifier` | `getAlgorithmId()` Deprecated. use getAlgorithm()
    `static SubjectPublicKeyInfo` | `getInstance(ASN1TaggedObject obj, boolean explicit)`
    `static SubjectPublicKeyInfo` | `getInstance(java.lang.Object obj)`
    `ASN1Primitive` | `getPublicKey()` Deprecated. use parsePublicKey
    `ASN1BitString` | `getPublicKeyData()` for when the public key is raw bits.
    `ASN1Primitive` | `parsePublicKey()` for when the public key is an encoded object - if the bitstring can't be decoded this routine throws an IOException.
    `ASN1Primitive` | `toASN1Primitive()` Produce an object suitable for an ASN1OutputStream.

    - ### Methods inherited from class org.bouncycastle.asn1.ASN1Object

      `encodeTo, encodeTo, equals, getEncoded, getEncoded, hasEncodedTagValue, hashCode`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SubjectPublicKeyInfo

          public SubjectPublicKeyInfo(AlgorithmIdentifier algId,
                                      ASN1BitString publicKey)

    - #### SubjectPublicKeyInfo

          public SubjectPublicKeyInfo(AlgorithmIdentifier algId,
                                      ASN1Encodable publicKey)
                               throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### SubjectPublicKeyInfo

          public SubjectPublicKeyInfo(AlgorithmIdentifier algId,
                                      byte[] publicKey)

    - #### SubjectPublicKeyInfo

          @Deprecated
          public SubjectPublicKeyInfo(ASN1Sequence seq)

      Deprecated. use SubjectPublicKeyInfo.getInstance()

  - ### Method Detail

    - #### getInstance

          public static SubjectPublicKeyInfo getInstance(ASN1TaggedObject obj,
                                                         boolean explicit)

    - #### getInstance

          public static SubjectPublicKeyInfo getInstance(java.lang.Object obj)

    - #### getAlgorithm

          public AlgorithmIdentifier getAlgorithm()

    - #### getAlgorithmId

          @Deprecated
          public AlgorithmIdentifier getAlgorithmId()

      Deprecated. use getAlgorithm()
      Returns:
        alg ID.

    - #### parsePublicKey

          public ASN1Primitive parsePublicKey()
                                       throws java.io.IOException

      for when the public key is an encoded object - if the bitstring can't be decoded this routine throws an IOException.
      Returns:
        the public key as an ASN.1 primitive.
      Throws:
        `java.io.IOException` - - if the bit string doesn't represent a DER encoded object.

    - #### getPublicKey

          @Deprecated
          public ASN1Primitive getPublicKey()
                                                 throws java.io.IOException

      Deprecated. use parsePublicKey
      for when the public key is an encoded object - if the bitstring can't be decoded this routine throws an IOException.
      Returns:
        the public key as an ASN.1 primitive.
      Throws:
        `java.io.IOException` - - if the bit string doesn't represent a DER encoded object.

    - #### getPublicKeyData

          public ASN1BitString getPublicKeyData()

      for when the public key is raw bits.
      Returns:
        the public key as the raw bit string...

    - #### toASN1Primitive

          public ASN1Primitive toASN1Primitive()

      Produce an object suitable for an ASN1OutputStream.

           SubjectPublicKeyInfo ::= SEQUENCE {
                                    algorithm AlgorithmIdentifier,
                                    publicKey BIT STRING }

      Specified by:
        `toASN1Primitive` in interface `ASN1Encodable`
      Specified by:
        `toASN1Primitive` in class `ASN1Object`
      Returns:
        a primitive representation of this object.