ASN1Object (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.asn1

## Class ASN1Object

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

- All Implemented Interfaces:
    ASN1Encodable, Encodable
  Direct Known Subclasses:
    AccessDescription, Accuracy, AdditionalInformationSyntax, Admissions, AdmissionSyntax, AlgorithmIdentifier, AltSignatureAlgorithm, AltSignatureValue, ArchiveTimeStamp, ArchiveTimeStampChain, ArchiveTimeStampSequence, ASN1Primitive, AttCertIssuer, AttCertValidityPeriod, Attribute, Attribute, Attribute, AttributeCertificate, AttributeCertificateInfo, Attributes, AttributeTypeAndValue, AttributeTypeAndValue, AttrOrOID, AuthenticatedData, AuthenticatedSafe, AuthEnvelopedData, AuthorityInformationAccess, AuthorityKeyIdentifier, BasicConstraints, BasicOCSPResponse, BinaryTime, BiometricData, BodyPartID, BodyPartList, BodyPartPath, BodyPartReference, CAKeyUpdAnnContent, CAST5CBCParameters, CCMParameters, CertBag, CertConfirmContent, CertDiscoveryMethod, CertEtcToken, CertHash, CertId, CertID, Certificate, CertificateBody, CertificateHolderAuthorization, CertificateList, CertificatePair, CertificatePolicies, CertificationRequest, CertificationRequest, CertificationRequestInfo, CertifiedKeyPair, CertOrEncCert, CertPolicyId, CertRepMessage, CertReqMessages, CertReqMsg, CertReqTemplateContent, CertRequest, CertResponse, CertStatus, CertStatus, CertTemplate, Challenge, Challenge.Rand, CMCEPrivateKey, CMCEPublicKey, CMCFailInfo, CMCPublicationInfo, CMCStatus, CMCStatusInfo, CMCStatusInfo.OtherInfo, CMCStatusInfoV2, CMCUnsignedData, CMPCertificate, CMSAlgorithmProtection, CMSORIforKEMOtherInfo, CommitmentTypeIndication, CommitmentTypeQualifier, CompleteRevocationRefs, CompressedData, ContentHints, ContentIdentifier, ContentInfo, ContentInfo, Controls, ControlsProcessed, CRLAnnContent, CRLBag, CRLDistPoint, CrlID, CrlIdentifier, CrlListID, CRLNumber, CrlOcspRef, CRLReason, CRLSource, CRLStatus, CrlValidatedID, CryptoInfos, CscaMasterList, CsrAttrs, CVCertificate, CVCertificateRequest, Data, DataGroupHash, DeclarationOfMajority, DecryptedPOP, DeltaCertificateDescriptor, DHBMParameter, DHDomainParameters, DHParameter, DHPublicKey, DhSigStatic, DHValidationParms, DigestedData, DigestInfo, DirectoryString, DisplayText, DistributionPoint, DistributionPointName, DomainParameters, DSAParameter, DSTU4145BinaryField, DSTU4145ECBinary, DSTU4145Params, DSTU4145PublicKey, DVCSCertInfo, DVCSErrorNotice, DVCSRequest, DVCSRequestInformation, DVCSResponse, DVCSTime, ECCCMSSharedInfo, ECGOST3410ParamSetParameters, ECPrivateKey, ECPrivateKeyStructure, EDIPartyName, ElGamalParameter, EncKeyWithID, EncryptedContentInfo, EncryptedData, EncryptedData, EncryptedKey, EncryptedObjectStoreData, EncryptedPOP, EncryptedPrivateKeyData, EncryptedPrivateKeyInfo, EncryptedSecretKeyData, EncryptedValue, EncryptionInfo, EncryptionScheme, EnvelopedData, ErrorMsgContent, ESSCertID, ESSCertIDv2, EstIdentityLinking, Evidence, EvidenceRecord, ExtendedFailInfo, ExtendedKeyUsage, Extension, ExtensionReq, Extensions, ExternalValue, FalconPrivateKey, FalconPublicKey, GCMParameters, GeneralName, GeneralNames, GeneralSubtree, GenericHybridParameters, GenMsgContent, GenRepContent, GetCert, GetCRL, Gost2814789EncryptedKey, Gost2814789KeyWrapParameters, GOST28147Parameters, GOST3410ParamSetParameters, GOST3410PublicKeyAlgParameters, GostR3410KeyTransport, GostR3410TransportParameters, Holder, IDEACBCPar, IdentityProofV2, IetfAttrSyntax, InfoTypeAndValue, Iso4217CurrencyCode, IssuerAndSerialNumber, IssuerAndSerialNumber, IssuerSerial, IssuingDistributionPoint, KEKIdentifier, KEKRecipientInfo, KemBMParameter, KemCiphertextInfo, KemOtherInfo, KEMRecipientInfo, KeyAgreeRecipientIdentifier, KeyAgreeRecipientInfo, KeyDerivationFunc, KeyPurposeId, KeyRecRepContent, KeySpecificInfo, KeyTransRecipientInfo, KeyUsage, KMACwithSHAKE128_params, KMACwithSHAKE256_params, LDSSecurityObject, LDSVersionInfo, LinkedCertificate, LraPopWitness, MacData, MessageImprint, MetaData, ModCertTemplate, MonetaryLimit, MonetaryValue, MQVuserKeyingMaterial, MTCCertificationAuthority, NameConstraints, NameOrPseudonym, NamingAuthority, NoticeReference, ObjectData, ObjectDataSequence, ObjectDigestInfo, ObjectStore, ObjectStoreData, ObjectStoreIntegrityCheck, OcspIdentifier, OcspListID, OCSPRequest, OCSPResponse, OcspResponsesID, OCSPResponseStatus, OOBCertHash, OptionalValidity, OriginatorIdentifierOrKey, OriginatorInfo, OriginatorPublicKey, OtherCertID, OtherHash, OtherHashAlgAndValue, OtherInfo, OtherKeyAttribute, OtherMsg, OtherName, OtherRecipientInfo, OtherRevocationInfoFormat, OtherRevRefs, OtherRevVals, OtherSigningCertificate, OtherStatusInfo, OtpChallenge, ParSet, PartialHashtree, PasswordRecipientInfo, PathProcInput, PBEParameter, PBES2Parameters, PBKDF2Params, PbkdKeyData, PbkdMacIntegrityCheck, PBMAC1Params, PBMParameter, PendInfo, PersonalData, Pfx, PKCS12PBEParams, PKIArchiveOptions, PKIBody, PKIConfirmContent, PKIData, PKIFreeText, PKIHeader, PKIMessage, PKIMessages, PKIPublicationInfo, PKIResponse, PKIStatus, PKIStatusInfo, PKMACValue, PolicyConstraints, PolicyInformation, PolicyMappings, PolicyQualifierInfo, PollRepContent, PollReqContent, PopLinkWitnessV2, POPODecKeyChallContent, POPODecKeyRespContent, POPOPrivKey, POPOSigningKey, POPOSigningKeyInput, PrivateKeyInfo, PrivateKeyPossessionStatement, PrivateKeyStatement, PrivateKeyUsagePeriod, ProcurationSyntax, ProfessionInfo, ProofOfPossession, ProtectedPart, PublicKeyAndChallenge, PublicKeyDataObject, PublishTrustAnchors, QCStatement, QcType, RC2CBCParameter, RDN, RecipientEncryptedKey, RecipientIdentifier, RecipientInfo, RecipientKeyIdentifier, RelatedCertificate, RelatedCertificateDescriptor, Request, RequestedCertificate, RequesterCertificate, ResponderID, ResponseBytes, ResponseData, Restriction, RevAnnContent, RevDetails, RevocationChallenge, RevocationValues, RevokedInfo, RevokeRequest, RevRepContent, RevReqContent, RoleSyntax, RootCaKeyUpdateContent, RSAESOAEPparams, RsaKemParameters, RSAPrivateKey, RSAPrivateKeyStructure, RSAPublicKey, RSAPublicKeyStructure, RSASSAPSSparams, SABERPrivateKey, SABERPublicKey, SafeBag, ScryptParams, SCVPReqRes, SecretBag, SecretKeyData, SemanticsInformation, ServiceLocator, ServiceType, Signature, SignatureCheck, SignaturePolicyId, SignaturePolicyIdentifier, SignedData, SignedData, SignedPublicKeyAndChallenge, SignerAttribute, SignerIdentifier, SignerInfo, SignerInfo, SignerLocation, SigningCertificate, SigningCertificateV2, SigPolicyQualifierInfo, SigPolicyQualifiers, SinglePubInfo, SingleResponse, SMIMECapabilities, SMIMECapability, SPHINCS256KeyParams, SPHINCSPLUSPrivateKey, SPHINCSPLUSPublicKey, SPUserNotice, SubjectAltPublicKeyInfo, SubjectDirectoryAttributes, SubjectKeyIdentifier, SubjectPublicKeyInfo, TaggedAttribute, TaggedCertificationRequest, TaggedContentInfo, TaggedRequest, Target, TargetEtcChain, TargetInformation, Targets, TBSCertificate, TBSCertificateLogEntry, TBSCertificateStructure, TBSCertList, TBSCertList.CRLEntry, TBSRequest, Time, Time, TimeStampAndCRL, TimeStampedData, TimeStampReq, TimeStampRequest, TimeStampResp, TimeStampTokenEvidence, TSTInfo, TypeOfBiometricData, UnsignedInteger, UserNotice, V2Form, ValidationParams, Validity, X500Name, X509CertificateStructure, X509Extensions, X509Name, X962Parameters, X9Curve, X9ECParameters, X9ECPoint, X9FieldElement, X9FieldID, XMSSKeyParams, XMSSMTKeyParams, XMSSMTPrivateKey, XMSSMTPublicKey, XMSSPrivateKey, XMSSPublicKey

      public abstract class ASN1Object
      extends java.lang.Object
      implements ASN1Encodable, Encodable

  Base class for defining an ASN.1 object.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ASN1Object()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `encodeTo(java.io.OutputStream output)`
    `void` | `encodeTo(java.io.OutputStream output, java.lang.String encoding)`
    `boolean` | `equals(java.lang.Object o)`
    `byte[]` | `getEncoded()` Return the default BER or DER encoding for this object.
    `byte[]` | `getEncoded(java.lang.String encoding)` Return either the default for "BER" or a DER encoding if "DER" is specified.
    `protected static boolean` | `hasEncodedTagValue(java.lang.Object obj, int tagValue)` Return true if obj is a byte array and represents an object with the given tag value.
    `int` | `hashCode()`
    `abstract ASN1Primitive` | `toASN1Primitive()` Method providing a primitive representation of this object suitable for encoding.

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

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

- - ### Constructor Detail

    - #### ASN1Object

          public ASN1Object()

  - ### Method Detail

    - #### encodeTo

          public void encodeTo(java.io.OutputStream output)
                        throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### encodeTo

          public void encodeTo(java.io.OutputStream output,
                               java.lang.String encoding)
                        throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### getEncoded

          public byte[] getEncoded()
                            throws java.io.IOException

      Return the default BER or DER encoding for this object.
      Specified by:
        `getEncoded` in interface `Encodable`
      Returns:
        BER/DER byte encoded object.
      Throws:
        `java.io.IOException` - on encoding error.

    - #### getEncoded

          public byte[] getEncoded(java.lang.String encoding)
                            throws java.io.IOException

      Return either the default for "BER" or a DER encoding if "DER" is specified.
      Parameters:
        `encoding` - name of encoding to use.
      Returns:
        byte encoded object.
      Throws:
        `java.io.IOException` - on encoding error.

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### equals

          public boolean equals(java.lang.Object o)

      Overrides:
        `equals` in class `java.lang.Object`

    - #### hasEncodedTagValue

          protected static boolean hasEncodedTagValue(java.lang.Object obj,
                                                      int tagValue)

      Return true if obj is a byte array and represents an object with the given tag value.
      Parameters:
        `obj` - object of interest.
        `tagValue` - tag value to check for.
      Returns:
        true if obj is a byte encoding starting with the given tag value, false otherwise.

    - #### toASN1Primitive

          public abstract ASN1Primitive toASN1Primitive()

      Method providing a primitive representation of this object suitable for encoding.
      Specified by:
        `toASN1Primitive` in interface `ASN1Encodable`
      Returns:
        a primitive representation of this object.