org.spongycastle.asn1.esf.OtherHashAlgAndValue 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.
The newest version!
package org.spongycastle.asn1.esf;
import org.spongycastle.asn1.ASN1Encodable;
import org.spongycastle.asn1.ASN1EncodableVector;
import org.spongycastle.asn1.ASN1OctetString;
import org.spongycastle.asn1.ASN1Sequence;
import org.spongycastle.asn1.DERObject;
import org.spongycastle.asn1.DERSequence;
import org.spongycastle.asn1.x509.AlgorithmIdentifier;
public class OtherHashAlgAndValue
extends ASN1Encodable
{
private AlgorithmIdentifier hashAlgorithm;
private ASN1OctetString hashValue;
public static OtherHashAlgAndValue getInstance(
Object obj)
{
if (obj instanceof OtherHashAlgAndValue)
{
return (OtherHashAlgAndValue) obj;
}
else if (obj != null)
{
return new OtherHashAlgAndValue(ASN1Sequence.getInstance(obj));
}
throw new IllegalArgumentException("null value in getInstance");
}
private OtherHashAlgAndValue(
ASN1Sequence seq)
{
if (seq.size() != 2)
{
throw new IllegalArgumentException("Bad sequence size: " + seq.size());
}
hashAlgorithm = AlgorithmIdentifier.getInstance(seq.getObjectAt(0));
hashValue = ASN1OctetString.getInstance(seq.getObjectAt(1));
}
public OtherHashAlgAndValue(
AlgorithmIdentifier hashAlgorithm,
ASN1OctetString hashValue)
{
this.hashAlgorithm = hashAlgorithm;
this.hashValue = hashValue;
}
public AlgorithmIdentifier getHashAlgorithm()
{
return hashAlgorithm;
}
public ASN1OctetString getHashValue()
{
return hashValue;
}
/**
*
* OtherHashAlgAndValue ::= SEQUENCE {
* hashAlgorithm AlgorithmIdentifier,
* hashValue OtherHashValue }
*
* OtherHashValue ::= OCTET STRING
*
*/
public DERObject toASN1Object()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(hashAlgorithm);
v.add(hashValue);
return new DERSequence(v);
}
}