blob: 0ec257d8dc0f991c1a1f174eff51815e7ed0bcf8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
package org.bouncycastle.asn1.esf;
import org.bouncycastle.asn1.ASN1Choice;
import org.bouncycastle.asn1.ASN1Object;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.oiw.OIWObjectIdentifiers;
import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
/**
* <pre>
* OtherHash ::= CHOICE {
* sha1Hash OtherHashValue, -- This contains a SHA-1 hash
* otherHash OtherHashAlgAndValue
* }
* </pre>
*/
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();
}
}
|