org.bouncycastle.asn1.cms.GenericHybridParameters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bcprov-ext-debug-jdk15on Show documentation
Show all versions of bcprov-ext-debug-jdk15on Show documentation
The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.8 with debug enabled.
package org.bouncycastle.asn1.cms;
import org.bouncycastle.asn1.ASN1EncodableVector;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
/**
* RFC 5990 GenericHybridParameters class.
*
* GenericHybridParameters ::= SEQUENCE {
* kem KeyEncapsulationMechanism,
* dem DataEncapsulationMechanism
* }
*
* KeyEncapsulationMechanism ::= AlgorithmIdentifier {{KEMAlgorithms}}
* DataEncapsulationMechanism ::= AlgorithmIdentifier {{DEMAlgorithms}}
*
*/
public class GenericHybridParameters
extends ASN1Object
{
private final AlgorithmIdentifier kem;
private final AlgorithmIdentifier dem;
private GenericHybridParameters(ASN1Sequence sequence)
{
if (sequence.size() != 2)
{
throw new IllegalArgumentException("ASN.1 SEQUENCE should be of length 2");
}
this.kem = AlgorithmIdentifier.getInstance(sequence.getObjectAt(0));
this.dem = AlgorithmIdentifier.getInstance(sequence.getObjectAt(1));
}
public static GenericHybridParameters getInstance(
Object o)
{
if (o instanceof GenericHybridParameters)
{
return (GenericHybridParameters)o;
}
else if (o != null)
{
return new GenericHybridParameters(ASN1Sequence.getInstance(o));
}
return null;
}
public GenericHybridParameters(AlgorithmIdentifier kem, AlgorithmIdentifier dem)
{
this.kem = kem;
this.dem = dem;
}
public AlgorithmIdentifier getDem()
{
return dem;
}
public AlgorithmIdentifier getKem()
{
return kem;
}
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(kem);
v.add(dem);
return new DERSequence(v);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy