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

org.bouncycastle.asn1.tsp.EncryptionInfo Maven / Gradle / Ivy

Go to download

The Bouncy Castle Java APIs for ASN.1 extension and utility APIs used to support bcpkix and bctls. This jar contains APIs for JDK 1.5 to JDK 1.8.

There is a newer version: 1.78.1
Show newest version
package org.bouncycastle.asn1.tsp;

import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1TaggedObject;
import org.bouncycastle.asn1.DLSequence;

/**
 * Implementation of the EncryptionInfo element defined in RFC 4998:
 * 

* 1988 ASN.1 EncryptionInfo *

* EncryptionInfo ::= SEQUENCE { * encryptionInfoType OBJECT IDENTIFIER, * encryptionInfoValue ANY DEFINED BY encryptionInfoType * } *

* 1997-ASN.1 EncryptionInfo *

* EncryptionInfo ::= SEQUENCE { * encryptionInfoType ENCINFO-TYPE.&id * ({SupportedEncryptionAlgorithms}), * encryptionInfoValue ENCINFO-TYPE.&Type * ({SupportedEncryptionAlgorithms}{@encryptionInfoType}) * } *

* ENCINFO-TYPE ::= TYPE-IDENTIFIER *

* SupportedEncryptionAlgorithms ENCINFO-TYPE ::= {...} */ public class EncryptionInfo extends ASN1Object { /** * The OID for EncryptionInfo type. */ private ASN1ObjectIdentifier encryptionInfoType; /** * The value of EncryptionInfo */ private ASN1Encodable encryptionInfoValue; /** * @deprecated Use {@link EncryptionInfo#getInstance(Object)} instead. */ public static EncryptionInfo getInstance(final ASN1Object obj) { return getInstance((Object)obj); } public static EncryptionInfo getInstance(final Object obj) { if (obj instanceof EncryptionInfo) { return (EncryptionInfo)obj; } else if (obj != null) { return new EncryptionInfo(ASN1Sequence.getInstance(obj)); } return null; } public static EncryptionInfo getInstance( ASN1TaggedObject obj, boolean explicit) { return getInstance((Object)ASN1Sequence.getInstance(obj, explicit)); } private EncryptionInfo(ASN1Sequence sequence) { if (sequence.size() != 2) { throw new IllegalArgumentException("wrong sequence size in constructor: " + sequence.size()); } this.encryptionInfoType = ASN1ObjectIdentifier.getInstance(sequence.getObjectAt(0)); this.encryptionInfoValue = sequence.getObjectAt(1); } public EncryptionInfo(ASN1ObjectIdentifier encryptionInfoType, ASN1Encodable encryptionInfoValue) { this.encryptionInfoType = encryptionInfoType; this.encryptionInfoValue = encryptionInfoValue; } public ASN1ObjectIdentifier getEncryptionInfoType() { return encryptionInfoType; } public ASN1Encodable getEncryptionInfoValue() { return encryptionInfoValue; } public ASN1Primitive toASN1Primitive() { ASN1EncodableVector v = new ASN1EncodableVector(2); v.add(encryptionInfoType); v.add(encryptionInfoValue); return new DLSequence(v); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy