This commit is contained in:
2026-06-15 18:18:16 +08:00
parent 97c9fba14e
commit 2b9f134e5f
4164 changed files with 386922 additions and 79 deletions

View File

@@ -0,0 +1,72 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class AttributeTypeAndValue
: Asn1Encodable
{
private readonly DerObjectIdentifier type;
private readonly Asn1Encodable value;
private AttributeTypeAndValue(Asn1Sequence seq)
{
type = (DerObjectIdentifier)seq[0];
value = (Asn1Encodable)seq[1];
}
public static AttributeTypeAndValue GetInstance(object obj)
{
if (obj is AttributeTypeAndValue)
return (AttributeTypeAndValue)obj;
if (obj is Asn1Sequence)
return new AttributeTypeAndValue((Asn1Sequence)obj);
throw new ArgumentException("Invalid object: " + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
}
public AttributeTypeAndValue(
string oid,
Asn1Encodable value)
: this(new DerObjectIdentifier(oid), value)
{
}
public AttributeTypeAndValue(
DerObjectIdentifier type,
Asn1Encodable value)
{
this.type = type;
this.value = value;
}
public virtual DerObjectIdentifier Type
{
get { return type; }
}
public virtual Asn1Encodable Value
{
get { return value; }
}
/**
* <pre>
* AttributeTypeAndValue ::= SEQUENCE {
* type OBJECT IDENTIFIER,
* value ANY DEFINED BY type }
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
return new DerSequence(type, value);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 10929e85222075a45944037e77775558
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class CertId
: Asn1Encodable
{
private readonly GeneralName issuer;
private readonly DerInteger serialNumber;
private CertId(Asn1Sequence seq)
{
issuer = GeneralName.GetInstance(seq[0]);
serialNumber = DerInteger.GetInstance(seq[1]);
}
public static CertId GetInstance(object obj)
{
if (obj is CertId)
return (CertId)obj;
if (obj is Asn1Sequence)
return new CertId((Asn1Sequence)obj);
throw new ArgumentException("Invalid object: " + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
}
public static CertId GetInstance(Asn1TaggedObject obj, bool isExplicit)
{
return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
}
public virtual GeneralName Issuer
{
get { return issuer; }
}
public virtual DerInteger SerialNumber
{
get { return serialNumber; }
}
/**
* <pre>
* CertId ::= SEQUENCE {
* issuer GeneralName,
* serialNumber INTEGER }
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
return new DerSequence(issuer, serialNumber);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 278626812312f974d9ceb32eba1c407f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,58 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class CertReqMessages
: Asn1Encodable
{
private readonly Asn1Sequence content;
private CertReqMessages(Asn1Sequence seq)
{
content = seq;
}
public static CertReqMessages GetInstance(object obj)
{
if (obj is CertReqMessages)
return (CertReqMessages)obj;
if (obj is Asn1Sequence)
return new CertReqMessages((Asn1Sequence)obj);
throw new ArgumentException("Invalid object: " + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
}
public CertReqMessages(params CertReqMsg[] msgs)
{
content = new DerSequence(msgs);
}
public virtual CertReqMsg[] ToCertReqMsgArray()
{
CertReqMsg[] result = new CertReqMsg[content.Count];
for (int i = 0; i != result.Length; ++i)
{
result[i] = CertReqMsg.GetInstance(content[i]);
}
return result;
}
/**
* <pre>
* CertReqMessages ::= SEQUENCE SIZE (1..MAX) OF CertReqMsg
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
return content;
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 95c108803b6695049aa7a5f143e18635
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,116 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class CertReqMsg
: Asn1Encodable
{
private readonly CertRequest certReq;
private readonly ProofOfPossession popo;
private readonly Asn1Sequence regInfo;
private CertReqMsg(Asn1Sequence seq)
{
certReq = CertRequest.GetInstance(seq[0]);
for (int pos = 1; pos < seq.Count; ++pos)
{
object o = seq[pos];
if (o is Asn1TaggedObject || o is ProofOfPossession)
{
popo = ProofOfPossession.GetInstance(o);
}
else
{
regInfo = Asn1Sequence.GetInstance(o);
}
}
}
public static CertReqMsg GetInstance(object obj)
{
if (obj is CertReqMsg)
return (CertReqMsg)obj;
if (obj != null)
return new CertReqMsg(Asn1Sequence.GetInstance(obj));
return null;
}
public static CertReqMsg GetInstance(
Asn1TaggedObject obj,
bool isExplicit)
{
return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
}
/**
* Creates a new CertReqMsg.
* @param certReq CertRequest
* @param popo may be null
* @param regInfo may be null
*/
public CertReqMsg(
CertRequest certReq,
ProofOfPossession popo,
AttributeTypeAndValue[] regInfo)
{
if (certReq == null)
throw new ArgumentNullException("certReq");
this.certReq = certReq;
this.popo = popo;
if (regInfo != null)
{
this.regInfo = new DerSequence(regInfo);
}
}
public virtual CertRequest CertReq
{
get { return certReq; }
}
public virtual ProofOfPossession Popo
{
get { return popo; }
}
public virtual AttributeTypeAndValue[] GetRegInfo()
{
if (regInfo == null)
return null;
AttributeTypeAndValue[] results = new AttributeTypeAndValue[regInfo.Count];
for (int i = 0; i != results.Length; ++i)
{
results[i] = AttributeTypeAndValue.GetInstance(regInfo[i]);
}
return results;
}
/**
* <pre>
* CertReqMsg ::= SEQUENCE {
* certReq CertRequest,
* pop ProofOfPossession OPTIONAL,
* -- content depends upon key type
* regInfo SEQUENCE SIZE(1..MAX) OF AttributeTypeAndValue OPTIONAL }
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector(certReq);
v.AddOptional(popo, regInfo);
return new DerSequence(v);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e017944cda918a54a9128204afdbe99f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,87 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Crmf;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class CertRequest
: Asn1Encodable
{
private readonly DerInteger certReqId;
private readonly CertTemplate certTemplate;
private readonly Controls controls;
private CertRequest(Asn1Sequence seq)
{
certReqId = DerInteger.GetInstance(seq[0]);
certTemplate = CertTemplate.GetInstance(seq[1]);
if (seq.Count > 2)
{
controls = Controls.GetInstance(seq[2]);
}
}
public static CertRequest GetInstance(object obj)
{
if (obj is CertRequest)
return (CertRequest)obj;
if (obj != null)
return new CertRequest(Asn1Sequence.GetInstance(obj));
return null;
}
public CertRequest(
int certReqId,
CertTemplate certTemplate,
Controls controls)
: this(new DerInteger(certReqId), certTemplate, controls)
{
}
public CertRequest(
DerInteger certReqId,
CertTemplate certTemplate,
Controls controls)
{
this.certReqId = certReqId;
this.certTemplate = certTemplate;
this.controls = controls;
}
public virtual DerInteger CertReqID
{
get { return certReqId; }
}
public virtual CertTemplate CertTemplate
{
get { return certTemplate; }
}
public virtual Controls Controls
{
get { return controls; }
}
/**
* <pre>
* CertRequest ::= SEQUENCE {
* certReqId INTEGER, -- ID for matching request and reply
* certTemplate CertTemplate, -- Selected fields of cert to be issued
* controls Controls OPTIONAL } -- Attributes affecting issuance
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector(certReqId, certTemplate);
v.AddOptional(controls);
return new DerSequence(v);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6af25341d32afe64b918925674998e1e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,153 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class CertTemplate
: Asn1Encodable
{
private readonly Asn1Sequence seq;
private readonly DerInteger version;
private readonly DerInteger serialNumber;
private readonly AlgorithmIdentifier signingAlg;
private readonly X509Name issuer;
private readonly OptionalValidity validity;
private readonly X509Name subject;
private readonly SubjectPublicKeyInfo publicKey;
private readonly DerBitString issuerUID;
private readonly DerBitString subjectUID;
private readonly X509Extensions extensions;
private CertTemplate(Asn1Sequence seq)
{
this.seq = seq;
foreach (Asn1TaggedObject tObj in seq)
{
switch (tObj.TagNo)
{
case 0:
version = DerInteger.GetInstance(tObj, false);
break;
case 1:
serialNumber = DerInteger.GetInstance(tObj, false);
break;
case 2:
signingAlg = AlgorithmIdentifier.GetInstance(tObj, false);
break;
case 3:
issuer = X509Name.GetInstance(tObj, true); // CHOICE
break;
case 4:
validity = OptionalValidity.GetInstance(Asn1Sequence.GetInstance(tObj, false));
break;
case 5:
subject = X509Name.GetInstance(tObj, true); // CHOICE
break;
case 6:
publicKey = SubjectPublicKeyInfo.GetInstance(tObj, false);
break;
case 7:
issuerUID = DerBitString.GetInstance(tObj, false);
break;
case 8:
subjectUID = DerBitString.GetInstance(tObj, false);
break;
case 9:
extensions = X509Extensions.GetInstance(tObj, false);
break;
default:
throw new ArgumentException("unknown tag: " + tObj.TagNo, "seq");
}
}
}
public static CertTemplate GetInstance(object obj)
{
if (obj is CertTemplate)
return (CertTemplate)obj;
if (obj != null)
return new CertTemplate(Asn1Sequence.GetInstance(obj));
return null;
}
public virtual int Version
{
get { return version.IntValueExact; }
}
public virtual DerInteger SerialNumber
{
get { return serialNumber; }
}
public virtual AlgorithmIdentifier SigningAlg
{
get { return signingAlg; }
}
public virtual X509Name Issuer
{
get { return issuer; }
}
public virtual OptionalValidity Validity
{
get { return validity; }
}
public virtual X509Name Subject
{
get { return subject; }
}
public virtual SubjectPublicKeyInfo PublicKey
{
get { return publicKey; }
}
public virtual DerBitString IssuerUID
{
get { return issuerUID; }
}
public virtual DerBitString SubjectUID
{
get { return subjectUID; }
}
public virtual X509Extensions Extensions
{
get { return extensions; }
}
/**
* <pre>
* CertTemplate ::= SEQUENCE {
* version [0] Version OPTIONAL,
* serialNumber [1] INTEGER OPTIONAL,
* signingAlg [2] AlgorithmIdentifier OPTIONAL,
* issuer [3] Name OPTIONAL,
* validity [4] OptionalValidity OPTIONAL,
* subject [5] Name OPTIONAL,
* publicKey [6] SubjectPublicKeyInfo OPTIONAL,
* issuerUID [7] UniqueIdentifier OPTIONAL,
* subjectUID [8] UniqueIdentifier OPTIONAL,
* extensions [9] Extensions OPTIONAL }
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
return seq;
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1121577eb63294944a978be8412f172a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,129 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class CertTemplateBuilder
{
private DerInteger version;
private DerInteger serialNumber;
private AlgorithmIdentifier signingAlg;
private X509Name issuer;
private OptionalValidity validity;
private X509Name subject;
private SubjectPublicKeyInfo publicKey;
private DerBitString issuerUID;
private DerBitString subjectUID;
private X509Extensions extensions;
/** Sets the X.509 version. Note: for X509v3, use 2 here. */
public virtual CertTemplateBuilder SetVersion(int ver)
{
version = new DerInteger(ver);
return this;
}
public virtual CertTemplateBuilder SetSerialNumber(DerInteger ser)
{
serialNumber = ser;
return this;
}
public virtual CertTemplateBuilder SetSigningAlg(AlgorithmIdentifier aid)
{
signingAlg = aid;
return this;
}
public virtual CertTemplateBuilder SetIssuer(X509Name name)
{
issuer = name;
return this;
}
public virtual CertTemplateBuilder SetValidity(OptionalValidity v)
{
validity = v;
return this;
}
public virtual CertTemplateBuilder SetSubject(X509Name name)
{
subject = name;
return this;
}
public virtual CertTemplateBuilder SetPublicKey(SubjectPublicKeyInfo spki)
{
publicKey = spki;
return this;
}
/** Sets the issuer unique ID (deprecated in X.509v3) */
public virtual CertTemplateBuilder SetIssuerUID(DerBitString uid)
{
issuerUID = uid;
return this;
}
/** Sets the subject unique ID (deprecated in X.509v3) */
public virtual CertTemplateBuilder SetSubjectUID(DerBitString uid)
{
subjectUID = uid;
return this;
}
public virtual CertTemplateBuilder SetExtensions(X509Extensions extens)
{
extensions = extens;
return this;
}
/**
* <pre>
* CertTemplate ::= SEQUENCE {
* version [0] Version OPTIONAL,
* serialNumber [1] INTEGER OPTIONAL,
* signingAlg [2] AlgorithmIdentifier OPTIONAL,
* issuer [3] Name OPTIONAL,
* validity [4] OptionalValidity OPTIONAL,
* subject [5] Name OPTIONAL,
* publicKey [6] SubjectPublicKeyInfo OPTIONAL,
* issuerUID [7] UniqueIdentifier OPTIONAL,
* subjectUID [8] UniqueIdentifier OPTIONAL,
* extensions [9] Extensions OPTIONAL }
* </pre>
* @return a basic ASN.1 object representation.
*/
public virtual CertTemplate Build()
{
Asn1EncodableVector v = new Asn1EncodableVector();
AddOptional(v, 0, false, version);
AddOptional(v, 1, false, serialNumber);
AddOptional(v, 2, false, signingAlg);
AddOptional(v, 3, true, issuer); // CHOICE
AddOptional(v, 4, false, validity);
AddOptional(v, 5, true, subject); // CHOICE
AddOptional(v, 6, false, publicKey);
AddOptional(v, 7, false, issuerUID);
AddOptional(v, 8, false, subjectUID);
AddOptional(v, 9, false, extensions);
return CertTemplate.GetInstance(new DerSequence(v));
}
private void AddOptional(Asn1EncodableVector v, int tagNo, bool isExplicit, Asn1Encodable obj)
{
if (obj != null)
{
v.Add(new DerTaggedObject(isExplicit, tagNo, obj));
}
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 68e8dab6aededb04fa4a98f8ba95f225
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,59 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using System.Text;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class Controls
: Asn1Encodable
{
private readonly Asn1Sequence content;
private Controls(Asn1Sequence seq)
{
content = seq;
}
public static Controls GetInstance(object obj)
{
if (obj is Controls)
return (Controls)obj;
if (obj is Asn1Sequence)
return new Controls((Asn1Sequence)obj);
throw new ArgumentException("Invalid object: " + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
}
public Controls(params AttributeTypeAndValue[] atvs)
{
content = new DerSequence(atvs);
}
public virtual AttributeTypeAndValue[] ToAttributeTypeAndValueArray()
{
AttributeTypeAndValue[] result = new AttributeTypeAndValue[content.Count];
for (int i = 0; i != result.Length; ++i)
{
result[i] = AttributeTypeAndValue.GetInstance(content[i]);
}
return result;
}
/**
* <pre>
* Controls ::= SEQUENCE SIZE(1..MAX) OF AttributeTypeAndValue
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
return content;
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7181c72771f04904580361d17a8472c5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public abstract class CrmfObjectIdentifiers
{
public static readonly DerObjectIdentifier id_pkix = new DerObjectIdentifier("1.3.6.1.5.5.7");
// arc for Internet X.509 PKI protocols and their components
public static readonly DerObjectIdentifier id_pkip = id_pkix.Branch("5");
public static readonly DerObjectIdentifier id_regCtrl = id_pkip.Branch("1");
public static readonly DerObjectIdentifier id_regCtrl_regToken = id_regCtrl.Branch("1");
public static readonly DerObjectIdentifier id_regCtrl_authenticator = id_regCtrl.Branch("2");
public static readonly DerObjectIdentifier id_regCtrl_pkiPublicationInfo = id_regCtrl.Branch("3");
public static readonly DerObjectIdentifier id_regCtrl_pkiArchiveOptions = id_regCtrl.Branch("4");
public static readonly DerObjectIdentifier id_ct_encKeyWithID = new DerObjectIdentifier(PkcsObjectIdentifiers.IdCT + ".21");
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e4012dc3c092db046a06a77ad11940ea
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,107 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class EncKeyWithID
: Asn1Encodable
{
private readonly PrivateKeyInfo privKeyInfo;
private readonly Asn1Encodable identifier;
public static EncKeyWithID GetInstance(object obj)
{
if (obj is EncKeyWithID)
return (EncKeyWithID)obj;
if (obj != null)
return new EncKeyWithID(Asn1Sequence.GetInstance(obj));
return null;
}
private EncKeyWithID(Asn1Sequence seq)
{
this.privKeyInfo = PrivateKeyInfo.GetInstance(seq[0]);
if (seq.Count > 1)
{
if (!(seq[1] is DerUtf8String))
{
this.identifier = GeneralName.GetInstance(seq[1]);
}
else
{
this.identifier = (Asn1Encodable)seq[1];
}
}
else
{
this.identifier = null;
}
}
public EncKeyWithID(PrivateKeyInfo privKeyInfo)
{
this.privKeyInfo = privKeyInfo;
this.identifier = null;
}
public EncKeyWithID(PrivateKeyInfo privKeyInfo, DerUtf8String str)
{
this.privKeyInfo = privKeyInfo;
this.identifier = str;
}
public EncKeyWithID(PrivateKeyInfo privKeyInfo, GeneralName generalName)
{
this.privKeyInfo = privKeyInfo;
this.identifier = generalName;
}
public virtual PrivateKeyInfo PrivateKey
{
get { return privKeyInfo; }
}
public virtual bool HasIdentifier
{
get { return identifier != null; }
}
public virtual bool IsIdentifierUtf8String
{
get { return identifier is DerUtf8String; }
}
public virtual Asn1Encodable Identifier
{
get { return identifier; }
}
/**
* <pre>
* EncKeyWithID ::= SEQUENCE {
* privateKey PrivateKeyInfo,
* identifier CHOICE {
* string UTF8String,
* generalName GeneralName
* } OPTIONAL
* }
* </pre>
* @return
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector(privKeyInfo);
v.AddOptional(identifier);
return new DerSequence(v);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4d9851431fa9fa749b0d380fc86ade10
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,66 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class EncryptedKey
: Asn1Encodable, IAsn1Choice
{
public static EncryptedKey GetInstance(object obj)
{
if (obj is EncryptedKey encryptedKey)
return encryptedKey;
if (obj is Asn1TaggedObject taggedObject)
return new EncryptedKey(EnvelopedData.GetInstance(taggedObject, false));
return new EncryptedKey(EncryptedValue.GetInstance(obj));
}
private readonly EnvelopedData m_envelopedData;
private readonly EncryptedValue m_encryptedValue;
public EncryptedKey(EnvelopedData envelopedData)
{
m_envelopedData = envelopedData;
}
public EncryptedKey(EncryptedValue encryptedValue)
{
m_encryptedValue = encryptedValue;
}
public virtual bool IsEncryptedValue => m_encryptedValue != null;
public virtual Asn1Encodable Value
{
get
{
if (m_encryptedValue != null)
return m_encryptedValue;
return m_envelopedData;
}
}
/**
* <pre>
* EncryptedKey ::= CHOICE {
* encryptedValue EncryptedValue, -- deprecated
* envelopedData [0] EnvelopedData }
* -- The encrypted private key MUST be placed in the envelopedData
* -- encryptedContentInfo encryptedContent OCTET STRING.
* </pre>
*/
public override Asn1Object ToAsn1Object()
{
if (m_encryptedValue != null)
return m_encryptedValue.ToAsn1Object();
return new DerTaggedObject(false, 0, m_envelopedData);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 987b8baf397675b4b8c1c16838cc119a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,121 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class EncryptedValue
: Asn1Encodable
{
public static EncryptedValue GetInstance(object obj)
{
if (obj is EncryptedValue encryptedValue)
return encryptedValue;
if (obj != null)
return new EncryptedValue(Asn1Sequence.GetInstance(obj));
return null;
}
private readonly AlgorithmIdentifier m_intendedAlg;
private readonly AlgorithmIdentifier m_symmAlg;
private readonly DerBitString m_encSymmKey;
private readonly AlgorithmIdentifier m_keyAlg;
private readonly Asn1OctetString m_valueHint;
private readonly DerBitString m_encValue;
private EncryptedValue(Asn1Sequence seq)
{
int index = 0;
while (seq[index] is Asn1TaggedObject tObj)
{
switch (tObj.TagNo)
{
case 0:
m_intendedAlg = AlgorithmIdentifier.GetInstance(tObj, false);
break;
case 1:
m_symmAlg = AlgorithmIdentifier.GetInstance(tObj, false);
break;
case 2:
m_encSymmKey = DerBitString.GetInstance(tObj, false);
break;
case 3:
m_keyAlg = AlgorithmIdentifier.GetInstance(tObj, false);
break;
case 4:
m_valueHint = Asn1OctetString.GetInstance(tObj, false);
break;
}
++index;
}
m_encValue = DerBitString.GetInstance(seq[index]);
}
public EncryptedValue(AlgorithmIdentifier intendedAlg, AlgorithmIdentifier symmAlg, DerBitString encSymmKey,
AlgorithmIdentifier keyAlg, Asn1OctetString valueHint, DerBitString encValue)
{
if (encValue == null)
throw new ArgumentNullException(nameof(encValue));
m_intendedAlg = intendedAlg;
m_symmAlg = symmAlg;
m_encSymmKey = encSymmKey;
m_keyAlg = keyAlg;
m_valueHint = valueHint;
m_encValue = encValue;
}
public virtual AlgorithmIdentifier IntendedAlg => m_intendedAlg;
public virtual AlgorithmIdentifier SymmAlg => m_symmAlg;
public virtual DerBitString EncSymmKey => m_encSymmKey;
public virtual AlgorithmIdentifier KeyAlg => m_keyAlg;
public virtual Asn1OctetString ValueHint => m_valueHint;
public virtual DerBitString EncValue => m_encValue;
/**
* <pre>
* (IMPLICIT TAGS)
* EncryptedValue ::= SEQUENCE {
* intendedAlg [0] AlgorithmIdentifier OPTIONAL,
* -- the intended algorithm for which the value will be used
* symmAlg [1] AlgorithmIdentifier OPTIONAL,
* -- the symmetric algorithm used to encrypt the value
* encSymmKey [2] BIT STRING OPTIONAL,
* -- the (encrypted) symmetric key used to encrypt the value
* keyAlg [3] AlgorithmIdentifier OPTIONAL,
* -- algorithm used to encrypt the symmetric key
* valueHint [4] OCTET STRING OPTIONAL,
* -- a brief description or identifier of the encValue content
* -- (may be meaningful only to the sending entity, and used only
* -- if EncryptedValue might be re-examined by the sending entity
* -- in the future)
* encValue BIT STRING }
* -- the encrypted value itself
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector();
v.AddOptionalTagged(false, 0, m_intendedAlg);
v.AddOptionalTagged(false, 1, m_symmAlg);
v.AddOptionalTagged(false, 2, m_encSymmKey);
v.AddOptionalTagged(false, 3, m_keyAlg);
v.AddOptionalTagged(false, 4, m_valueHint);
v.Add(m_encValue);
return new DerSequence(v);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 384131c555e30744da1edefbb044e78e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,72 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class OptionalValidity
: Asn1Encodable
{
private readonly Time notBefore;
private readonly Time notAfter;
private OptionalValidity(Asn1Sequence seq)
{
foreach (Asn1TaggedObject tObj in seq)
{
if (tObj.TagNo == 0)
{
notBefore = Time.GetInstance(tObj, true);
}
else
{
notAfter = Time.GetInstance(tObj, true);
}
}
}
public static OptionalValidity GetInstance(object obj)
{
if (obj == null || obj is OptionalValidity)
return (OptionalValidity)obj;
return new OptionalValidity(Asn1Sequence.GetInstance(obj));
}
public OptionalValidity(Time notBefore, Time notAfter)
{
this.notBefore = notBefore;
this.notAfter = notAfter;
}
public virtual Time NotBefore
{
get { return notBefore; }
}
public virtual Time NotAfter
{
get { return notAfter; }
}
/**
* <pre>
* OptionalValidity ::= SEQUENCE {
* notBefore [0] Time OPTIONAL,
* notAfter [1] Time OPTIONAL } --at least one MUST be present
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector();
v.AddOptionalTagged(true, 0, notBefore);
v.AddOptionalTagged(true, 1, notAfter);
return new DerSequence(v);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1f1791c18ff6755478877daf115e5d74
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,111 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class PkiArchiveOptions
: Asn1Encodable, IAsn1Choice
{
public const int encryptedPrivKey = 0;
public const int keyGenParameters = 1;
public const int archiveRemGenPrivKey = 2;
private readonly Asn1Encodable value;
public static PkiArchiveOptions GetInstance(object obj)
{
if (obj is PkiArchiveOptions)
return (PkiArchiveOptions)obj;
if (obj is Asn1TaggedObject)
return new PkiArchiveOptions((Asn1TaggedObject)obj);
throw new ArgumentException("Invalid object: " + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
}
private PkiArchiveOptions(Asn1TaggedObject tagged)
{
switch (tagged.TagNo)
{
case encryptedPrivKey:
value = EncryptedKey.GetInstance(tagged.GetObject());
break;
case keyGenParameters:
value = Asn1OctetString.GetInstance(tagged, false);
break;
case archiveRemGenPrivKey:
value = DerBoolean.GetInstance(tagged, false);
break;
default:
throw new ArgumentException("unknown tag number: " + tagged.TagNo, "tagged");
}
}
public PkiArchiveOptions(EncryptedKey encKey)
{
this.value = encKey;
}
public PkiArchiveOptions(Asn1OctetString keyGenParameters)
{
this.value = keyGenParameters;
}
public PkiArchiveOptions(bool archiveRemGenPrivKey)
{
this.value = DerBoolean.GetInstance(archiveRemGenPrivKey);
}
public virtual int Type
{
get
{
if (value is EncryptedKey)
return encryptedPrivKey;
if (value is Asn1OctetString)
return keyGenParameters;
return archiveRemGenPrivKey;
}
}
public virtual Asn1Encodable Value
{
get { return value; }
}
/**
* <pre>
* PkiArchiveOptions ::= CHOICE {
* encryptedPrivKey [0] EncryptedKey,
* -- the actual value of the private key
* keyGenParameters [1] KeyGenParameters,
* -- parameters which allow the private key to be re-generated
* archiveRemGenPrivKey [2] BOOLEAN }
* -- set to TRUE if sender wishes receiver to archive the private
* -- key of a key pair that the receiver generates in response to
* -- this request; set to FALSE if no archival is desired.
* </pre>
*/
public override Asn1Object ToAsn1Object()
{
if (value is EncryptedKey)
{
return new DerTaggedObject(true, encryptedPrivKey, value); // choice
}
if (value is Asn1OctetString)
{
return new DerTaggedObject(false, keyGenParameters, value);
}
return new DerTaggedObject(false, archiveRemGenPrivKey, value);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fb54bc848ddbe7142a167523c41379b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,116 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Math;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
/**
* <pre>
* PKIPublicationInfo ::= SEQUENCE {
* action INTEGER {
* dontPublish (0),
* pleasePublish (1) },
* pubInfos SEQUENCE SIZE (1..MAX) OF SinglePubInfo OPTIONAL }
* -- pubInfos MUST NOT be present if action is "dontPublish"
* -- (if action is "pleasePublish" and pubInfos is omitted,
* -- "dontCare" is assumed)
* </pre>
*/
public class PkiPublicationInfo
: Asn1Encodable
{
public static readonly DerInteger DontPublish = new DerInteger(0);
public static readonly DerInteger PleasePublish = new DerInteger(1);
public static PkiPublicationInfo GetInstance(object obj)
{
if (obj is PkiPublicationInfo pkiPublicationInfo)
return pkiPublicationInfo;
if (obj != null)
return new PkiPublicationInfo(Asn1Sequence.GetInstance(obj));
return null;
}
private readonly DerInteger m_action;
private readonly Asn1Sequence m_pubInfos;
private PkiPublicationInfo(Asn1Sequence seq)
{
m_action = DerInteger.GetInstance(seq[0]);
if (seq.Count > 1)
{
m_pubInfos = Asn1Sequence.GetInstance(seq[1]);
}
}
public PkiPublicationInfo(BigInteger action)
: this(new DerInteger(action))
{
}
public PkiPublicationInfo(DerInteger action)
{
m_action = action;
}
/**
* Constructor with a single pubInfo, assumes pleasePublish as the action.
*
* @param pubInfo the pubInfo to be published (can be null if don't care is required).
*/
public PkiPublicationInfo(SinglePubInfo pubInfo)
: this(pubInfo != null ? new SinglePubInfo[1]{ pubInfo } : null)
{
}
/**
* Constructor with multiple pubInfo, assumes pleasePublish as the action.
*
* @param pubInfos the pubInfos to be published (can be null if don't care is required).
*/
public PkiPublicationInfo(SinglePubInfo[] pubInfos)
{
m_action = PleasePublish;
if (pubInfos != null)
{
m_pubInfos = new DerSequence(pubInfos);
}
}
public virtual DerInteger Action => m_action;
public virtual SinglePubInfo[] GetPubInfos()
{
if (m_pubInfos == null)
return null;
return m_pubInfos.MapElements(SinglePubInfo.GetInstance);
}
/**
* <pre>
* PkiPublicationInfo ::= SEQUENCE {
* action INTEGER {
* dontPublish (0),
* pleasePublish (1) },
* pubInfos SEQUENCE SIZE (1..MAX) OF SinglePubInfo OPTIONAL }
* -- pubInfos MUST NOT be present if action is "dontPublish"
* -- (if action is "pleasePublish" and pubInfos is omitted,
* -- "dontCare" is assumed)
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
if (m_pubInfos == null)
return new DerSequence(m_action);
return new DerSequence(m_action, m_pubInfos);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b092b0381196e13428b372cefd759e9a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,94 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cmp;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
/**
* Password-based MAC value for use with POPOSigningKeyInput.
*/
public class PKMacValue
: Asn1Encodable
{
private readonly AlgorithmIdentifier algID;
private readonly DerBitString macValue;
private PKMacValue(Asn1Sequence seq)
{
this.algID = AlgorithmIdentifier.GetInstance(seq[0]);
this.macValue = DerBitString.GetInstance(seq[1]);
}
public static PKMacValue GetInstance(object obj)
{
if (obj is PKMacValue)
return (PKMacValue)obj;
if (obj is Asn1Sequence)
return new PKMacValue((Asn1Sequence)obj);
throw new ArgumentException("Invalid object: " + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
}
public static PKMacValue GetInstance(Asn1TaggedObject obj, bool isExplicit)
{
return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
}
/**
* Creates a new PKMACValue.
* @param params parameters for password-based MAC
* @param value MAC of the DER-encoded SubjectPublicKeyInfo
*/
public PKMacValue(
PbmParameter pbmParams,
DerBitString macValue)
: this(new AlgorithmIdentifier(CmpObjectIdentifiers.passwordBasedMac, pbmParams), macValue)
{
}
/**
* Creates a new PKMACValue.
* @param aid CMPObjectIdentifiers.passwordBasedMAC, with PBMParameter
* @param value MAC of the DER-encoded SubjectPublicKeyInfo
*/
public PKMacValue(
AlgorithmIdentifier algID,
DerBitString macValue)
{
this.algID = algID;
this.macValue = macValue;
}
public virtual AlgorithmIdentifier AlgID
{
get { return algID; }
}
public virtual DerBitString MacValue
{
get { return macValue; }
}
/**
* <pre>
* PKMACValue ::= SEQUENCE {
* algId AlgorithmIdentifier,
* -- algorithm value shall be PasswordBasedMac 1.2.840.113533.7.66.13
* -- parameter value is PBMParameter
* value BIT STRING }
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
return new DerSequence(algID, macValue);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 95cf0bd85d68cb0439a7cb22a794ecc7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,88 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class PopoPrivKey
: Asn1Encodable, IAsn1Choice
{
public const int thisMessage = 0;
public const int subsequentMessage = 1;
public const int dhMAC = 2;
public const int agreeMAC = 3;
public const int encryptedKey = 4;
private readonly int tagNo;
private readonly Asn1Encodable obj;
private PopoPrivKey(Asn1TaggedObject obj)
{
this.tagNo = obj.TagNo;
switch (tagNo)
{
case thisMessage:
this.obj = DerBitString.GetInstance(obj, false);
break;
case subsequentMessage:
this.obj = SubsequentMessage.ValueOf(DerInteger.GetInstance(obj, false).IntValueExact);
break;
case dhMAC:
this.obj = DerBitString.GetInstance(obj, false);
break;
case agreeMAC:
this.obj = PKMacValue.GetInstance(obj, false);
break;
case encryptedKey:
this.obj = EnvelopedData.GetInstance(obj, false);
break;
default:
throw new ArgumentException("unknown tag in PopoPrivKey", "obj");
}
}
public static PopoPrivKey GetInstance(Asn1TaggedObject tagged, bool isExplicit)
{
return new PopoPrivKey(Asn1TaggedObject.GetInstance(tagged, true));
}
public PopoPrivKey(SubsequentMessage msg)
{
this.tagNo = subsequentMessage;
this.obj = msg;
}
public virtual int Type
{
get { return tagNo; }
}
public virtual Asn1Encodable Value
{
get { return obj; }
}
/**
* <pre>
* PopoPrivKey ::= CHOICE {
* thisMessage [0] BIT STRING, -- Deprecated
* -- possession is proven in this message (which contains the private
* -- key itself (encrypted for the CA))
* subsequentMessage [1] SubsequentMessage,
* -- possession will be proven in a subsequent message
* dhMAC [2] BIT STRING, -- Deprecated
* agreeMAC [3] PKMACValue,
* encryptedKey [4] EnvelopedData }
* </pre>
*/
public override Asn1Object ToAsn1Object()
{
return new DerTaggedObject(false, tagNo, obj);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f28283b87adf8414b8447039f9e98f91
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,114 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class PopoSigningKey
: Asn1Encodable
{
private readonly PopoSigningKeyInput poposkInput;
private readonly AlgorithmIdentifier algorithmIdentifier;
private readonly DerBitString signature;
private PopoSigningKey(Asn1Sequence seq)
{
int index = 0;
if (seq[index] is Asn1TaggedObject)
{
Asn1TaggedObject tagObj
= (Asn1TaggedObject) seq[index++];
if (tagObj.TagNo != 0)
{
throw new ArgumentException( "Unknown PopoSigningKeyInput tag: " + tagObj.TagNo, "seq");
}
poposkInput = PopoSigningKeyInput.GetInstance(tagObj.GetObject());
}
algorithmIdentifier = AlgorithmIdentifier.GetInstance(seq[index++]);
signature = DerBitString.GetInstance(seq[index]);
}
public static PopoSigningKey GetInstance(object obj)
{
if (obj is PopoSigningKey)
return (PopoSigningKey)obj;
if (obj is Asn1Sequence)
return new PopoSigningKey((Asn1Sequence)obj);
throw new ArgumentException("Invalid object: " + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
}
public static PopoSigningKey GetInstance(Asn1TaggedObject obj, bool isExplicit)
{
return GetInstance(Asn1Sequence.GetInstance(obj, isExplicit));
}
/**
* Creates a new Proof of Possession object for a signing key.
* @param poposkIn the PopoSigningKeyInput structure, or null if the
* CertTemplate includes both subject and publicKey values.
* @param aid the AlgorithmIdentifier used to sign the proof of possession.
* @param signature a signature over the DER-encoded value of poposkIn,
* or the DER-encoded value of certReq if poposkIn is null.
*/
public PopoSigningKey(
PopoSigningKeyInput poposkIn,
AlgorithmIdentifier aid,
DerBitString signature)
{
this.poposkInput = poposkIn;
this.algorithmIdentifier = aid;
this.signature = signature;
}
public virtual PopoSigningKeyInput PoposkInput
{
get { return poposkInput; }
}
public virtual AlgorithmIdentifier AlgorithmIdentifier
{
get { return algorithmIdentifier; }
}
public virtual DerBitString Signature
{
get { return signature; }
}
/**
* <pre>
* PopoSigningKey ::= SEQUENCE {
* poposkInput [0] PopoSigningKeyInput OPTIONAL,
* algorithmIdentifier AlgorithmIdentifier,
* signature BIT STRING }
* -- The signature (using "algorithmIdentifier") is on the
* -- DER-encoded value of poposkInput. NOTE: If the CertReqMsg
* -- certReq CertTemplate contains the subject and publicKey values,
* -- then poposkInput MUST be omitted and the signature MUST be
* -- computed on the DER-encoded value of CertReqMsg certReq. If
* -- the CertReqMsg certReq CertTemplate does not contain the public
* -- key and subject values, then poposkInput MUST be present and
* -- MUST be signed. This strategy ensures that the public key is
* -- not present in both the poposkInput and CertReqMsg certReq
* -- CertTemplate fields.
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector();
v.AddOptionalTagged(false, 0, poposkInput);
v.Add(algorithmIdentifier);
v.Add(signature);
return new DerSequence(v);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6208fd84c2584df449899d3bba939bd9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,120 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class PopoSigningKeyInput
: Asn1Encodable
{
private readonly GeneralName sender;
private readonly PKMacValue publicKeyMac;
private readonly SubjectPublicKeyInfo publicKey;
private PopoSigningKeyInput(Asn1Sequence seq)
{
Asn1Encodable authInfo = (Asn1Encodable)seq[0];
if (authInfo is Asn1TaggedObject)
{
Asn1TaggedObject tagObj = (Asn1TaggedObject)authInfo;
if (tagObj.TagNo != 0)
{
throw new ArgumentException("Unknown authInfo tag: " + tagObj.TagNo, "seq");
}
sender = GeneralName.GetInstance(tagObj.GetObject());
}
else
{
publicKeyMac = PKMacValue.GetInstance(authInfo);
}
publicKey = SubjectPublicKeyInfo.GetInstance(seq[1]);
}
public static PopoSigningKeyInput GetInstance(object obj)
{
if (obj is PopoSigningKeyInput)
return (PopoSigningKeyInput)obj;
if (obj is Asn1Sequence)
return new PopoSigningKeyInput((Asn1Sequence)obj);
throw new ArgumentException("Invalid object: " + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
}
/** Creates a new PopoSigningKeyInput with sender name as authInfo. */
public PopoSigningKeyInput(
GeneralName sender,
SubjectPublicKeyInfo spki)
{
this.sender = sender;
this.publicKey = spki;
}
/** Creates a new PopoSigningKeyInput using password-based MAC. */
public PopoSigningKeyInput(
PKMacValue pkmac,
SubjectPublicKeyInfo spki)
{
this.publicKeyMac = pkmac;
this.publicKey = spki;
}
/** Returns the sender field, or null if authInfo is publicKeyMac */
public virtual GeneralName Sender
{
get { return sender; }
}
/** Returns the publicKeyMac field, or null if authInfo is sender */
public virtual PKMacValue PublicKeyMac
{
get { return publicKeyMac; }
}
public virtual SubjectPublicKeyInfo PublicKey
{
get { return publicKey; }
}
/**
* <pre>
* PopoSigningKeyInput ::= SEQUENCE {
* authInfo CHOICE {
* sender [0] GeneralName,
* -- used only if an authenticated identity has been
* -- established for the sender (e.g., a DN from a
* -- previously-issued and currently-valid certificate
* publicKeyMac PKMacValue },
* -- used if no authenticated GeneralName currently exists for
* -- the sender; publicKeyMac contains a password-based MAC
* -- on the DER-encoded value of publicKey
* publicKey SubjectPublicKeyInfo } -- from CertTemplate
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector();
if (sender != null)
{
v.Add(new DerTaggedObject(false, 0, sender));
}
else
{
v.Add(publicKeyMac);
}
v.Add(publicKey);
return new DerSequence(v);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2412d787b4f435545abff0826e0c9e4d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,104 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class ProofOfPossession
: Asn1Encodable, IAsn1Choice
{
public const int TYPE_RA_VERIFIED = 0;
public const int TYPE_SIGNING_KEY = 1;
public const int TYPE_KEY_ENCIPHERMENT = 2;
public const int TYPE_KEY_AGREEMENT = 3;
private readonly int tagNo;
private readonly Asn1Encodable obj;
private ProofOfPossession(Asn1TaggedObject tagged)
{
tagNo = tagged.TagNo;
switch (tagNo)
{
case 0:
obj = DerNull.Instance;
break;
case 1:
obj = PopoSigningKey.GetInstance(tagged, false);
break;
case 2:
case 3:
obj = PopoPrivKey.GetInstance(tagged, false);
break;
default:
throw new ArgumentException("unknown tag: " + tagNo, "tagged");
}
}
public static ProofOfPossession GetInstance(object obj)
{
if (obj is ProofOfPossession)
return (ProofOfPossession)obj;
if (obj is Asn1TaggedObject)
return new ProofOfPossession((Asn1TaggedObject)obj);
throw new ArgumentException("Invalid object: " + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
}
/** Creates a ProofOfPossession with type raVerified. */
public ProofOfPossession()
{
tagNo = TYPE_RA_VERIFIED;
obj = DerNull.Instance;
}
/** Creates a ProofOfPossession for a signing key. */
public ProofOfPossession(PopoSigningKey Poposk)
{
tagNo = TYPE_SIGNING_KEY;
obj = Poposk;
}
/**
* Creates a ProofOfPossession for key encipherment or agreement.
* @param type one of TYPE_KEY_ENCIPHERMENT or TYPE_KEY_AGREEMENT
*/
public ProofOfPossession(int type, PopoPrivKey privkey)
{
tagNo = type;
obj = privkey;
}
public virtual int Type
{
get { return tagNo; }
}
public virtual Asn1Encodable Object
{
get { return obj; }
}
/**
* <pre>
* ProofOfPossession ::= CHOICE {
* raVerified [0] NULL,
* -- used if the RA has already verified that the requester is in
* -- possession of the private key
* signature [1] PopoSigningKey,
* keyEncipherment [2] PopoPrivKey,
* keyAgreement [3] PopoPrivKey }
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
return new DerTaggedObject(false, tagNo, obj);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d7ca0880911f99c44b8163c48da74263
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class SinglePubInfo
: Asn1Encodable
{
private readonly DerInteger pubMethod;
private readonly GeneralName pubLocation;
private SinglePubInfo(Asn1Sequence seq)
{
pubMethod = DerInteger.GetInstance(seq[0]);
if (seq.Count == 2)
{
pubLocation = GeneralName.GetInstance(seq[1]);
}
}
public static SinglePubInfo GetInstance(object obj)
{
if (obj is SinglePubInfo)
return (SinglePubInfo)obj;
if (obj is Asn1Sequence)
return new SinglePubInfo((Asn1Sequence)obj);
throw new ArgumentException("Invalid object: " + Org.BouncyCastle.Utilities.Platform.GetTypeName(obj), "obj");
}
public virtual GeneralName PubLocation
{
get { return pubLocation; }
}
/**
* <pre>
* SinglePubInfo ::= SEQUENCE {
* pubMethod INTEGER {
* dontCare (0),
* x500 (1),
* web (2),
* ldap (3) },
* pubLocation GeneralName OPTIONAL }
* </pre>
* @return a basic ASN.1 object representation.
*/
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector(pubMethod);
v.AddOptional(pubLocation);
return new DerSequence(v);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 645932d2306ef97438653d481b2e9963
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf
{
public class SubsequentMessage
: DerInteger
{
public static readonly SubsequentMessage encrCert = new SubsequentMessage(0);
public static readonly SubsequentMessage challengeResp = new SubsequentMessage(1);
private SubsequentMessage(int value)
: base(value)
{
}
public static SubsequentMessage ValueOf(int value)
{
if (value == 0)
return encrCert;
if (value == 1)
return challengeResp;
throw new ArgumentException("unknown value: " + value, "value");
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f6c948121986aaf45bede1acf7e93383
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: