提交Unity 联机Pro

This commit is contained in:
PC-20230316NUNE\Administrator
2024-08-17 14:27:18 +08:00
parent f00193b000
commit 894100ae37
7448 changed files with 854473 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crmf
{
/// <summary>
/// Carrier for an authenticator control.
/// </summary>
public class AuthenticatorControl
: IControl
{
private static readonly DerObjectIdentifier type = CrmfObjectIdentifiers.id_regCtrl_authenticator;
private readonly DerUtf8String token;
/// <summary>
/// Basic constructor - build from a UTF-8 string representing the token.
/// </summary>
/// <param name="token">UTF-8 string representing the token.</param>
public AuthenticatorControl(DerUtf8String token)
{
this.token = token;
}
/// <summary>
/// Basic constructor - build from a string representing the token.
/// </summary>
/// <param name="token">string representing the token.</param>
public AuthenticatorControl(string token)
{
this.token = new DerUtf8String(token);
}
/// <summary>
/// Return the type of this control.
/// </summary>
public DerObjectIdentifier Type
{
get { return type; }
}
/// <summary>
/// Return the token associated with this control (a UTF8String).
/// </summary>
public Asn1Encodable Value
{
get { return token; }
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 28a1a8a8f104c564bb93406b47ed90bd
timeCreated: 1572510027
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,233 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Operators;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crmf
{
public class CertificateRequestMessage
{
public static readonly int popRaVerified = BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf.ProofOfPossession.TYPE_RA_VERIFIED;
public static readonly int popSigningKey = BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf.ProofOfPossession.TYPE_SIGNING_KEY;
public static readonly int popKeyEncipherment = BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf.ProofOfPossession.TYPE_KEY_ENCIPHERMENT;
public static readonly int popKeyAgreement = BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf.ProofOfPossession.TYPE_KEY_AGREEMENT;
private readonly CertReqMsg certReqMsg;
private readonly Controls controls;
private static CertReqMsg ParseBytes(byte[] encoding)
{
return CertReqMsg.GetInstance(encoding);
}
/// <summary>
/// Create a CertificateRequestMessage from the passed in bytes.
/// </summary>
/// <param name="encoded">BER/DER encoding of the CertReqMsg structure.</param>
public CertificateRequestMessage(byte[] encoded)
: this(CertReqMsg.GetInstance(encoded))
{
}
public CertificateRequestMessage(CertReqMsg certReqMsg)
{
this.certReqMsg = certReqMsg;
this.controls = certReqMsg.CertReq.Controls;
}
/// <summary>
/// Return the underlying ASN.1 object defining this CertificateRequestMessage object.
/// </summary>
/// <returns>A CertReqMsg</returns>
public CertReqMsg ToAsn1Structure()
{
return certReqMsg;
}
/// <summary>
/// Return the certificate template contained in this message.
/// </summary>
/// <returns>a CertTemplate structure.</returns>
public CertTemplate GetCertTemplate()
{
return this.certReqMsg.CertReq.CertTemplate;
}
/// <summary>
/// Return whether or not this request has control values associated with it.
/// </summary>
/// <returns>true if there are control values present, false otherwise.</returns>
public bool HasControls
{
get { return controls != null; }
}
/// <summary>
/// Return whether or not this request has a specific type of control value.
/// </summary>
/// <param name="objectIdentifier">the type OID for the control value we are checking for.</param>
/// <returns>true if a control value of type is present, false otherwise.</returns>
public bool HasControl(DerObjectIdentifier objectIdentifier)
{
return FindControl(objectIdentifier) != null;
}
/// <summary>
/// Return a control value of the specified type.
/// </summary>
/// <param name="type">the type OID for the control value we are checking for.</param>
/// <returns>the control value if present, null otherwise.</returns>
public IControl GetControl(DerObjectIdentifier type)
{
AttributeTypeAndValue found = FindControl(type);
if (found != null)
{
if (found.Type.Equals(CrmfObjectIdentifiers.id_regCtrl_pkiArchiveOptions))
{
return new PkiArchiveControl(PkiArchiveOptions.GetInstance(found.Value));
}
if (found.Type.Equals(CrmfObjectIdentifiers.id_regCtrl_regToken))
{
return new RegTokenControl(DerUtf8String.GetInstance(found.Value));
}
if (found.Type.Equals(CrmfObjectIdentifiers.id_regCtrl_authenticator))
{
return new AuthenticatorControl(DerUtf8String.GetInstance(found.Value));
}
}
return null;
}
public AttributeTypeAndValue FindControl(DerObjectIdentifier type)
{
if (controls == null)
{
return null;
}
AttributeTypeAndValue[] tAndV = controls.ToAttributeTypeAndValueArray();
AttributeTypeAndValue found = null;
for (int i = 0; i < tAndV.Length; i++)
{
if (tAndV[i].Type.Equals(type))
{
found = tAndV[i];
break;
}
}
return found;
}
/// <summary>
/// Return whether or not this request message has a proof-of-possession field in it.
/// </summary>
/// <returns>true if proof-of-possession is present, false otherwise.</returns>
public bool HasProofOfPossession
{
get { return certReqMsg.Popo != null; }
}
/// <summary>
/// Return the type of the proof-of-possession this request message provides.
/// </summary>
/// <returns>one of: popRaVerified, popSigningKey, popKeyEncipherment, popKeyAgreement</returns>
public int ProofOfPossession
{
get { return certReqMsg.Popo.Type; }
}
/// <summary>
/// Return whether or not the proof-of-possession (POP) is of the type popSigningKey and
/// it has a public key MAC associated with it.
/// </summary>
/// <returns>true if POP is popSigningKey and a PKMAC is present, false otherwise.</returns>
public bool HasSigningKeyProofOfPossessionWithPkMac
{
get
{
ProofOfPossession pop = certReqMsg.Popo;
if (pop.Type == popSigningKey)
{
PopoSigningKey popoSign = PopoSigningKey.GetInstance(pop.Object);
return popoSign.PoposkInput.PublicKeyMac != null;
}
return false;
}
}
/// <summary>
/// Return whether or not a signing key proof-of-possession (POP) is valid.
/// </summary>
/// <param name="verifierProvider">a provider that can produce content verifiers for the signature contained in this POP.</param>
/// <returns>true if the POP is valid, false otherwise.</returns>
/// <exception cref="InvalidOperationException">if there is a problem in verification or content verifier creation.</exception>
/// <exception cref="InvalidOperationException">if POP not appropriate.</exception>
public bool IsValidSigningKeyPop(IVerifierFactoryProvider verifierProvider)
{
ProofOfPossession pop = certReqMsg.Popo;
if (pop.Type == popSigningKey)
{
PopoSigningKey popoSign = PopoSigningKey.GetInstance(pop.Object);
if (popoSign.PoposkInput != null && popoSign.PoposkInput.PublicKeyMac != null)
{
throw new InvalidOperationException("verification requires password check");
}
return verifySignature(verifierProvider, popoSign);
}
throw new InvalidOperationException("not Signing Key type of proof of possession");
}
private bool verifySignature(IVerifierFactoryProvider verifierFactoryProvider, PopoSigningKey signKey)
{
IVerifierFactory verifer;
IStreamCalculator<IVerifier> calculator;
try
{
verifer = verifierFactoryProvider.CreateVerifierFactory(signKey.AlgorithmIdentifier);
calculator = verifer.CreateCalculator();
}
catch (Exception ex)
{
throw new CrmfException("unable to create verifier: " + ex.Message, ex);
}
if (signKey.PoposkInput != null)
{
byte[] b = signKey.GetDerEncoded();
calculator.Stream.Write(b, 0, b.Length);
}
else
{
byte[] b = certReqMsg.CertReq.GetDerEncoded();
calculator.Stream.Write(b, 0, b.Length);
}
IVerifier result = calculator.GetResult();
return result.IsVerified(signKey.Signature.GetBytes());
}
/// <summary>
/// Return the ASN.1 encoding of the certReqMsg we wrap.
/// </summary>
/// <returns>a byte array containing the binary encoding of the certReqMsg.</returns>
public byte[] GetEncoded()
{
return certReqMsg.GetEncoded();
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 5697d71e405982946a806d7706eca78d
timeCreated: 1572510030
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,269 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using System.Collections.Generic;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Math;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crmf
{
public class CertificateRequestMessageBuilder
{
private readonly BigInteger _certReqId;
private X509ExtensionsGenerator _extGenerator;
private CertTemplateBuilder _templateBuilder;
private IList<IControl> m_controls = new List<IControl>();
private ISignatureFactory _popSigner;
private PKMacBuilder _pkMacBuilder;
private char[] _password;
private GeneralName _sender;
private int _popoType = ProofOfPossession.TYPE_KEY_ENCIPHERMENT;
private PopoPrivKey _popoPrivKey;
private Asn1Null _popRaVerified;
private PKMacValue _agreeMac;
public CertificateRequestMessageBuilder(BigInteger certReqId)
{
this._certReqId = certReqId;
this._extGenerator = new X509ExtensionsGenerator();
this._templateBuilder = new CertTemplateBuilder();
}
public CertificateRequestMessageBuilder SetPublicKey(SubjectPublicKeyInfo publicKeyInfo)
{
if (publicKeyInfo != null)
{
_templateBuilder.SetPublicKey(publicKeyInfo);
}
return this;
}
public CertificateRequestMessageBuilder SetIssuer(X509Name issuer)
{
if (issuer != null)
{
_templateBuilder.SetIssuer(issuer);
}
return this;
}
public CertificateRequestMessageBuilder SetSubject(X509Name subject)
{
if (subject != null)
{
_templateBuilder.SetSubject(subject);
}
return this;
}
public CertificateRequestMessageBuilder SetSerialNumber(BigInteger serialNumber)
{
if (serialNumber != null)
{
_templateBuilder.SetSerialNumber(new DerInteger(serialNumber));
}
return this;
}
public CertificateRequestMessageBuilder SetValidity(DateTime? notBefore, DateTime? notAfter)
{
_templateBuilder.SetValidity(new OptionalValidity(CreateTime(notBefore), CreateTime(notAfter)));
return this;
}
public CertificateRequestMessageBuilder AddExtension(DerObjectIdentifier oid, bool critical,
Asn1Encodable value)
{
_extGenerator.AddExtension(oid, critical, value);
return this;
}
public CertificateRequestMessageBuilder AddExtension(DerObjectIdentifier oid, bool critical,
byte[] value)
{
_extGenerator.AddExtension(oid, critical, value);
return this;
}
public CertificateRequestMessageBuilder AddControl(IControl control)
{
m_controls.Add(control);
return this;
}
public CertificateRequestMessageBuilder SetProofOfPossessionSignKeySigner(ISignatureFactory popoSignatureFactory)
{
if (_popoPrivKey != null || _popRaVerified != null || _agreeMac != null)
{
throw new InvalidOperationException("only one proof of possession is allowed.");
}
this._popSigner = popoSignatureFactory;
return this;
}
public CertificateRequestMessageBuilder SetProofOfPossessionSubsequentMessage(SubsequentMessage msg)
{
if (_popoPrivKey != null || _popRaVerified != null || _agreeMac != null)
{
throw new InvalidOperationException("only one proof of possession is allowed.");
}
this._popoType = ProofOfPossession.TYPE_KEY_ENCIPHERMENT;
this._popoPrivKey = new PopoPrivKey(msg);
return this;
}
public CertificateRequestMessageBuilder SetProofOfPossessionSubsequentMessage(int type, SubsequentMessage msg)
{
if (_popoPrivKey != null || _popRaVerified != null || _agreeMac != null)
{
throw new InvalidOperationException("only one proof of possession is allowed.");
}
if (type != ProofOfPossession.TYPE_KEY_ENCIPHERMENT && type != ProofOfPossession.TYPE_KEY_AGREEMENT)
{
throw new ArgumentException("type must be ProofOfPossession.TYPE_KEY_ENCIPHERMENT || ProofOfPossession.TYPE_KEY_AGREEMENT");
}
this._popoType = type;
this._popoPrivKey = new PopoPrivKey(msg);
return this;
}
public CertificateRequestMessageBuilder SetProofOfPossessionAgreeMac(PKMacValue macValue)
{
if (_popSigner != null || _popRaVerified != null || _popoPrivKey != null)
{
throw new InvalidOperationException("only one proof of possession allowed");
}
this._agreeMac = macValue;
return this;
}
public CertificateRequestMessageBuilder SetProofOfPossessionRaVerified()
{
if (_popSigner != null || _popoPrivKey != null)
{
throw new InvalidOperationException("only one proof of possession allowed");
}
this._popRaVerified = DerNull.Instance;
return this;
}
public CertificateRequestMessageBuilder SetAuthInfoPKMAC(PKMacBuilder pkmacFactory, char[] password)
{
this._pkMacBuilder = pkmacFactory;
this._password = password;
return this;
}
public CertificateRequestMessageBuilder SetAuthInfoSender(X509Name sender)
{
return SetAuthInfoSender(new GeneralName(sender));
}
public CertificateRequestMessageBuilder SetAuthInfoSender(GeneralName sender)
{
this._sender = sender;
return this;
}
public CertificateRequestMessage Build()
{
Asn1EncodableVector v = new Asn1EncodableVector(new DerInteger(this._certReqId));
if (!this._extGenerator.IsEmpty)
{
this._templateBuilder.SetExtensions(_extGenerator.Generate());
}
v.Add(_templateBuilder.Build());
if (m_controls.Count > 0)
{
Asn1EncodableVector controlV = new Asn1EncodableVector();
foreach (var control in m_controls)
{
controlV.Add(new AttributeTypeAndValue(control.Type, control.Value));
}
v.Add(new DerSequence(controlV));
}
CertRequest request = CertRequest.GetInstance(new DerSequence(v));
v = new Asn1EncodableVector(request);
if (_popSigner != null)
{
CertTemplate template = request.CertTemplate;
if (template.Subject == null || template.PublicKey == null)
{
SubjectPublicKeyInfo pubKeyInfo = request.CertTemplate.PublicKey;
ProofOfPossessionSigningKeyBuilder builder = new ProofOfPossessionSigningKeyBuilder(pubKeyInfo);
if (_sender != null)
{
builder.SetSender(_sender);
}
else
{
//PKMACValueGenerator pkmacGenerator = new PKMACValueGenerator(_pkmacBuilder);
builder.SetPublicKeyMac(_pkMacBuilder, _password);
}
v.Add(new ProofOfPossession(builder.Build(_popSigner)));
}
else
{
ProofOfPossessionSigningKeyBuilder builder = new ProofOfPossessionSigningKeyBuilder(request);
v.Add(new ProofOfPossession(builder.Build(_popSigner)));
}
}
else if (_popoPrivKey != null)
{
v.Add(new ProofOfPossession(_popoType, _popoPrivKey));
}
else if (_agreeMac != null)
{
v.Add(new ProofOfPossession(ProofOfPossession.TYPE_KEY_AGREEMENT,
PopoPrivKey.GetInstance(new DerTaggedObject(false, PopoPrivKey.agreeMAC, _agreeMac), true)));
}
else if (_popRaVerified != null)
{
v.Add(new ProofOfPossession());
}
return new CertificateRequestMessage(CertReqMsg.GetInstance(new DerSequence(v)));
}
private static Time CreateTime(DateTime? dateTime)
{
return dateTime == null ? null : new Time(dateTime.Value);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 99bec169f4967e6448dbb4a6d120db96
timeCreated: 1572510035
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,34 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using System.Runtime.Serialization;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crmf
{
[Serializable]
public class CrmfException
: Exception
{
public CrmfException()
: base()
{
}
public CrmfException(string message)
: base(message)
{
}
public CrmfException(string message, Exception innerException)
: base(message, innerException)
{
}
protected CrmfException(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: cf363d14806bf124f8fdb4e168eb4b41
timeCreated: 1572510039
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crmf
{
public class DefaultPKMacPrimitivesProvider
: IPKMacPrimitivesProvider
{
public IDigest CreateDigest(AlgorithmIdentifier digestAlg)
{
return DigestUtilities.GetDigest(digestAlg.Algorithm);
}
public IMac CreateMac(AlgorithmIdentifier macAlg)
{
return MacUtilities.GetMac(macAlg.Algorithm);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 482c84e5101b85a4297c9e59d8f3b098
timeCreated: 1572510029
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,163 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using System.IO;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Pkcs;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO;
using BestHTTP.SecureProtocol.Org.BouncyCastle.X509;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crmf
{
public class EncryptedValueBuilder
{
private readonly IKeyWrapper wrapper;
private readonly ICipherBuilderWithKey encryptor;
private readonly IEncryptedValuePadder padder;
///
/// Create a builder that makes EncryptedValue structures.
///
/// <param name="wrapper">wrapper a wrapper for key used to encrypt the actual data contained in the EncryptedValue.</param>
/// <param name="encryptor">encryptor an output encryptor to encrypt the actual data contained in the EncryptedValue. </param>
///
public EncryptedValueBuilder(IKeyWrapper wrapper, ICipherBuilderWithKey encryptor)
: this(wrapper, encryptor, null)
{
}
///
/// Create a builder that makes EncryptedValue structures with fixed length blocks padded using the passed in padder.
///
/// <param name="wrapper">a wrapper for key used to encrypt the actual data contained in the EncryptedValue.</param>
/// <param name="encryptor">encryptor an output encryptor to encrypt the actual data contained in the EncryptedValue.</param>
/// <param name="padder">padder a padder to ensure that the EncryptedValue created will always be a constant length.</param>
///
public EncryptedValueBuilder(IKeyWrapper wrapper, ICipherBuilderWithKey encryptor, IEncryptedValuePadder padder)
{
this.wrapper = wrapper;
this.encryptor = encryptor;
this.padder = padder;
}
///
/// Build an EncryptedValue structure containing the passed in pass phrase.
///
/// <param name="revocationPassphrase">a revocation pass phrase.</param>
///<returns>an EncryptedValue containing the encrypted pass phrase.</returns>
///
public EncryptedValue Build(char[] revocationPassphrase)
{
return EncryptData(PadData(Strings.ToUtf8ByteArray(revocationPassphrase)));
}
///<summary>
/// Build an EncryptedValue structure containing the certificate contained in
/// the passed in holder.
///</summary>
/// <param name="holder">a holder containing a certificate.</param>
/// <returns>an EncryptedValue containing the encrypted certificate.</returns>
/// <exception cref="CrmfException">on a failure to encrypt the data, or wrap the symmetric key for this value.</exception>
///
public EncryptedValue Build(X509Certificate holder)
{
try
{
return EncryptData(PadData(holder.GetEncoded()));
}
catch (IOException e)
{
throw new CrmfException("cannot encode certificate: " + e.Message, e);
}
}
///<summary>
/// Build an EncryptedValue structure containing the private key contained in
/// the passed info structure.
///</summary>
/// <param name="privateKeyInfo">a PKCS#8 private key info structure.</param>
/// <returns>an EncryptedValue containing an EncryptedPrivateKeyInfo structure.</returns>
/// <exception cref="CrmfException">on a failure to encrypt the data, or wrap the symmetric key for this value.</exception>
///
public EncryptedValue Build(PrivateKeyInfo privateKeyInfo)
{
Pkcs8EncryptedPrivateKeyInfoBuilder encInfoBldr = new Pkcs8EncryptedPrivateKeyInfoBuilder(privateKeyInfo);
AlgorithmIdentifier intendedAlg = privateKeyInfo.PrivateKeyAlgorithm;
AlgorithmIdentifier symmAlg = (AlgorithmIdentifier)encryptor.AlgorithmDetails;
DerBitString encSymmKey;
try
{
Pkcs8EncryptedPrivateKeyInfo encInfo = encInfoBldr.Build(encryptor);
encSymmKey = new DerBitString(wrapper.Wrap(((KeyParameter)encryptor.Key).GetKey()).Collect());
AlgorithmIdentifier keyAlg = (AlgorithmIdentifier)wrapper.AlgorithmDetails;
Asn1OctetString valueHint = null;
return new EncryptedValue(intendedAlg, symmAlg, encSymmKey, keyAlg, valueHint, new DerBitString(encInfo.GetEncryptedData()));
}
catch (Exception e)
{
throw new CrmfException("cannot wrap key: " + e.Message, e);
}
}
private EncryptedValue EncryptData(byte[] data)
{
MemoryOutputStream bOut = new MemoryOutputStream();
var cipher = encryptor.BuildCipher(bOut);
try
{
using (var eOut = cipher.Stream)
{
eOut.Write(data, 0, data.Length);
}
}
catch (IOException e)
{
throw new CrmfException("cannot process data: " + e.Message, e);
}
AlgorithmIdentifier intendedAlg = null;
AlgorithmIdentifier symmAlg = (AlgorithmIdentifier)encryptor.AlgorithmDetails;
DerBitString encSymmKey;
try
{
encSymmKey = new DerBitString(wrapper.Wrap(((KeyParameter)encryptor.Key).GetKey()).Collect());
}
catch (Exception e)
{
throw new CrmfException("cannot wrap key: " + e.Message, e);
}
AlgorithmIdentifier keyAlg = (AlgorithmIdentifier)wrapper.AlgorithmDetails;
Asn1OctetString valueHint = null;
DerBitString encValue = new DerBitString(bOut.ToArray());
return new EncryptedValue(intendedAlg, symmAlg, encSymmKey, keyAlg, valueHint, encValue);
}
private byte[] PadData(byte[] data)
{
if (padder != null)
{
return padder.GetPaddedData(data);
}
return data;
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: abe43d8f6206a0f47816e41b75cde35d
timeCreated: 1572510036
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crmf
{
/// <summary>
/// Generic interface for a CertificateRequestMessage control value.
/// </summary>
public interface IControl
{
/// <summary>
/// Return the type of this control.
/// </summary>
DerObjectIdentifier Type { get; }
/// <summary>
/// Return the value contained in this control object.
/// </summary>
Asn1Encodable Value { get; }
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 79bfa4fcd3dc54544ae96884fd0d8a13
timeCreated: 1572510033
licenseType: Store
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 BestHTTP.SecureProtocol.Org.BouncyCastle.Crmf
{
/// <summary>
/// An encrypted value padder is used to make sure that prior to a value been
/// encrypted the data is padded to a standard length.
/// </summary>
public interface IEncryptedValuePadder
{
///
/// <summary>Return a byte array of padded data.</summary>
///
/// <param name="data">the data to be padded.</param>
/// <returns>a padded byte array containing data.</returns>
///
byte[] GetPaddedData(byte[] data);
///
/// <summary>Return a byte array of with padding removed.</summary>
///
/// <param name="paddedData">the data to be padded.</param>
/// <returns>an array containing the original unpadded data.</returns>
///
byte[] GetUnpaddedData(byte[] paddedData);
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: c54ee56c868092749ae800211ccf9380
timeCreated: 1572510038
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crmf
{
public interface IPKMacPrimitivesProvider
{
IDigest CreateDigest(AlgorithmIdentifier digestAlg);
IMac CreateMac(AlgorithmIdentifier macAlg);
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 98a3d91a2844864488aa560cee92d84e
timeCreated: 1572510035
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,290 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using System.IO;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cmp;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Iana;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Oiw;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.IO;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Parameters;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Security;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crmf
{
internal class PKMacStreamCalculator
: IStreamCalculator<DefaultPKMacResult>
{
private readonly MacSink _stream;
public PKMacStreamCalculator(IMac mac)
{
_stream = new MacSink(mac);
}
public Stream Stream
{
get { return _stream; }
}
public DefaultPKMacResult GetResult()
{
return new DefaultPKMacResult(_stream.Mac);
}
}
internal class PKMacFactory
: IMacFactory
{
protected readonly PbmParameter parameters;
private readonly byte[] key;
public PKMacFactory(byte[] key, PbmParameter parameters)
{
this.key = Arrays.Clone(key);
this.parameters = parameters;
}
public virtual object AlgorithmDetails
{
get { return new AlgorithmIdentifier(CmpObjectIdentifiers.passwordBasedMac, parameters); }
}
public virtual IStreamCalculator<IBlockResult> CreateCalculator()
{
IMac mac = MacUtilities.GetMac(parameters.Mac.Algorithm);
mac.Init(new KeyParameter(key));
return new PKMacStreamCalculator(mac);
}
}
internal class DefaultPKMacResult
: IBlockResult
{
private readonly IMac mac;
public DefaultPKMacResult(IMac mac)
{
this.mac = mac;
}
public byte[] Collect()
{
byte[] res = new byte[mac.GetMacSize()];
mac.DoFinal(res, 0);
return res;
}
public int Collect(byte[] sig, int sigOff)
{
byte[] signature = Collect();
signature.CopyTo(sig, sigOff);
return signature.Length;
}
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || _UNITY_2021_2_OR_NEWER_
public int Collect(Span<byte> destination)
{
byte[] result = Collect();
result.CopyTo(destination);
return result.Length;
}
#endif
}
public class PKMacBuilder
{
private AlgorithmIdentifier owf;
private AlgorithmIdentifier mac;
private IPKMacPrimitivesProvider provider;
private SecureRandom random;
private PbmParameter parameters;
private int iterationCount;
private int saltLength = 20;
private int maxIterations;
/// <summary>
/// Default, IterationCount = 1000, OIW=IdSha1, Mac=HmacSHA1
/// </summary>
public PKMacBuilder() :
this(new AlgorithmIdentifier(OiwObjectIdentifiers.IdSha1), 1000, new AlgorithmIdentifier(IanaObjectIdentifiers.HmacSha1, DerNull.Instance), new DefaultPKMacPrimitivesProvider())
{
}
/// <summary>
/// Defaults with IPKMacPrimitivesProvider
/// </summary>
/// <param name="provider"></param>
public PKMacBuilder(IPKMacPrimitivesProvider provider) :
this(new AlgorithmIdentifier(OiwObjectIdentifiers.IdSha1), 1000, new AlgorithmIdentifier(IanaObjectIdentifiers.HmacSha1, DerNull.Instance), provider)
{
}
/// <summary>
/// Create.
/// </summary>
/// <param name="provider">The Mac provider</param>
/// <param name="digestAlgorithmIdentifier">Digest Algorithm Id</param>
/// <param name="macAlgorithmIdentifier">Mac Algorithm Id</param>
public PKMacBuilder(IPKMacPrimitivesProvider provider, AlgorithmIdentifier digestAlgorithmIdentifier, AlgorithmIdentifier macAlgorithmIdentifier) :
this(digestAlgorithmIdentifier, 1000, macAlgorithmIdentifier, provider)
{
}
/// <summary>
/// Create a PKMAC builder enforcing a ceiling on the maximum iteration count.
/// </summary>
/// <param name="provider">supporting calculator</param>
/// <param name="maxIterations">max allowable value for iteration count.</param>
public PKMacBuilder(IPKMacPrimitivesProvider provider, int maxIterations)
{
this.provider = provider;
this.maxIterations = maxIterations;
}
private PKMacBuilder(AlgorithmIdentifier digestAlgorithmIdentifier, int iterationCount, AlgorithmIdentifier macAlgorithmIdentifier, IPKMacPrimitivesProvider provider)
{
this.iterationCount = iterationCount;
this.mac = macAlgorithmIdentifier;
this.owf = digestAlgorithmIdentifier;
this.provider = provider;
}
/**
* Set the salt length in octets.
*
* @param saltLength length in octets of the salt to be generated.
* @return the generator
*/
public PKMacBuilder SetSaltLength(int saltLength)
{
if (saltLength < 8)
throw new ArgumentException("salt length must be at least 8 bytes");
this.saltLength = saltLength;
return this;
}
/// <summary>
/// Set the iteration count.
/// </summary>
/// <param name="iterationCount">the iteration count.</param>
/// <returns>this</returns>
/// <exception cref="ArgumentException">if iteration count is less than 100</exception>
public PKMacBuilder SetIterationCount(int iterationCount)
{
if (iterationCount < 100)
throw new ArgumentException("iteration count must be at least 100");
CheckIterationCountCeiling(iterationCount);
this.iterationCount = iterationCount;
return this;
}
/// <summary>
/// Set PbmParameters
/// </summary>
/// <param name="parameters">The parameters.</param>
/// <returns>this</returns>
public PKMacBuilder SetParameters(PbmParameter parameters)
{
CheckIterationCountCeiling(parameters.IterationCount.IntValueExact);
this.parameters = parameters;
return this;
}
/// <summary>
/// The Secure random
/// </summary>
/// <param name="random">The random.</param>
/// <returns>this</returns>
public PKMacBuilder SetSecureRandom(SecureRandom random)
{
this.random = random;
return this;
}
/// <summary>
/// Build an IMacFactory.
/// </summary>
/// <param name="password">The password.</param>
/// <returns>IMacFactory</returns>
public IMacFactory Build(char[] password)
{
if (parameters != null)
return GenCalculator(parameters, password);
byte[] salt = new byte[saltLength];
this.random = CryptoServicesRegistrar.GetSecureRandom(random);
random.NextBytes(salt);
return GenCalculator(new PbmParameter(salt, owf, iterationCount, mac), password);
}
private void CheckIterationCountCeiling(int iterationCount)
{
if (maxIterations > 0 && iterationCount > maxIterations)
throw new ArgumentException("iteration count exceeds limit (" + iterationCount + " > " + maxIterations + ")");
}
private IMacFactory GenCalculator(PbmParameter parameters, char[] password)
{
// From RFC 4211
//
// 1. Generate a random salt value S
//
// 2. Append the salt to the pw. K = pw || salt.
//
// 3. Hash the value of K. K = HASH(K)
//
// 4. Iter = Iter - 1. If Iter is greater than zero. Goto step 3.
//
// 5. Compute an HMAC as documented in [HMAC].
//
// MAC = HASH( K XOR opad, HASH( K XOR ipad, data) )
//
// Where opad and ipad are defined in [HMAC].
byte[] pw = Strings.ToUtf8ByteArray(password);
byte[] salt = parameters.Salt.GetOctets();
byte[] K = new byte[pw.Length + salt.Length];
Array.Copy(pw, 0, K, 0, pw.Length);
Array.Copy(salt, 0, K, pw.Length, salt.Length);
IDigest digest = provider.CreateDigest(parameters.Owf);
int iter = parameters.IterationCount.IntValueExact;
digest.BlockUpdate(K, 0, K.Length);
K = new byte[digest.GetDigestSize()];
digest.DoFinal(K, 0);
while (--iter > 0)
{
digest.BlockUpdate(K, 0, K.Length);
digest.DoFinal(K, 0);
}
byte[] key = K;
return new PKMacFactory(key, parameters);
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: fc9d9ca6c9d795c4fa152a11e7d6d13e
timeCreated: 1572510043
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,98 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Cms;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crmf
{
public class PkiArchiveControl
: IControl
{
public static readonly int encryptedPrivKey = PkiArchiveOptions.encryptedPrivKey;
public static readonly int keyGenParameters = PkiArchiveOptions.keyGenParameters;
public static readonly int archiveRemGenPrivKey = PkiArchiveOptions.archiveRemGenPrivKey;
private static readonly DerObjectIdentifier type = CrmfObjectIdentifiers.id_regCtrl_pkiArchiveOptions;
private readonly PkiArchiveOptions pkiArchiveOptions;
/// <summary>
/// Basic constructor - build from an PKIArchiveOptions structure.
/// </summary>
/// <param name="pkiArchiveOptions">the ASN.1 structure that will underlie this control.</param>
public PkiArchiveControl(PkiArchiveOptions pkiArchiveOptions)
{
this.pkiArchiveOptions = pkiArchiveOptions;
}
/// <summary>
/// Return the type of this control.
/// </summary>
/// <returns>CRMFObjectIdentifiers.id_regCtrl_pkiArchiveOptions</returns>
public DerObjectIdentifier Type
{
get { return type; }
}
/// <summary>
/// Return the underlying ASN.1 object.
/// </summary>
/// <returns>a PKIArchiveOptions structure.</returns>
public Asn1Encodable Value
{
get { return pkiArchiveOptions; }
}
/// <summary>
/// Return the archive control type, one of: encryptedPrivKey,keyGenParameters,or archiveRemGenPrivKey.
/// </summary>
/// <returns>the archive control type.</returns>
public int ArchiveType
{
get { return pkiArchiveOptions.Type; }
}
/// <summary>
/// Return whether this control contains enveloped data.
/// </summary>
/// <returns>true if the control contains enveloped data, false otherwise.</returns>
public bool EnvelopedData
{
get
{
EncryptedKey encKey = EncryptedKey.GetInstance(pkiArchiveOptions.Value);
return !encKey.IsEncryptedValue;
}
}
/// <summary>
/// Return the enveloped data structure contained in this control.
/// </summary>
/// <returns>a CMSEnvelopedData object.</returns>
public CmsEnvelopedData GetEnvelopedData()
{
try
{
EncryptedKey encKey = EncryptedKey.GetInstance(pkiArchiveOptions.Value);
EnvelopedData data = BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms.EnvelopedData.GetInstance(encKey.Value);
return new CmsEnvelopedData(new ContentInfo(CmsObjectIdentifiers.EnvelopedData, data));
}
catch (CmsException e)
{
throw new CrmfException("CMS parsing error: " + e.Message, e);
}
catch (Exception e)
{
throw new CrmfException("CRMF parsing error: " + e.Message, e);
}
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: c6866b361dff159478f3a7b0a8dfa4cf
timeCreated: 1572510039
licenseType: Store
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 System.IO;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Cms;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Cms;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crmf
{
public class PkiArchiveControlBuilder
{
private CmsEnvelopedDataGenerator envGen;
private CmsProcessableByteArray keyContent;
/// <summary>
///Basic constructor - specify the contents of the PKIArchiveControl structure.
/// </summary>
/// <param name="privateKeyInfo">the private key to be archived.</param>
/// <param name="generalName">the general name to be associated with the private key.</param>
///
public PkiArchiveControlBuilder(PrivateKeyInfo privateKeyInfo, GeneralName generalName)
{
EncKeyWithID encKeyWithID = new EncKeyWithID(privateKeyInfo, generalName);
try
{
this.keyContent = new CmsProcessableByteArray(CrmfObjectIdentifiers.id_ct_encKeyWithID, encKeyWithID.GetEncoded());
}
catch (IOException e)
{
throw new InvalidOperationException("unable to encode key and general name info", e);
}
this.envGen = new CmsEnvelopedDataGenerator();
}
///<summary>Add a recipient generator to this control.</summary>
///<param name="recipientGen"> recipient generator created for a specific recipient.</param>
///<returns>this builder object.</returns>
public PkiArchiveControlBuilder AddRecipientGenerator(RecipientInfoGenerator recipientGen)
{
envGen.AddRecipientInfoGenerator(recipientGen);
return this;
}
/// <summary>Build the PKIArchiveControl using the passed in encryptor to encrypt its contents.</summary>
/// <param name="contentEncryptor">a suitable content encryptor.</param>
/// <returns>a PKIArchiveControl object.</returns>
public PkiArchiveControl Build(ICipherBuilderWithKey contentEncryptor)
{
CmsEnvelopedData envContent = envGen.Generate(keyContent, contentEncryptor);
EnvelopedData envD = EnvelopedData.GetInstance(envContent.ContentInfo.Content);
return new PkiArchiveControl(new PkiArchiveOptions(new EncryptedKey(envD)));
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 53e72fbeaecc61049b4b45f296b26073
timeCreated: 1572510030
licenseType: Store
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 System.IO;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.X509;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Operators;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crmf
{
public class ProofOfPossessionSigningKeyBuilder
{
private CertRequest _certRequest;
private SubjectPublicKeyInfo _pubKeyInfo;
private GeneralName _name;
private PKMacValue _publicKeyMAC;
public ProofOfPossessionSigningKeyBuilder(CertRequest certRequest)
{
this._certRequest = certRequest;
}
public ProofOfPossessionSigningKeyBuilder(SubjectPublicKeyInfo pubKeyInfo)
{
this._pubKeyInfo = pubKeyInfo;
}
public ProofOfPossessionSigningKeyBuilder SetSender(GeneralName name)
{
this._name = name;
return this;
}
public ProofOfPossessionSigningKeyBuilder SetPublicKeyMac(PKMacBuilder generator, char[] password)
{
IMacFactory fact = generator.Build(password);
byte[] d = _pubKeyInfo.GetDerEncoded();
IStreamCalculator<IBlockResult> calc = fact.CreateCalculator();
using (var stream = calc.Stream)
{
stream.Write(d, 0, d.Length);
}
this._publicKeyMAC = new PKMacValue(
(AlgorithmIdentifier)fact.AlgorithmDetails,
new DerBitString(calc.GetResult().Collect()));
return this;
}
public PopoSigningKey Build(ISignatureFactory signer)
{
if (_name != null && _publicKeyMAC != null)
{
throw new InvalidOperationException("name and publicKeyMAC cannot both be set.");
}
PopoSigningKeyInput popo;
IStreamCalculator<IBlockResult> calc = signer.CreateCalculator();
using (Stream sigStream = calc.Stream)
{
if (_certRequest != null)
{
popo = null;
_certRequest.EncodeTo(sigStream, Asn1Encodable.Der);
}
else if (_name != null)
{
popo = new PopoSigningKeyInput(_name, _pubKeyInfo);
popo.EncodeTo(sigStream, Asn1Encodable.Der);
}
else
{
popo = new PopoSigningKeyInput(_publicKeyMAC, _pubKeyInfo);
popo.EncodeTo(sigStream, Asn1Encodable.Der);
}
}
var signature = calc.GetResult().Collect();
return new PopoSigningKey(popo, (AlgorithmIdentifier)signer.AlgorithmDetails, new DerBitString(signature));
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 95ca5515bfa281a4e80a8b3cf8b6f31c
timeCreated: 1572510035
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,55 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Crmf;
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crmf
{
public class RegTokenControl
: IControl
{
private static readonly DerObjectIdentifier type = CrmfObjectIdentifiers.id_regCtrl_regToken;
private readonly DerUtf8String token;
/// <summary>
/// Basic constructor - build from a UTF-8 string representing the token.
/// </summary>
/// <param name="token">UTF-8 string representing the token.</param>
public RegTokenControl(DerUtf8String token)
{
this.token = token;
}
/// <summary>
/// Basic constructor - build from a string representing the token.
/// </summary>
/// <param name="token">string representing the token.</param>
public RegTokenControl(string token)
{
this.token = new DerUtf8String(token);
}
/// <summary>
/// Return the type of this control.
/// </summary>
/// <returns>CRMFObjectIdentifiers.id_regCtrl_regToken</returns>
public DerObjectIdentifier Type
{
get { return type; }
}
/// <summary>
/// Return the token associated with this control (a UTF8String).
/// </summary>
/// <returns>a UTF8String.</returns>
public Asn1Encodable Value
{
get { return token; }
}
}
}
#pragma warning restore
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: bdf5fab6c84b8ae42a49e261d385ae38
timeCreated: 1572510038
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: