org.bouncycastle.asn1.cryptopro.Gost2814789KeyWrapParameters 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.cryptopro;
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.DEROctetString;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.util.Arrays;
public class Gost2814789KeyWrapParameters
extends ASN1Object
{
private final ASN1ObjectIdentifier encryptionParamSet;
private final byte[] ukm;
private Gost2814789KeyWrapParameters(ASN1Sequence seq)
{
if (seq.size() == 2)
{
this.encryptionParamSet = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0));
this.ukm = ASN1OctetString.getInstance(seq.getObjectAt(1)).getOctets();
}
else if (seq.size() == 1)
{
this.encryptionParamSet = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0));
this.ukm = null;
}
else
{
throw new IllegalArgumentException("unknown sequence length: " + seq.size());
}
}
public static Gost2814789KeyWrapParameters getInstance(
Object obj)
{
if (obj instanceof Gost2814789KeyWrapParameters)
{
return (Gost2814789KeyWrapParameters)obj;
}
if (obj != null)
{
return new Gost2814789KeyWrapParameters(ASN1Sequence.getInstance(obj));
}
return null;
}
public Gost2814789KeyWrapParameters(ASN1ObjectIdentifier encryptionParamSet)
{
this(encryptionParamSet, null);
}
public Gost2814789KeyWrapParameters(ASN1ObjectIdentifier encryptionParamSet, byte[] ukm)
{
this.encryptionParamSet = encryptionParamSet;
this.ukm = Arrays.clone(ukm);
}
public ASN1ObjectIdentifier getEncryptionParamSet()
{
return encryptionParamSet;
}
public byte[] getUkm()
{
return ukm;
}
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(encryptionParamSet);
if (ukm != null)
{
v.add(new DEROctetString(ukm));
}
return new DERSequence(v);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy