blob: d47b87215c691afbef1807e0694fd5bd61990601 (
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
|
using System;
using System.IO;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Asn1.Cmp
{
/**
* OOBCert ::= CMPCertificate
*/
public class OobCert
: CmpCertificate
{
public static OobCert GetInstance(object obj)
{
if (obj == null)
return null;
if (obj is OobCert oobCert)
return oobCert;
if (obj is CmpCertificate cmpCertificate)
return GetInstance(cmpCertificate.GetEncoded());
if (obj is byte[] bs)
{
try
{
obj = Asn1Object.FromByteArray(bs);
}
catch (IOException)
{
throw new ArgumentException("Invalid encoding in OobCert");
}
}
if (obj is Asn1Sequence seq)
return new OobCert(X509CertificateStructure.GetInstance(obj));
if (obj is Asn1TaggedObject taggedObject)
return new OobCert(taggedObject.TagNo, taggedObject.GetObject());
throw new ArgumentException("Invalid object: " + Platform.GetTypeName(obj), nameof(obj));
}
public static OobCert GetInstance(Asn1TaggedObject taggedObject, bool declaredExplicit)
{
if (taggedObject == null)
return null;
if (!declaredExplicit)
throw new ArgumentException("tag must be explicit");
return GetInstance(taggedObject.GetObject());
}
public OobCert(int type, Asn1Encodable otherCert)
: base(type, otherCert)
{
}
public OobCert(X509CertificateStructure x509v3PKCert)
: base(x509v3PKCert)
{
}
}
}
|