org.spongycastle.asn1.misc.CAST5CBCParameters 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.misc;
import org.spongycastle.asn1.*;
public class CAST5CBCParameters
extends ASN1Encodable
{
DERInteger keyLength;
ASN1OctetString iv;
public static CAST5CBCParameters getInstance(
Object o)
{
if (o instanceof CAST5CBCParameters)
{
return (CAST5CBCParameters)o;
}
else if (o instanceof ASN1Sequence)
{
return new CAST5CBCParameters((ASN1Sequence)o);
}
throw new IllegalArgumentException("unknown object in CAST5CBCParameter factory");
}
public CAST5CBCParameters(
byte[] iv,
int keyLength)
{
this.iv = new DEROctetString(iv);
this.keyLength = new DERInteger(keyLength);
}
public CAST5CBCParameters(
ASN1Sequence seq)
{
iv = (ASN1OctetString)seq.getObjectAt(0);
keyLength = (DERInteger)seq.getObjectAt(1);
}
public byte[] getIV()
{
return iv.getOctets();
}
public int getKeyLength()
{
return keyLength.getValue().intValue();
}
/**
* Produce an object suitable for an ASN1OutputStream.
*
* cast5CBCParameters ::= SEQUENCE {
* iv OCTET STRING DEFAULT 0,
* -- Initialization vector
* keyLength INTEGER
* -- Key length, in bits
* }
*
*/
public DERObject toASN1Object()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(iv);
v.add(keyLength);
return new DERSequence(v);
}
}