All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.spongycastle.asn1.esf.OtherHash Maven / Gradle / Ivy

Go to download

The Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms. This jar contains JCE provider for the Bouncy Castle Cryptography APIs for JDK 1.5 to JDK 1.7.

There is a newer version: 1.47.0.3
Show newest version
package org.spongycastle.asn1.esf;

import org.spongycastle.asn1.ASN1Choice;
import org.spongycastle.asn1.ASN1Object;
import org.spongycastle.asn1.ASN1OctetString;
import org.spongycastle.asn1.ASN1Primitive;
import org.spongycastle.asn1.DEROctetString;
import org.spongycastle.asn1.oiw.OIWObjectIdentifiers;
import org.spongycastle.asn1.x509.AlgorithmIdentifier;

/**
 * 
 * OtherHash ::= CHOICE {
 *    sha1Hash  OtherHashValue, -- This contains a SHA-1 hash
 *   otherHash  OtherHashAlgAndValue
 *  }
 * 
*/ public class OtherHash extends ASN1Object implements ASN1Choice { private ASN1OctetString sha1Hash; private OtherHashAlgAndValue otherHash; public static OtherHash getInstance(Object obj) { if (obj instanceof OtherHash) { return (OtherHash)obj; } if (obj instanceof ASN1OctetString) { return new OtherHash((ASN1OctetString)obj); } return new OtherHash(OtherHashAlgAndValue.getInstance(obj)); } private OtherHash(ASN1OctetString sha1Hash) { this.sha1Hash = sha1Hash; } public OtherHash(OtherHashAlgAndValue otherHash) { this.otherHash = otherHash; } public OtherHash(byte[] sha1Hash) { this.sha1Hash = new DEROctetString(sha1Hash); } public AlgorithmIdentifier getHashAlgorithm() { if (null == this.otherHash) { return new AlgorithmIdentifier(OIWObjectIdentifiers.idSHA1); } return this.otherHash.getHashAlgorithm(); } public byte[] getHashValue() { if (null == this.otherHash) { return this.sha1Hash.getOctets(); } return this.otherHash.getHashValue().getOctets(); } public ASN1Primitive toASN1Primitive() { if (null == this.otherHash) { return this.sha1Hash; } return this.otherHash.toASN1Primitive(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy