up
This commit is contained in:
93
Assets/BestHTTP/SecureProtocol/asn1/ocsp/OCSPResponse.cs
Normal file
93
Assets/BestHTTP/SecureProtocol/asn1/ocsp/OCSPResponse.cs
Normal file
@@ -0,0 +1,93 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Ocsp
|
||||
{
|
||||
public class OcspResponse
|
||||
: Asn1Encodable
|
||||
{
|
||||
private readonly OcspResponseStatus responseStatus;
|
||||
private readonly ResponseBytes responseBytes;
|
||||
|
||||
public static OcspResponse GetInstance(
|
||||
Asn1TaggedObject obj,
|
||||
bool explicitly)
|
||||
{
|
||||
return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
|
||||
}
|
||||
|
||||
public static OcspResponse GetInstance(
|
||||
object obj)
|
||||
{
|
||||
if (obj == null || obj is OcspResponse)
|
||||
{
|
||||
return (OcspResponse)obj;
|
||||
}
|
||||
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new OcspResponse((Asn1Sequence)obj);
|
||||
}
|
||||
|
||||
throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
public OcspResponse(
|
||||
OcspResponseStatus responseStatus,
|
||||
ResponseBytes responseBytes)
|
||||
{
|
||||
if (responseStatus == null)
|
||||
throw new ArgumentNullException("responseStatus");
|
||||
|
||||
this.responseStatus = responseStatus;
|
||||
this.responseBytes = responseBytes;
|
||||
}
|
||||
|
||||
private OcspResponse(
|
||||
Asn1Sequence seq)
|
||||
{
|
||||
responseStatus = new OcspResponseStatus(
|
||||
DerEnumerated.GetInstance(seq[0]));
|
||||
|
||||
if (seq.Count == 2)
|
||||
{
|
||||
responseBytes = ResponseBytes.GetInstance(
|
||||
(Asn1TaggedObject)seq[1], true);
|
||||
}
|
||||
}
|
||||
|
||||
public OcspResponseStatus ResponseStatus
|
||||
{
|
||||
get { return responseStatus; }
|
||||
}
|
||||
|
||||
public ResponseBytes ResponseBytes
|
||||
{
|
||||
get { return responseBytes; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce an object suitable for an Asn1OutputStream.
|
||||
* <pre>
|
||||
* OcspResponse ::= Sequence {
|
||||
* responseStatus OcspResponseStatus,
|
||||
* responseBytes [0] EXPLICIT ResponseBytes OPTIONAL }
|
||||
* </pre>
|
||||
*/
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector v = new Asn1EncodableVector(responseStatus);
|
||||
|
||||
if (responseBytes != null)
|
||||
{
|
||||
v.Add(new DerTaggedObject(true, 0, responseBytes));
|
||||
}
|
||||
|
||||
return new DerSequence(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b67091dc95a1e4d9b8f86c1ce18dd484
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Asn1;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Ocsp
|
||||
{
|
||||
public class OcspResponseStatus
|
||||
: DerEnumerated
|
||||
{
|
||||
public const int Successful = 0;
|
||||
public const int MalformedRequest = 1;
|
||||
public const int InternalError = 2;
|
||||
public const int TryLater = 3;
|
||||
public const int SignatureRequired = 5;
|
||||
public const int Unauthorized = 6;
|
||||
|
||||
/**
|
||||
* The OcspResponseStatus enumeration.
|
||||
* <pre>
|
||||
* OcspResponseStatus ::= Enumerated {
|
||||
* successful (0), --Response has valid confirmations
|
||||
* malformedRequest (1), --Illegal confirmation request
|
||||
* internalError (2), --Internal error in issuer
|
||||
* tryLater (3), --Try again later
|
||||
* --(4) is not used
|
||||
* sigRequired (5), --Must sign the request
|
||||
* unauthorized (6) --Request unauthorized
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public OcspResponseStatus(int value)
|
||||
: base(value)
|
||||
{
|
||||
}
|
||||
|
||||
public OcspResponseStatus(DerEnumerated value)
|
||||
: base(value.Value.IntValue)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 799a2b5b9ffcd45f5a09ab12f2674ab0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
110
Assets/BestHTTP/SecureProtocol/asn1/ocsp/ResponderID.cs
Normal file
110
Assets/BestHTTP/SecureProtocol/asn1/ocsp/ResponderID.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Asn1;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Ocsp
|
||||
{
|
||||
public class ResponderID
|
||||
: Asn1Encodable, IAsn1Choice
|
||||
{
|
||||
private readonly Asn1Encodable id;
|
||||
|
||||
public static ResponderID GetInstance(
|
||||
object obj)
|
||||
{
|
||||
if (obj == null || obj is ResponderID)
|
||||
{
|
||||
return (ResponderID)obj;
|
||||
}
|
||||
|
||||
if (obj is DerOctetString)
|
||||
{
|
||||
return new ResponderID((DerOctetString)obj);
|
||||
}
|
||||
|
||||
if (obj is Asn1TaggedObject)
|
||||
{
|
||||
Asn1TaggedObject o = (Asn1TaggedObject)obj;
|
||||
|
||||
if (o.TagNo == 1)
|
||||
{
|
||||
return new ResponderID(X509Name.GetInstance(o, true));
|
||||
}
|
||||
|
||||
return new ResponderID(Asn1OctetString.GetInstance(o, true));
|
||||
}
|
||||
|
||||
return new ResponderID(X509Name.GetInstance(obj));
|
||||
}
|
||||
|
||||
public ResponderID(
|
||||
Asn1OctetString id)
|
||||
{
|
||||
if (id == null)
|
||||
throw new ArgumentNullException("id");
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public ResponderID(
|
||||
X509Name id)
|
||||
{
|
||||
if (id == null)
|
||||
throw new ArgumentNullException("id");
|
||||
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public static ResponderID GetInstance(
|
||||
Asn1TaggedObject obj,
|
||||
bool isExplicit)
|
||||
{
|
||||
return GetInstance(obj.GetObject()); // must be explicitly tagged
|
||||
}
|
||||
|
||||
public virtual byte[] GetKeyHash()
|
||||
{
|
||||
if (id is Asn1OctetString)
|
||||
{
|
||||
return ((Asn1OctetString)id).GetOctets();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual X509Name Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (id is Asn1OctetString)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return X509Name.GetInstance(id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce an object suitable for an Asn1OutputStream.
|
||||
* <pre>
|
||||
* ResponderID ::= CHOICE {
|
||||
* byName [1] Name,
|
||||
* byKey [2] KeyHash }
|
||||
* </pre>
|
||||
*/
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
if (id is Asn1OctetString)
|
||||
{
|
||||
return new DerTaggedObject(true, 2, id);
|
||||
}
|
||||
|
||||
return new DerTaggedObject(true, 1, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/asn1/ocsp/ResponderID.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/asn1/ocsp/ResponderID.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81fe73b1422b548cf9284a95232fd708
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
85
Assets/BestHTTP/SecureProtocol/asn1/ocsp/ResponseBytes.cs
Normal file
85
Assets/BestHTTP/SecureProtocol/asn1/ocsp/ResponseBytes.cs
Normal file
@@ -0,0 +1,85 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Ocsp
|
||||
{
|
||||
public class ResponseBytes
|
||||
: Asn1Encodable
|
||||
{
|
||||
private readonly DerObjectIdentifier responseType;
|
||||
private readonly Asn1OctetString response;
|
||||
|
||||
public static ResponseBytes GetInstance(
|
||||
Asn1TaggedObject obj,
|
||||
bool explicitly)
|
||||
{
|
||||
return GetInstance(Asn1Sequence.GetInstance(obj, explicitly));
|
||||
}
|
||||
|
||||
public static ResponseBytes GetInstance(
|
||||
object obj)
|
||||
{
|
||||
if (obj == null || obj is ResponseBytes)
|
||||
{
|
||||
return (ResponseBytes)obj;
|
||||
}
|
||||
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new ResponseBytes((Asn1Sequence)obj);
|
||||
}
|
||||
|
||||
throw new ArgumentException("unknown object in factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
public ResponseBytes(
|
||||
DerObjectIdentifier responseType,
|
||||
Asn1OctetString response)
|
||||
{
|
||||
if (responseType == null)
|
||||
throw new ArgumentNullException("responseType");
|
||||
if (response == null)
|
||||
throw new ArgumentNullException("response");
|
||||
|
||||
this.responseType = responseType;
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
private ResponseBytes(
|
||||
Asn1Sequence seq)
|
||||
{
|
||||
if (seq.Count != 2)
|
||||
throw new ArgumentException("Wrong number of elements in sequence", "seq");
|
||||
|
||||
this.responseType = DerObjectIdentifier.GetInstance(seq[0]);
|
||||
this.response = Asn1OctetString.GetInstance(seq[1]);
|
||||
}
|
||||
|
||||
public DerObjectIdentifier ResponseType
|
||||
{
|
||||
get { return responseType; }
|
||||
}
|
||||
|
||||
public Asn1OctetString Response
|
||||
{
|
||||
get { return response; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce an object suitable for an Asn1OutputStream.
|
||||
* <pre>
|
||||
* ResponseBytes ::= Sequence {
|
||||
* responseType OBJECT IDENTIFIER,
|
||||
* response OCTET STRING }
|
||||
* </pre>
|
||||
*/
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return new DerSequence(responseType, response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 96b4e5bb207a043688e60dce472d179e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user