org.spongycastle.asn1.pkcs.RC2CBCParameter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scprov-jdk15 Show documentation
Show all versions of scprov-jdk15 Show documentation
Spongy Castle is a package-rename (org.bouncycastle.* to org.spongycastle.*) of Bouncy Castle intended for Android.
Android ships with a stripped-down version of Bouncy Castle - this causes classloader collisions if you try to add
an alternative (updated/complete) Bouncy Castle jar.
This jar contains JCE provider and lightweight API for the Bouncy Castle Cryptography APIs for JDK 1.5.
package org.spongycastle.asn1.pkcs;
import java.math.BigInteger;
import org.spongycastle.asn1.ASN1Encodable;
import org.spongycastle.asn1.ASN1EncodableVector;
import org.spongycastle.asn1.ASN1OctetString;
import org.spongycastle.asn1.ASN1Sequence;
import org.spongycastle.asn1.DERInteger;
import org.spongycastle.asn1.DERObject;
import org.spongycastle.asn1.DEROctetString;
import org.spongycastle.asn1.DERSequence;
public class RC2CBCParameter
extends ASN1Encodable
{
DERInteger version;
ASN1OctetString iv;
public static RC2CBCParameter getInstance(
Object o)
{
if (o instanceof ASN1Sequence)
{
return new RC2CBCParameter((ASN1Sequence)o);
}
throw new IllegalArgumentException("unknown object in RC2CBCParameter factory");
}
public RC2CBCParameter(
byte[] iv)
{
this.version = null;
this.iv = new DEROctetString(iv);
}
public RC2CBCParameter(
int parameterVersion,
byte[] iv)
{
this.version = new DERInteger(parameterVersion);
this.iv = new DEROctetString(iv);
}
public RC2CBCParameter(
ASN1Sequence seq)
{
if (seq.size() == 1)
{
version = null;
iv = (ASN1OctetString)seq.getObjectAt(0);
}
else
{
version = (DERInteger)seq.getObjectAt(0);
iv = (ASN1OctetString)seq.getObjectAt(1);
}
}
public BigInteger getRC2ParameterVersion()
{
if (version == null)
{
return null;
}
return version.getValue();
}
public byte[] getIV()
{
return iv.getOctets();
}
public DERObject toASN1Object()
{
ASN1EncodableVector v = new ASN1EncodableVector();
if (version != null)
{
v.add(version);
}
v.add(iv);
return new DERSequence(v);
}
}