package org.bouncycastle.asn1.cms; import org.bouncycastle.asn1.ASN1EncodableVector; import org.bouncycastle.asn1.ASN1Object; import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.asn1.ASN1OctetString; import org.bouncycastle.asn1.ASN1Primitive; import org.bouncycastle.asn1.ASN1Sequence; import org.bouncycastle.asn1.ASN1TaggedObject; import org.bouncycastle.asn1.BERSequence; import org.bouncycastle.asn1.BERTaggedObject; import org.bouncycastle.asn1.x509.AlgorithmIdentifier; /** * RFC 5652 EncryptedContentInfo object. * *
* EncryptedContentInfo ::= SEQUENCE { * contentType ContentType, * contentEncryptionAlgorithm ContentEncryptionAlgorithmIdentifier, * encryptedContent [0] IMPLICIT EncryptedContent OPTIONAL * } **/ public class EncryptedContentInfo extends ASN1Object { private ASN1ObjectIdentifier contentType; private AlgorithmIdentifier contentEncryptionAlgorithm; private ASN1OctetString encryptedContent; public EncryptedContentInfo( ASN1ObjectIdentifier contentType, AlgorithmIdentifier contentEncryptionAlgorithm, ASN1OctetString encryptedContent) { this.contentType = contentType; this.contentEncryptionAlgorithm = contentEncryptionAlgorithm; this.encryptedContent = encryptedContent; } private EncryptedContentInfo( ASN1Sequence seq) { if (seq.size() < 2) { throw new IllegalArgumentException("Truncated Sequence Found"); } contentType = (ASN1ObjectIdentifier)seq.getObjectAt(0); contentEncryptionAlgorithm = AlgorithmIdentifier.getInstance( seq.getObjectAt(1)); if (seq.size() > 2) { encryptedContent = ASN1OctetString.getInstance( (ASN1TaggedObject)seq.getObjectAt(2), false); } } /** * Return an EncryptedContentInfo object from the given object. *
* Accepted inputs: *