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

org.bouncycastle.asn1.cms

## Class EnvelopedData

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

- All Implemented Interfaces:
    ASN1Encodable, Encodable

      public class EnvelopedData
      extends ASN1Object

  RFC 5652 EnvelopedData object.

       EnvelopedData ::= SEQUENCE {
           version CMSVersion,
           originatorInfo [0] IMPLICIT OriginatorInfo OPTIONAL,
           recipientInfos RecipientInfos,
           encryptedContentInfo EncryptedContentInfo,
           unprotectedAttrs [1] IMPLICIT UnprotectedAttributes OPTIONAL
       }

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `EnvelopedData(OriginatorInfo originatorInfo, ASN1Set recipientInfos, EncryptedContentInfo encryptedContentInfo, ASN1Set unprotectedAttrs)`
    `EnvelopedData(OriginatorInfo originatorInfo, ASN1Set recipientInfos, EncryptedContentInfo encryptedContentInfo, Attributes unprotectedAttrs)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `calculateVersion(OriginatorInfo originatorInfo, ASN1Set recipientInfos, ASN1Set unprotectedAttrs)`
    `EncryptedContentInfo` | `getEncryptedContentInfo()`
    `static EnvelopedData` | `getInstance(ASN1TaggedObject obj, boolean explicit)` Return an EnvelopedData object from a tagged object.
    `static EnvelopedData` | `getInstance(java.lang.Object obj)` Return an EnvelopedData object from the given object.
    `OriginatorInfo` | `getOriginatorInfo()`
    `ASN1Set` | `getRecipientInfos()`
    `ASN1Set` | `getUnprotectedAttrs()`
    `ASN1Integer` | `getVersion()`
    `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

    - #### EnvelopedData

          public EnvelopedData(OriginatorInfo originatorInfo,
                               ASN1Set recipientInfos,
                               EncryptedContentInfo encryptedContentInfo,
                               ASN1Set unprotectedAttrs)

    - #### EnvelopedData

          public EnvelopedData(OriginatorInfo originatorInfo,
                               ASN1Set recipientInfos,
                               EncryptedContentInfo encryptedContentInfo,
                               Attributes unprotectedAttrs)

  - ### Method Detail

    - #### getInstance

          public static EnvelopedData getInstance(ASN1TaggedObject obj,
                                                  boolean explicit)

      Return an EnvelopedData object from a tagged object.
      Parameters:
        `obj` - the tagged object holding the object we want.
        `explicit` - true if the object is meant to be explicitly tagged false otherwise.
      Throws:
        `java.lang.IllegalArgumentException` - if the object held by the tagged object cannot be converted.

    - #### getInstance

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

      Return an EnvelopedData object from the given object.

      Accepted inputs:

      - null → null
      - `EnvelopedData` object
      - `ASN1Sequence` input formats with EnvelopedData structure inside
      Parameters:
        `obj` - the object we want converted.
      Throws:
        `java.lang.IllegalArgumentException` - if the object cannot be converted.

    - #### getVersion

          public ASN1Integer getVersion()

    - #### getOriginatorInfo

          public OriginatorInfo getOriginatorInfo()

    - #### getRecipientInfos

          public ASN1Set getRecipientInfos()

    - #### getEncryptedContentInfo

          public EncryptedContentInfo getEncryptedContentInfo()

    - #### getUnprotectedAttrs

          public ASN1Set getUnprotectedAttrs()

    - #### toASN1Primitive

          public ASN1Primitive toASN1Primitive()

      Produce an object suitable for an ASN1OutputStream.

      The encoding follows the components, as for `SignedData`: if the encrypted content info or any of the sets carries the indefinite-length (BER) form the sequence is BER, otherwise it is definite-length.

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

    - #### calculateVersion

          public static int calculateVersion(OriginatorInfo originatorInfo,
                                             ASN1Set recipientInfos,
                                             ASN1Set unprotectedAttrs)