Class RecipientInformation

java.lang.Object
org.bouncycastle.cms.RecipientInformation
Direct Known Subclasses:
KEKRecipientInformation, KEMRecipientInformation, KeyAgreeRecipientInformation, KeyTransRecipientInformation, PasswordRecipientInformation

public abstract class RecipientInformation extends Object
  • Field Details

    • rid

      protected RecipientId rid
    • keyEncAlg

      protected org.bouncycastle.asn1.x509.AlgorithmIdentifier keyEncAlg
    • messageAlgorithm

      protected org.bouncycastle.asn1.x509.AlgorithmIdentifier messageAlgorithm
    • secureReadable

      protected org.bouncycastle.cms.CMSSecureReadable secureReadable
  • Method Details

    • getRID

      public RecipientId getRID()
    • getKeyEncryptionAlgorithm

      public org.bouncycastle.asn1.x509.AlgorithmIdentifier getKeyEncryptionAlgorithm()
      Return the key encryption algorithm details for the key in this recipient.
      Returns:
      AlgorithmIdentifier representing the key encryption algorithm.
    • getKeyEncryptionAlgOID

      public String getKeyEncryptionAlgOID()
      return the object identifier for the key encryption algorithm.
      Returns:
      OID for key encryption algorithm.
    • getKeyEncryptionAlgParams

      public byte[] getKeyEncryptionAlgParams()
      return the ASN.1 encoded key encryption algorithm parameters, or null if there aren't any.
      Returns:
      ASN.1 encoding of key encryption algorithm parameters.
    • getContentDigest

      public byte[] getContentDigest()
      Return the content digest calculated during the read of the content if one has been generated. This will only happen if we are dealing with authenticated data and authenticated attributes are present.
      Returns:
      byte array containing the digest.
    • getMac

      public byte[] getMac()
      Return the MAC calculated for the recipient. Note: this call is only meaningful once all the content has been read.

      For an AuthenticatedData message with authenticated attributes, the content is bound to the MAC through them, so the messageDigest attribute is first checked against the digest of the content read and the content-type attribute against the eContentType (RFC 5652 sec. 9.2 and 9.3). Without authenticated attributes a CBC-MAC (des-ede3-cbc, rc2-cbc) whose parameters carry a non-zero IV is refused, as nothing covers that IV. The caller compares the result with the MAC in the message.

      Returns:
      byte array containing the mac.
      Throws:
      CMSRuntimeException - if one of these checks fails.
    • getContent

      public byte[] getContent(Recipient recipient) throws CMSException
      Return the decrypted/encapsulated content in the EnvelopedData after recovering the content encryption/MAC key using the passed in Recipient.
      Parameters:
      recipient - recipient object to use to recover content encryption key
      Returns:
      the content inside the EnvelopedData this RecipientInformation is associated with.
      Throws:
      CMSException - if the content-encryption/MAC key cannot be recovered.
    • getContentType

      public org.bouncycastle.asn1.ASN1ObjectIdentifier getContentType()
      Return the content type of the encapsulated data accessed by this recipient.
      Returns:
      the content type OID.
    • getContentStream

      public CMSTypedStream getContentStream(Recipient recipient) throws CMSException, IOException
      Return a CMSTypedStream representing the content in the EnvelopedData after recovering the content encryption/MAC key using the passed in Recipient.
      Parameters:
      recipient - recipient object to use to recover content encryption key
      Returns:
      the content inside the EnvelopedData this RecipientInformation is associated with.
      Throws:
      CMSException - if the content-encryption/MAC key cannot be recovered.
      IOException
    • getRecipientOperator

      protected abstract RecipientOperator getRecipientOperator(Recipient recipient) throws CMSException, IOException
      Throws:
      CMSException
      IOException