All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.bouncycastle.asn1.cms.EncryptedData Maven / Gradle / Ivy

Go to download

The FIPS 140-3 Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms certified to FIPS 140-3 level 1. This jar contains JCE provider and low-level API for the BC-FJA version 2.0.0, FIPS Certificate #4743. Please see certificate for certified platform details.

There is a newer version: 2.0.0
Show newest version
/***************************************************************/
/******    DO NOT EDIT THIS CLASS bc-java SOURCE FILE     ******/
/***************************************************************/
package org.bouncycastle.asn1.cms;

import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Integer;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1Set;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.BERSequence;
import org.bouncycastle.asn1.BERTaggedObject;

/**
 * RFC 5652 EncryptedData object.
 * 

*

 * EncryptedData ::= SEQUENCE {
 *     version CMSVersion,
 *     encryptedContentInfo EncryptedContentInfo,
 *     unprotectedAttrs [1] IMPLICIT UnprotectedAttributes OPTIONAL }
 * 
*/ public class EncryptedData extends ASN1Object { private ASN1Integer version; private EncryptedContentInfo encryptedContentInfo; private ASN1Set unprotectedAttrs; /** * Return an EncryptedData object from the given object. *

* Accepted inputs: *

    *
  • null → null *
  • {@link EncryptedData} object *
  • {@link org.bouncycastle.asn1.ASN1Sequence#getInstance(java.lang.Object) ASN1Sequence} input formats *
* * @param o the object we want converted. * @exception IllegalArgumentException if the object cannot be converted. */ public static EncryptedData getInstance(Object o) { if (o instanceof EncryptedData) { return (EncryptedData)o; } if (o != null) { return new EncryptedData(ASN1Sequence.getInstance(o)); } return null; } public EncryptedData(EncryptedContentInfo encInfo) { this(encInfo, null); } public EncryptedData(EncryptedContentInfo encInfo, ASN1Set unprotectedAttrs) { this.version = new ASN1Integer((unprotectedAttrs == null) ? 0 : 2); this.encryptedContentInfo = encInfo; this.unprotectedAttrs = unprotectedAttrs; } private EncryptedData(ASN1Sequence seq) { this.version = ASN1Integer.getInstance(seq.getObjectAt(0)); this.encryptedContentInfo = EncryptedContentInfo.getInstance(seq.getObjectAt(1)); if (seq.size() == 3) { this.unprotectedAttrs = ASN1Set.getInstance((ASN1TaggedObject)seq.getObjectAt(2), false); } } public ASN1Integer getVersion() { return version; } public EncryptedContentInfo getEncryptedContentInfo() { return encryptedContentInfo; } public ASN1Set getUnprotectedAttrs() { return unprotectedAttrs; } /** * @return a basic ASN.1 object representation. */ public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(); v.add(version); v.add(encryptedContentInfo); if (unprotectedAttrs != null) { v.add(new BERTaggedObject(false, 1, unprotectedAttrs)); } return new BERSequence(v); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy