blob: 304b9cd49511e45623830e02c1ddd9ff10f17400 (
plain) (
blame)
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
|
using System;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Ocsp;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.X509;
namespace Org.BouncyCastle.Ocsp
{
/**
* Carrier for a ResponderID.
*/
public class RespID
{
internal readonly ResponderID id;
public RespID(
ResponderID id)
{
this.id = id;
}
public RespID(
X509Name name)
{
this.id = new ResponderID(name);
}
public RespID(
AsymmetricKeyParameter publicKey)
{
try
{
SubjectPublicKeyInfo info = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(publicKey);
byte[] keyHash = DigestUtilities.CalculateDigest("SHA1", info.PublicKey.GetBytes());
this.id = new ResponderID(new DerOctetString(keyHash));
}
catch (Exception e)
{
throw new OcspException("problem creating ID: " + e, e);
}
}
public ResponderID ToAsn1Object()
{
return id;
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
RespID other = obj as RespID;
if (other == null)
return false;
return id.Equals(other.id);
}
public override int GetHashCode()
{
return id.GetHashCode();
}
}
}
|