up
This commit is contained in:
226
Assets/BestHTTP/SecureProtocol/security/DigestUtilities.cs
Normal file
226
Assets/BestHTTP/SecureProtocol/security/DigestUtilities.cs
Normal file
@@ -0,0 +1,226 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using Org.BouncyCastle.Asn1;
|
||||
using Org.BouncyCastle.Asn1.CryptoPro;
|
||||
using Org.BouncyCastle.Asn1.Nist;
|
||||
using Org.BouncyCastle.Asn1.Pkcs;
|
||||
using Org.BouncyCastle.Asn1.Oiw;
|
||||
using Org.BouncyCastle.Asn1.TeleTrust;
|
||||
using Org.BouncyCastle.Security;
|
||||
using Org.BouncyCastle.Crypto.Digests;
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Security
|
||||
{
|
||||
/// <remarks>
|
||||
/// Utility class for creating IDigest objects from their names/Oids
|
||||
/// </remarks>
|
||||
public sealed class DigestUtilities
|
||||
{
|
||||
private enum DigestAlgorithm {
|
||||
GOST3411,
|
||||
KECCAK_224, KECCAK_256, KECCAK_288, KECCAK_384, KECCAK_512,
|
||||
MD2, MD4, MD5,
|
||||
RIPEMD128, RIPEMD160, RIPEMD256, RIPEMD320,
|
||||
SHA_1, SHA_224, SHA_256, SHA_384, SHA_512,
|
||||
SHA_512_224, SHA_512_256,
|
||||
SHA3_224, SHA3_256, SHA3_384, SHA3_512,
|
||||
SHAKE128, SHAKE256,
|
||||
TIGER,
|
||||
WHIRLPOOL,
|
||||
};
|
||||
|
||||
private DigestUtilities()
|
||||
{
|
||||
}
|
||||
|
||||
private static readonly IDictionary algorithms = Platform.CreateHashtable();
|
||||
private static readonly IDictionary oids = Platform.CreateHashtable();
|
||||
|
||||
static DigestUtilities()
|
||||
{
|
||||
// Signal to obfuscation tools not to change enum constants
|
||||
((DigestAlgorithm)Enums.GetArbitraryValue(typeof(DigestAlgorithm))).ToString();
|
||||
|
||||
algorithms[PkcsObjectIdentifiers.MD2.Id] = "MD2";
|
||||
algorithms[PkcsObjectIdentifiers.MD4.Id] = "MD4";
|
||||
algorithms[PkcsObjectIdentifiers.MD5.Id] = "MD5";
|
||||
|
||||
algorithms["SHA1"] = "SHA-1";
|
||||
algorithms[OiwObjectIdentifiers.IdSha1.Id] = "SHA-1";
|
||||
algorithms["SHA224"] = "SHA-224";
|
||||
algorithms[NistObjectIdentifiers.IdSha224.Id] = "SHA-224";
|
||||
algorithms["SHA256"] = "SHA-256";
|
||||
algorithms[NistObjectIdentifiers.IdSha256.Id] = "SHA-256";
|
||||
algorithms["SHA384"] = "SHA-384";
|
||||
algorithms[NistObjectIdentifiers.IdSha384.Id] = "SHA-384";
|
||||
algorithms["SHA512"] = "SHA-512";
|
||||
algorithms[NistObjectIdentifiers.IdSha512.Id] = "SHA-512";
|
||||
algorithms["SHA512/224"] = "SHA-512/224";
|
||||
algorithms[NistObjectIdentifiers.IdSha512_224.Id] = "SHA-512/224";
|
||||
algorithms["SHA512/256"] = "SHA-512/256";
|
||||
algorithms[NistObjectIdentifiers.IdSha512_256.Id] = "SHA-512/256";
|
||||
|
||||
algorithms["RIPEMD-128"] = "RIPEMD128";
|
||||
algorithms[TeleTrusTObjectIdentifiers.RipeMD128.Id] = "RIPEMD128";
|
||||
algorithms["RIPEMD-160"] = "RIPEMD160";
|
||||
algorithms[TeleTrusTObjectIdentifiers.RipeMD160.Id] = "RIPEMD160";
|
||||
algorithms["RIPEMD-256"] = "RIPEMD256";
|
||||
algorithms[TeleTrusTObjectIdentifiers.RipeMD256.Id] = "RIPEMD256";
|
||||
algorithms["RIPEMD-320"] = "RIPEMD320";
|
||||
// algorithms[TeleTrusTObjectIdentifiers.RipeMD320.Id] = "RIPEMD320";
|
||||
|
||||
algorithms[CryptoProObjectIdentifiers.GostR3411.Id] = "GOST3411";
|
||||
|
||||
algorithms[NistObjectIdentifiers.IdSha3_224.Id] = "SHA3-224";
|
||||
algorithms[NistObjectIdentifiers.IdSha3_256.Id] = "SHA3-256";
|
||||
algorithms[NistObjectIdentifiers.IdSha3_384.Id] = "SHA3-384";
|
||||
algorithms[NistObjectIdentifiers.IdSha3_512.Id] = "SHA3-512";
|
||||
algorithms[NistObjectIdentifiers.IdShake128.Id] = "SHAKE128";
|
||||
algorithms[NistObjectIdentifiers.IdShake256.Id] = "SHAKE256";
|
||||
|
||||
oids["MD2"] = PkcsObjectIdentifiers.MD2;
|
||||
oids["MD4"] = PkcsObjectIdentifiers.MD4;
|
||||
oids["MD5"] = PkcsObjectIdentifiers.MD5;
|
||||
oids["SHA-1"] = OiwObjectIdentifiers.IdSha1;
|
||||
oids["SHA-224"] = NistObjectIdentifiers.IdSha224;
|
||||
oids["SHA-256"] = NistObjectIdentifiers.IdSha256;
|
||||
oids["SHA-384"] = NistObjectIdentifiers.IdSha384;
|
||||
oids["SHA-512"] = NistObjectIdentifiers.IdSha512;
|
||||
oids["SHA-512/224"] = NistObjectIdentifiers.IdSha512_224;
|
||||
oids["SHA-512/256"] = NistObjectIdentifiers.IdSha512_256;
|
||||
oids["SHA3-224"] = NistObjectIdentifiers.IdSha3_224;
|
||||
oids["SHA3-256"] = NistObjectIdentifiers.IdSha3_256;
|
||||
oids["SHA3-384"] = NistObjectIdentifiers.IdSha3_384;
|
||||
oids["SHA3-512"] = NistObjectIdentifiers.IdSha3_512;
|
||||
oids["SHAKE128"] = NistObjectIdentifiers.IdShake128;
|
||||
oids["SHAKE256"] = NistObjectIdentifiers.IdShake256;
|
||||
oids["RIPEMD128"] = TeleTrusTObjectIdentifiers.RipeMD128;
|
||||
oids["RIPEMD160"] = TeleTrusTObjectIdentifiers.RipeMD160;
|
||||
oids["RIPEMD256"] = TeleTrusTObjectIdentifiers.RipeMD256;
|
||||
oids["GOST3411"] = CryptoProObjectIdentifiers.GostR3411;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a ObjectIdentifier for a given digest mechanism.
|
||||
/// </summary>
|
||||
/// <param name="mechanism">A string representation of the digest meanism.</param>
|
||||
/// <returns>A DerObjectIdentifier, null if the Oid is not available.</returns>
|
||||
|
||||
public static DerObjectIdentifier GetObjectIdentifier(
|
||||
string mechanism)
|
||||
{
|
||||
if (mechanism == null)
|
||||
throw new System.ArgumentNullException("mechanism");
|
||||
|
||||
mechanism = Platform.ToUpperInvariant(mechanism);
|
||||
string aliased = (string) algorithms[mechanism];
|
||||
|
||||
if (aliased != null)
|
||||
mechanism = aliased;
|
||||
|
||||
return (DerObjectIdentifier) oids[mechanism];
|
||||
}
|
||||
|
||||
public static ICollection Algorithms
|
||||
{
|
||||
get { return oids.Keys; }
|
||||
}
|
||||
|
||||
public static IDigest GetDigest(
|
||||
DerObjectIdentifier id)
|
||||
{
|
||||
return GetDigest(id.Id);
|
||||
}
|
||||
|
||||
public static IDigest GetDigest(
|
||||
string algorithm)
|
||||
{
|
||||
string upper = Platform.ToUpperInvariant(algorithm);
|
||||
string mechanism = (string) algorithms[upper];
|
||||
|
||||
if (mechanism == null)
|
||||
{
|
||||
mechanism = upper;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
DigestAlgorithm digestAlgorithm = (DigestAlgorithm)Enums.GetEnumValue(
|
||||
typeof(DigestAlgorithm), mechanism);
|
||||
|
||||
switch (digestAlgorithm)
|
||||
{
|
||||
case DigestAlgorithm.GOST3411: return new Gost3411Digest();
|
||||
case DigestAlgorithm.KECCAK_224: return new KeccakDigest(224);
|
||||
case DigestAlgorithm.KECCAK_256: return new KeccakDigest(256);
|
||||
case DigestAlgorithm.KECCAK_288: return new KeccakDigest(288);
|
||||
case DigestAlgorithm.KECCAK_384: return new KeccakDigest(384);
|
||||
case DigestAlgorithm.KECCAK_512: return new KeccakDigest(512);
|
||||
case DigestAlgorithm.MD2: return new MD2Digest();
|
||||
case DigestAlgorithm.MD4: return new MD4Digest();
|
||||
case DigestAlgorithm.MD5: return new MD5Digest();
|
||||
case DigestAlgorithm.RIPEMD128: return new RipeMD128Digest();
|
||||
case DigestAlgorithm.RIPEMD160: return new RipeMD160Digest();
|
||||
case DigestAlgorithm.RIPEMD256: return new RipeMD256Digest();
|
||||
case DigestAlgorithm.RIPEMD320: return new RipeMD320Digest();
|
||||
case DigestAlgorithm.SHA_1: return new Sha1Digest();
|
||||
case DigestAlgorithm.SHA_224: return new Sha224Digest();
|
||||
case DigestAlgorithm.SHA_256: return new Sha256Digest();
|
||||
case DigestAlgorithm.SHA_384: return new Sha384Digest();
|
||||
case DigestAlgorithm.SHA_512: return new Sha512Digest();
|
||||
case DigestAlgorithm.SHA_512_224: return new Sha512tDigest(224);
|
||||
case DigestAlgorithm.SHA_512_256: return new Sha512tDigest(256);
|
||||
case DigestAlgorithm.SHA3_224: return new Sha3Digest(224);
|
||||
case DigestAlgorithm.SHA3_256: return new Sha3Digest(256);
|
||||
case DigestAlgorithm.SHA3_384: return new Sha3Digest(384);
|
||||
case DigestAlgorithm.SHA3_512: return new Sha3Digest(512);
|
||||
case DigestAlgorithm.SHAKE128: return new ShakeDigest(128);
|
||||
case DigestAlgorithm.SHAKE256: return new ShakeDigest(256);
|
||||
case DigestAlgorithm.TIGER: return new TigerDigest();
|
||||
case DigestAlgorithm.WHIRLPOOL: return new WhirlpoolDigest();
|
||||
}
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
}
|
||||
|
||||
throw new SecurityUtilityException("Digest " + mechanism + " not recognised.");
|
||||
}
|
||||
|
||||
public static string GetAlgorithmName(
|
||||
DerObjectIdentifier oid)
|
||||
{
|
||||
return (string) algorithms[oid.Id];
|
||||
}
|
||||
|
||||
public static byte[] CalculateDigest(string algorithm, byte[] input)
|
||||
{
|
||||
IDigest digest = GetDigest(algorithm);
|
||||
digest.BlockUpdate(input, 0, input.Length);
|
||||
return DoFinal(digest);
|
||||
}
|
||||
|
||||
public static byte[] DoFinal(
|
||||
IDigest digest)
|
||||
{
|
||||
byte[] b = new byte[digest.GetDigestSize()];
|
||||
digest.DoFinal(b, 0);
|
||||
return b;
|
||||
}
|
||||
|
||||
public static byte[] DoFinal(
|
||||
IDigest digest,
|
||||
byte[] input)
|
||||
{
|
||||
digest.BlockUpdate(input, 0, input.Length);
|
||||
return DoFinal(digest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70e5de850cd59474793f69947ca4b5b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Security
|
||||
{
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class GeneralSecurityException
|
||||
: Exception
|
||||
{
|
||||
public GeneralSecurityException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public GeneralSecurityException(
|
||||
string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public GeneralSecurityException(
|
||||
string message,
|
||||
Exception exception)
|
||||
: base(message, exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0f3f7bf585464b64a935ff084a39a09
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Security
|
||||
{
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class InvalidKeyException : KeyException
|
||||
{
|
||||
public InvalidKeyException() : base() { }
|
||||
public InvalidKeyException(string message) : base(message) { }
|
||||
public InvalidKeyException(string message, Exception exception) : base(message, exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f15f4c3bc00bc4f6a9e43d9a7110c57c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Security
|
||||
{
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class InvalidParameterException : KeyException
|
||||
{
|
||||
public InvalidParameterException() : base() { }
|
||||
public InvalidParameterException(string message) : base(message) { }
|
||||
public InvalidParameterException(string message, Exception exception) : base(message, exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b7822466e63f4f6db622c4fa493e7fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
Assets/BestHTTP/SecureProtocol/security/KeyException.cs
Normal file
18
Assets/BestHTTP/SecureProtocol/security/KeyException.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Security
|
||||
{
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class KeyException : GeneralSecurityException
|
||||
{
|
||||
public KeyException() : base() { }
|
||||
public KeyException(string message) : base(message) { }
|
||||
public KeyException(string message, Exception exception) : base(message, exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/security/KeyException.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/security/KeyException.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5254dfc57a9794e14a9d554c725c69f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
260
Assets/BestHTTP/SecureProtocol/security/MacUtilities.cs
Normal file
260
Assets/BestHTTP/SecureProtocol/security/MacUtilities.cs
Normal file
@@ -0,0 +1,260 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Globalization;
|
||||
|
||||
using Org.BouncyCastle.Asn1;
|
||||
using Org.BouncyCastle.Asn1.Iana;
|
||||
using Org.BouncyCastle.Asn1.Pkcs;
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using Org.BouncyCastle.Crypto.Engines;
|
||||
using Org.BouncyCastle.Crypto.Macs;
|
||||
using Org.BouncyCastle.Crypto.Paddings;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Security
|
||||
{
|
||||
/// <remarks>
|
||||
/// Utility class for creating HMac object from their names/Oids
|
||||
/// </remarks>
|
||||
public sealed class MacUtilities
|
||||
{
|
||||
private MacUtilities()
|
||||
{
|
||||
}
|
||||
|
||||
private static readonly IDictionary algorithms = Platform.CreateHashtable();
|
||||
//private static readonly IDictionary oids = Platform.CreateHashtable();
|
||||
|
||||
static MacUtilities()
|
||||
{
|
||||
algorithms[IanaObjectIdentifiers.HmacMD5.Id] = "HMAC-MD5";
|
||||
algorithms[IanaObjectIdentifiers.HmacRipeMD160.Id] = "HMAC-RIPEMD160";
|
||||
algorithms[IanaObjectIdentifiers.HmacSha1.Id] = "HMAC-SHA1";
|
||||
algorithms[IanaObjectIdentifiers.HmacTiger.Id] = "HMAC-TIGER";
|
||||
|
||||
algorithms[PkcsObjectIdentifiers.IdHmacWithSha1.Id] = "HMAC-SHA1";
|
||||
algorithms[PkcsObjectIdentifiers.IdHmacWithSha224.Id] = "HMAC-SHA224";
|
||||
algorithms[PkcsObjectIdentifiers.IdHmacWithSha256.Id] = "HMAC-SHA256";
|
||||
algorithms[PkcsObjectIdentifiers.IdHmacWithSha384.Id] = "HMAC-SHA384";
|
||||
algorithms[PkcsObjectIdentifiers.IdHmacWithSha512.Id] = "HMAC-SHA512";
|
||||
|
||||
// TODO AESMAC?
|
||||
|
||||
algorithms["DES"] = "DESMAC";
|
||||
algorithms["DES/CFB8"] = "DESMAC/CFB8";
|
||||
algorithms["DES64"] = "DESMAC64";
|
||||
algorithms["DESEDE"] = "DESEDEMAC";
|
||||
algorithms[PkcsObjectIdentifiers.DesEde3Cbc.Id] = "DESEDEMAC";
|
||||
algorithms["DESEDE/CFB8"] = "DESEDEMAC/CFB8";
|
||||
algorithms["DESISO9797MAC"] = "DESWITHISO9797";
|
||||
algorithms["DESEDE64"] = "DESEDEMAC64";
|
||||
|
||||
algorithms["DESEDE64WITHISO7816-4PADDING"] = "DESEDEMAC64WITHISO7816-4PADDING";
|
||||
algorithms["DESEDEISO9797ALG1MACWITHISO7816-4PADDING"] = "DESEDEMAC64WITHISO7816-4PADDING";
|
||||
algorithms["DESEDEISO9797ALG1WITHISO7816-4PADDING"] = "DESEDEMAC64WITHISO7816-4PADDING";
|
||||
|
||||
algorithms["ISO9797ALG3"] = "ISO9797ALG3MAC";
|
||||
algorithms["ISO9797ALG3MACWITHISO7816-4PADDING"] = "ISO9797ALG3WITHISO7816-4PADDING";
|
||||
|
||||
algorithms["SKIPJACK"] = "SKIPJACKMAC";
|
||||
algorithms["SKIPJACK/CFB8"] = "SKIPJACKMAC/CFB8";
|
||||
algorithms["IDEA"] = "IDEAMAC";
|
||||
algorithms["IDEA/CFB8"] = "IDEAMAC/CFB8";
|
||||
algorithms["RC2"] = "RC2MAC";
|
||||
algorithms["RC2/CFB8"] = "RC2MAC/CFB8";
|
||||
algorithms["RC5"] = "RC5MAC";
|
||||
algorithms["RC5/CFB8"] = "RC5MAC/CFB8";
|
||||
algorithms["GOST28147"] = "GOST28147MAC";
|
||||
algorithms["VMPC"] = "VMPCMAC";
|
||||
algorithms["VMPC-MAC"] = "VMPCMAC";
|
||||
algorithms["SIPHASH"] = "SIPHASH-2-4";
|
||||
|
||||
algorithms["PBEWITHHMACSHA"] = "PBEWITHHMACSHA1";
|
||||
algorithms["1.3.14.3.2.26"] = "PBEWITHHMACSHA1";
|
||||
}
|
||||
|
||||
// /// <summary>
|
||||
// /// Returns a ObjectIdentifier for a given digest mechanism.
|
||||
// /// </summary>
|
||||
// /// <param name="mechanism">A string representation of the digest meanism.</param>
|
||||
// /// <returns>A DerObjectIdentifier, null if the Oid is not available.</returns>
|
||||
// public static DerObjectIdentifier GetObjectIdentifier(
|
||||
// string mechanism)
|
||||
// {
|
||||
// mechanism = (string) algorithms[Platform.ToUpperInvariant(mechanism)];
|
||||
//
|
||||
// if (mechanism != null)
|
||||
// {
|
||||
// return (DerObjectIdentifier)oids[mechanism];
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// public static ICollection Algorithms
|
||||
// {
|
||||
// get { return oids.Keys; }
|
||||
// }
|
||||
|
||||
public static IMac GetMac(
|
||||
DerObjectIdentifier id)
|
||||
{
|
||||
return GetMac(id.Id);
|
||||
}
|
||||
|
||||
public static IMac GetMac(
|
||||
string algorithm)
|
||||
{
|
||||
string upper = Platform.ToUpperInvariant(algorithm);
|
||||
|
||||
string mechanism = (string) algorithms[upper];
|
||||
|
||||
if (mechanism == null)
|
||||
{
|
||||
mechanism = upper;
|
||||
}
|
||||
|
||||
if (Platform.StartsWith(mechanism, "PBEWITH"))
|
||||
{
|
||||
mechanism = mechanism.Substring("PBEWITH".Length);
|
||||
}
|
||||
|
||||
if (Platform.StartsWith(mechanism, "HMAC"))
|
||||
{
|
||||
string digestName;
|
||||
if (Platform.StartsWith(mechanism, "HMAC-") || Platform.StartsWith(mechanism, "HMAC/"))
|
||||
{
|
||||
digestName = mechanism.Substring(5);
|
||||
}
|
||||
else
|
||||
{
|
||||
digestName = mechanism.Substring(4);
|
||||
}
|
||||
|
||||
return new HMac(DigestUtilities.GetDigest(digestName));
|
||||
}
|
||||
|
||||
if (mechanism == "AESCMAC")
|
||||
{
|
||||
return new CMac(new AesFastEngine());
|
||||
}
|
||||
if (mechanism == "DESMAC")
|
||||
{
|
||||
return new CbcBlockCipherMac(new DesEngine());
|
||||
}
|
||||
if (mechanism == "DESMAC/CFB8")
|
||||
{
|
||||
return new CfbBlockCipherMac(new DesEngine());
|
||||
}
|
||||
if (mechanism == "DESMAC64")
|
||||
{
|
||||
return new CbcBlockCipherMac(new DesEngine(), 64);
|
||||
}
|
||||
if (mechanism == "DESEDECMAC")
|
||||
{
|
||||
return new CMac(new DesEdeEngine());
|
||||
}
|
||||
if (mechanism == "DESEDEMAC")
|
||||
{
|
||||
return new CbcBlockCipherMac(new DesEdeEngine());
|
||||
}
|
||||
if (mechanism == "DESEDEMAC/CFB8")
|
||||
{
|
||||
return new CfbBlockCipherMac(new DesEdeEngine());
|
||||
}
|
||||
if (mechanism == "DESEDEMAC64")
|
||||
{
|
||||
return new CbcBlockCipherMac(new DesEdeEngine(), 64);
|
||||
}
|
||||
if (mechanism == "DESEDEMAC64WITHISO7816-4PADDING")
|
||||
{
|
||||
return new CbcBlockCipherMac(new DesEdeEngine(), 64, new ISO7816d4Padding());
|
||||
}
|
||||
if (mechanism == "DESWITHISO9797"
|
||||
|| mechanism == "ISO9797ALG3MAC")
|
||||
{
|
||||
return new ISO9797Alg3Mac(new DesEngine());
|
||||
}
|
||||
if (mechanism == "ISO9797ALG3WITHISO7816-4PADDING")
|
||||
{
|
||||
return new ISO9797Alg3Mac(new DesEngine(), new ISO7816d4Padding());
|
||||
}
|
||||
if (mechanism == "SKIPJACKMAC")
|
||||
{
|
||||
return new CbcBlockCipherMac(new SkipjackEngine());
|
||||
}
|
||||
if (mechanism == "SKIPJACKMAC/CFB8")
|
||||
{
|
||||
return new CfbBlockCipherMac(new SkipjackEngine());
|
||||
}
|
||||
if (mechanism == "IDEAMAC")
|
||||
{
|
||||
return new CbcBlockCipherMac(new IdeaEngine());
|
||||
}
|
||||
if (mechanism == "IDEAMAC/CFB8")
|
||||
{
|
||||
return new CfbBlockCipherMac(new IdeaEngine());
|
||||
}
|
||||
if (mechanism == "RC2MAC")
|
||||
{
|
||||
return new CbcBlockCipherMac(new RC2Engine());
|
||||
}
|
||||
if (mechanism == "RC2MAC/CFB8")
|
||||
{
|
||||
return new CfbBlockCipherMac(new RC2Engine());
|
||||
}
|
||||
if (mechanism == "RC5MAC")
|
||||
{
|
||||
return new CbcBlockCipherMac(new RC532Engine());
|
||||
}
|
||||
if (mechanism == "RC5MAC/CFB8")
|
||||
{
|
||||
return new CfbBlockCipherMac(new RC532Engine());
|
||||
}
|
||||
if (mechanism == "GOST28147MAC")
|
||||
{
|
||||
return new Gost28147Mac();
|
||||
}
|
||||
if (mechanism == "VMPCMAC")
|
||||
{
|
||||
return new VmpcMac();
|
||||
}
|
||||
if (mechanism == "SIPHASH-2-4")
|
||||
{
|
||||
return new SipHash();
|
||||
}
|
||||
throw new SecurityUtilityException("Mac " + mechanism + " not recognised.");
|
||||
}
|
||||
|
||||
public static string GetAlgorithmName(
|
||||
DerObjectIdentifier oid)
|
||||
{
|
||||
return (string) algorithms[oid.Id];
|
||||
}
|
||||
|
||||
public static byte[] CalculateMac(string algorithm, ICipherParameters cp, byte[] input)
|
||||
{
|
||||
IMac mac = GetMac(algorithm);
|
||||
mac.Init(cp);
|
||||
mac.BlockUpdate(input, 0, input.Length);
|
||||
return DoFinal(mac);
|
||||
}
|
||||
|
||||
public static byte[] DoFinal(IMac mac)
|
||||
{
|
||||
byte[] b = new byte[mac.GetMacSize()];
|
||||
mac.DoFinal(b, 0);
|
||||
return b;
|
||||
}
|
||||
|
||||
public static byte[] DoFinal(IMac mac, byte[] input)
|
||||
{
|
||||
mac.BlockUpdate(input, 0, input.Length);
|
||||
return DoFinal(mac);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/security/MacUtilities.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/security/MacUtilities.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e18ed72801b85498da565bc50a576c1d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
257
Assets/BestHTTP/SecureProtocol/security/PublicKeyFactory.cs
Normal file
257
Assets/BestHTTP/SecureProtocol/security/PublicKeyFactory.cs
Normal file
@@ -0,0 +1,257 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
using Org.BouncyCastle.Asn1;
|
||||
using Org.BouncyCastle.Asn1.CryptoPro;
|
||||
using Org.BouncyCastle.Asn1.Oiw;
|
||||
using Org.BouncyCastle.Asn1.Pkcs;
|
||||
using Org.BouncyCastle.Asn1.Sec;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Org.BouncyCastle.Asn1.X9;
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using Org.BouncyCastle.Crypto.Generators;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
using Org.BouncyCastle.Math;
|
||||
using Org.BouncyCastle.Math.EC;
|
||||
|
||||
namespace Org.BouncyCastle.Security
|
||||
{
|
||||
public sealed class PublicKeyFactory
|
||||
{
|
||||
private PublicKeyFactory()
|
||||
{
|
||||
}
|
||||
|
||||
public static AsymmetricKeyParameter CreateKey(
|
||||
byte[] keyInfoData)
|
||||
{
|
||||
return CreateKey(
|
||||
SubjectPublicKeyInfo.GetInstance(
|
||||
Asn1Object.FromByteArray(keyInfoData)));
|
||||
}
|
||||
|
||||
public static AsymmetricKeyParameter CreateKey(
|
||||
Stream inStr)
|
||||
{
|
||||
return CreateKey(
|
||||
SubjectPublicKeyInfo.GetInstance(
|
||||
Asn1Object.FromStream(inStr)));
|
||||
}
|
||||
|
||||
public static AsymmetricKeyParameter CreateKey(
|
||||
SubjectPublicKeyInfo keyInfo)
|
||||
{
|
||||
AlgorithmIdentifier algID = keyInfo.AlgorithmID;
|
||||
DerObjectIdentifier algOid = algID.Algorithm;
|
||||
|
||||
// TODO See RSAUtil.isRsaOid in Java build
|
||||
if (algOid.Equals(PkcsObjectIdentifiers.RsaEncryption)
|
||||
|| algOid.Equals(X509ObjectIdentifiers.IdEARsa)
|
||||
|| algOid.Equals(PkcsObjectIdentifiers.IdRsassaPss)
|
||||
|| algOid.Equals(PkcsObjectIdentifiers.IdRsaesOaep))
|
||||
{
|
||||
RsaPublicKeyStructure pubKey = RsaPublicKeyStructure.GetInstance(
|
||||
keyInfo.GetPublicKey());
|
||||
|
||||
return new RsaKeyParameters(false, pubKey.Modulus, pubKey.PublicExponent);
|
||||
}
|
||||
else if (algOid.Equals(X9ObjectIdentifiers.DHPublicNumber))
|
||||
{
|
||||
Asn1Sequence seq = Asn1Sequence.GetInstance(algID.Parameters.ToAsn1Object());
|
||||
|
||||
DHPublicKey dhPublicKey = DHPublicKey.GetInstance(keyInfo.GetPublicKey());
|
||||
|
||||
BigInteger y = dhPublicKey.Y.Value;
|
||||
|
||||
if (IsPkcsDHParam(seq))
|
||||
return ReadPkcsDHParam(algOid, y, seq);
|
||||
|
||||
DHDomainParameters dhParams = DHDomainParameters.GetInstance(seq);
|
||||
|
||||
BigInteger p = dhParams.P.Value;
|
||||
BigInteger g = dhParams.G.Value;
|
||||
BigInteger q = dhParams.Q.Value;
|
||||
|
||||
BigInteger j = null;
|
||||
if (dhParams.J != null)
|
||||
{
|
||||
j = dhParams.J.Value;
|
||||
}
|
||||
|
||||
DHValidationParameters validation = null;
|
||||
DHValidationParms dhValidationParms = dhParams.ValidationParms;
|
||||
if (dhValidationParms != null)
|
||||
{
|
||||
byte[] seed = dhValidationParms.Seed.GetBytes();
|
||||
BigInteger pgenCounter = dhValidationParms.PgenCounter.Value;
|
||||
|
||||
// TODO Check pgenCounter size?
|
||||
|
||||
validation = new DHValidationParameters(seed, pgenCounter.IntValue);
|
||||
}
|
||||
|
||||
return new DHPublicKeyParameters(y, new DHParameters(p, g, q, j, validation));
|
||||
}
|
||||
else if (algOid.Equals(PkcsObjectIdentifiers.DhKeyAgreement))
|
||||
{
|
||||
Asn1Sequence seq = Asn1Sequence.GetInstance(algID.Parameters.ToAsn1Object());
|
||||
|
||||
DerInteger derY = (DerInteger) keyInfo.GetPublicKey();
|
||||
|
||||
return ReadPkcsDHParam(algOid, derY.Value, seq);
|
||||
}
|
||||
else if (algOid.Equals(OiwObjectIdentifiers.ElGamalAlgorithm))
|
||||
{
|
||||
ElGamalParameter para = new ElGamalParameter(
|
||||
Asn1Sequence.GetInstance(algID.Parameters.ToAsn1Object()));
|
||||
DerInteger derY = (DerInteger) keyInfo.GetPublicKey();
|
||||
|
||||
return new ElGamalPublicKeyParameters(
|
||||
derY.Value,
|
||||
new ElGamalParameters(para.P, para.G));
|
||||
}
|
||||
else if (algOid.Equals(X9ObjectIdentifiers.IdDsa)
|
||||
|| algOid.Equals(OiwObjectIdentifiers.DsaWithSha1))
|
||||
{
|
||||
DerInteger derY = (DerInteger) keyInfo.GetPublicKey();
|
||||
Asn1Encodable ae = algID.Parameters;
|
||||
|
||||
DsaParameters parameters = null;
|
||||
if (ae != null)
|
||||
{
|
||||
DsaParameter para = DsaParameter.GetInstance(ae.ToAsn1Object());
|
||||
parameters = new DsaParameters(para.P, para.Q, para.G);
|
||||
}
|
||||
|
||||
return new DsaPublicKeyParameters(derY.Value, parameters);
|
||||
}
|
||||
else if (algOid.Equals(X9ObjectIdentifiers.IdECPublicKey))
|
||||
{
|
||||
X962Parameters para = new X962Parameters(algID.Parameters.ToAsn1Object());
|
||||
|
||||
X9ECParameters x9;
|
||||
if (para.IsNamedCurve)
|
||||
{
|
||||
x9 = ECKeyPairGenerator.FindECCurveByOid((DerObjectIdentifier)para.Parameters);
|
||||
}
|
||||
else
|
||||
{
|
||||
x9 = new X9ECParameters((Asn1Sequence)para.Parameters);
|
||||
}
|
||||
|
||||
Asn1OctetString key = new DerOctetString(keyInfo.PublicKeyData.GetBytes());
|
||||
X9ECPoint derQ = new X9ECPoint(x9.Curve, key);
|
||||
ECPoint q = derQ.Point;
|
||||
|
||||
if (para.IsNamedCurve)
|
||||
{
|
||||
return new ECPublicKeyParameters("EC", q, (DerObjectIdentifier)para.Parameters);
|
||||
}
|
||||
|
||||
ECDomainParameters dParams = new ECDomainParameters(x9.Curve, x9.G, x9.N, x9.H, x9.GetSeed());
|
||||
return new ECPublicKeyParameters(q, dParams);
|
||||
}
|
||||
else if (algOid.Equals(CryptoProObjectIdentifiers.GostR3410x2001))
|
||||
{
|
||||
Gost3410PublicKeyAlgParameters gostParams = new Gost3410PublicKeyAlgParameters(
|
||||
(Asn1Sequence) algID.Parameters);
|
||||
|
||||
Asn1OctetString key;
|
||||
try
|
||||
{
|
||||
key = (Asn1OctetString) keyInfo.GetPublicKey();
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
throw new ArgumentException("invalid info structure in GOST3410 public key");
|
||||
}
|
||||
|
||||
byte[] keyEnc = key.GetOctets();
|
||||
byte[] x = new byte[32];
|
||||
byte[] y = new byte[32];
|
||||
|
||||
for (int i = 0; i != y.Length; i++)
|
||||
{
|
||||
x[i] = keyEnc[32 - 1 - i];
|
||||
}
|
||||
|
||||
for (int i = 0; i != x.Length; i++)
|
||||
{
|
||||
y[i] = keyEnc[64 - 1 - i];
|
||||
}
|
||||
|
||||
ECDomainParameters ecP = ECGost3410NamedCurves.GetByOid(gostParams.PublicKeyParamSet);
|
||||
|
||||
if (ecP == null)
|
||||
return null;
|
||||
|
||||
ECPoint q = ecP.Curve.CreatePoint(new BigInteger(1, x), new BigInteger(1, y));
|
||||
|
||||
return new ECPublicKeyParameters("ECGOST3410", q, gostParams.PublicKeyParamSet);
|
||||
}
|
||||
else if (algOid.Equals(CryptoProObjectIdentifiers.GostR3410x94))
|
||||
{
|
||||
Gost3410PublicKeyAlgParameters algParams = new Gost3410PublicKeyAlgParameters(
|
||||
(Asn1Sequence) algID.Parameters);
|
||||
|
||||
DerOctetString derY;
|
||||
try
|
||||
{
|
||||
derY = (DerOctetString) keyInfo.GetPublicKey();
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
throw new ArgumentException("invalid info structure in GOST3410 public key");
|
||||
}
|
||||
|
||||
byte[] keyEnc = derY.GetOctets();
|
||||
byte[] keyBytes = new byte[keyEnc.Length];
|
||||
|
||||
for (int i = 0; i != keyEnc.Length; i++)
|
||||
{
|
||||
keyBytes[i] = keyEnc[keyEnc.Length - 1 - i]; // was little endian
|
||||
}
|
||||
|
||||
BigInteger y = new BigInteger(1, keyBytes);
|
||||
|
||||
return new Gost3410PublicKeyParameters(y, algParams.PublicKeyParamSet);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new SecurityUtilityException("algorithm identifier in key not recognised: " + algOid);
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsPkcsDHParam(Asn1Sequence seq)
|
||||
{
|
||||
if (seq.Count == 2)
|
||||
return true;
|
||||
|
||||
if (seq.Count > 3)
|
||||
return false;
|
||||
|
||||
DerInteger l = DerInteger.GetInstance(seq[2]);
|
||||
DerInteger p = DerInteger.GetInstance(seq[0]);
|
||||
|
||||
return l.Value.CompareTo(BigInteger.ValueOf(p.Value.BitLength)) <= 0;
|
||||
}
|
||||
|
||||
private static DHPublicKeyParameters ReadPkcsDHParam(DerObjectIdentifier algOid,
|
||||
BigInteger y, Asn1Sequence seq)
|
||||
{
|
||||
DHParameter para = new DHParameter(seq);
|
||||
|
||||
BigInteger lVal = para.L;
|
||||
int l = lVal == null ? 0 : lVal.IntValue;
|
||||
DHParameters dhParams = new DHParameters(para.P, para.G, null, l);
|
||||
|
||||
return new DHPublicKeyParameters(y, dhParams, algOid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95dcb80140f504ff98387f928b218ac6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
266
Assets/BestHTTP/SecureProtocol/security/SecureRandom.cs
Normal file
266
Assets/BestHTTP/SecureProtocol/security/SecureRandom.cs
Normal file
@@ -0,0 +1,266 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using Org.BouncyCastle.Crypto.Digests;
|
||||
using Org.BouncyCastle.Crypto.Prng;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Security
|
||||
{
|
||||
public class SecureRandom
|
||||
: Random
|
||||
{
|
||||
private static long counter = Times.NanoTime();
|
||||
|
||||
#if NETCF_1_0 || PORTABLE
|
||||
private static object counterLock = new object();
|
||||
private static long NextCounterValue()
|
||||
{
|
||||
lock (counterLock)
|
||||
{
|
||||
return ++counter;
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly SecureRandom[] master = { null };
|
||||
private static SecureRandom Master
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (master)
|
||||
{
|
||||
if (master[0] == null)
|
||||
{
|
||||
SecureRandom sr = master[0] = GetInstance("SHA256PRNG", false);
|
||||
|
||||
// Even though Ticks has at most 8 or 14 bits of entropy, there's no harm in adding it.
|
||||
sr.SetSeed(DateTime.Now.Ticks);
|
||||
|
||||
// 32 will be enough when ThreadedSeedGenerator is fixed. Until then, ThreadedSeedGenerator returns low
|
||||
// entropy, and this is not sufficient to be secure. http://www.bouncycastle.org/csharpdevmailarchive/msg00814.html
|
||||
sr.SetSeed(new ThreadedSeedGenerator().GenerateSeed(32, true));
|
||||
}
|
||||
|
||||
return master[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
private static long NextCounterValue()
|
||||
{
|
||||
return Interlocked.Increment(ref counter);
|
||||
}
|
||||
|
||||
private static readonly SecureRandom master = new SecureRandom(new CryptoApiRandomGenerator());
|
||||
private static SecureRandom Master
|
||||
{
|
||||
get { return master; }
|
||||
}
|
||||
#endif
|
||||
|
||||
private static DigestRandomGenerator CreatePrng(string digestName, bool autoSeed)
|
||||
{
|
||||
IDigest digest = DigestUtilities.GetDigest(digestName);
|
||||
if (digest == null)
|
||||
return null;
|
||||
DigestRandomGenerator prng = new DigestRandomGenerator(digest);
|
||||
if (autoSeed)
|
||||
{
|
||||
prng.AddSeedMaterial(NextCounterValue());
|
||||
prng.AddSeedMaterial(GetNextBytes(Master, digest.GetDigestSize()));
|
||||
}
|
||||
return prng;
|
||||
}
|
||||
|
||||
public static byte[] GetNextBytes(SecureRandom secureRandom, int length)
|
||||
{
|
||||
byte[] result = new byte[length];
|
||||
secureRandom.NextBytes(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create and auto-seed an instance based on the given algorithm.
|
||||
/// </summary>
|
||||
/// <remarks>Equivalent to GetInstance(algorithm, true)</remarks>
|
||||
/// <param name="algorithm">e.g. "SHA256PRNG"</param>
|
||||
public static SecureRandom GetInstance(string algorithm)
|
||||
{
|
||||
return GetInstance(algorithm, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create an instance based on the given algorithm, with optional auto-seeding
|
||||
/// </summary>
|
||||
/// <param name="algorithm">e.g. "SHA256PRNG"</param>
|
||||
/// <param name="autoSeed">If true, the instance will be auto-seeded.</param>
|
||||
public static SecureRandom GetInstance(string algorithm, bool autoSeed)
|
||||
{
|
||||
string upper = Platform.ToUpperInvariant(algorithm);
|
||||
if (Platform.EndsWith(upper, "PRNG"))
|
||||
{
|
||||
string digestName = upper.Substring(0, upper.Length - "PRNG".Length);
|
||||
DigestRandomGenerator prng = CreatePrng(digestName, autoSeed);
|
||||
if (prng != null)
|
||||
{
|
||||
return new SecureRandom(prng);
|
||||
}
|
||||
}
|
||||
|
||||
throw new ArgumentException("Unrecognised PRNG algorithm: " + algorithm, "algorithm");
|
||||
}
|
||||
|
||||
[Obsolete("Call GenerateSeed() on a SecureRandom instance instead")]
|
||||
public static byte[] GetSeed(int length)
|
||||
{
|
||||
return GetNextBytes(Master, length);
|
||||
}
|
||||
|
||||
protected readonly IRandomGenerator generator;
|
||||
|
||||
public SecureRandom()
|
||||
: this(CreatePrng("SHA256", true))
|
||||
{
|
||||
}
|
||||
|
||||
/// <remarks>
|
||||
/// To replicate existing predictable output, replace with GetInstance("SHA1PRNG", false), followed by SetSeed(seed)
|
||||
/// </remarks>
|
||||
[Obsolete("Use GetInstance/SetSeed instead")]
|
||||
public SecureRandom(byte[] seed)
|
||||
: this(CreatePrng("SHA1", false))
|
||||
{
|
||||
SetSeed(seed);
|
||||
}
|
||||
|
||||
/// <summary>Use the specified instance of IRandomGenerator as random source.</summary>
|
||||
/// <remarks>
|
||||
/// This constructor performs no seeding of either the <c>IRandomGenerator</c> or the
|
||||
/// constructed <c>SecureRandom</c>. It is the responsibility of the client to provide
|
||||
/// proper seed material as necessary/appropriate for the given <c>IRandomGenerator</c>
|
||||
/// implementation.
|
||||
/// </remarks>
|
||||
/// <param name="generator">The source to generate all random bytes from.</param>
|
||||
public SecureRandom(IRandomGenerator generator)
|
||||
: base(0)
|
||||
{
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
public virtual byte[] GenerateSeed(int length)
|
||||
{
|
||||
return GetNextBytes(Master, length);
|
||||
}
|
||||
|
||||
public virtual void SetSeed(byte[] seed)
|
||||
{
|
||||
generator.AddSeedMaterial(seed);
|
||||
}
|
||||
|
||||
public virtual void SetSeed(long seed)
|
||||
{
|
||||
generator.AddSeedMaterial(seed);
|
||||
}
|
||||
|
||||
public override int Next()
|
||||
{
|
||||
return NextInt() & int.MaxValue;
|
||||
}
|
||||
|
||||
public override int Next(int maxValue)
|
||||
{
|
||||
|
||||
if (maxValue < 2)
|
||||
{
|
||||
if (maxValue < 0)
|
||||
throw new ArgumentOutOfRangeException("maxValue", "cannot be negative");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bits;
|
||||
|
||||
// Test whether maxValue is a power of 2
|
||||
if ((maxValue & (maxValue - 1)) == 0)
|
||||
{
|
||||
bits = NextInt() & int.MaxValue;
|
||||
return (int)(((long)bits * maxValue) >> 31);
|
||||
}
|
||||
|
||||
int result;
|
||||
do
|
||||
{
|
||||
bits = NextInt() & int.MaxValue;
|
||||
result = bits % maxValue;
|
||||
}
|
||||
while (bits - result + (maxValue - 1) < 0); // Ignore results near overflow
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public override int Next(int minValue, int maxValue)
|
||||
{
|
||||
if (maxValue <= minValue)
|
||||
{
|
||||
if (maxValue == minValue)
|
||||
return minValue;
|
||||
|
||||
throw new ArgumentException("maxValue cannot be less than minValue");
|
||||
}
|
||||
|
||||
int diff = maxValue - minValue;
|
||||
if (diff > 0)
|
||||
return minValue + Next(diff);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
int i = NextInt();
|
||||
|
||||
if (i >= minValue && i < maxValue)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
public override void NextBytes(byte[] buf)
|
||||
{
|
||||
generator.NextBytes(buf);
|
||||
}
|
||||
|
||||
public virtual void NextBytes(byte[] buf, int off, int len)
|
||||
{
|
||||
generator.NextBytes(buf, off, len);
|
||||
}
|
||||
|
||||
private static readonly double DoubleScale = System.Math.Pow(2.0, 64.0);
|
||||
|
||||
public override double NextDouble()
|
||||
{
|
||||
return Convert.ToDouble((ulong) NextLong()) / DoubleScale;
|
||||
}
|
||||
|
||||
public virtual int NextInt()
|
||||
{
|
||||
byte[] bytes = new byte[4];
|
||||
NextBytes(bytes);
|
||||
|
||||
uint result = bytes[0];
|
||||
result <<= 8;
|
||||
result |= bytes[1];
|
||||
result <<= 8;
|
||||
result |= bytes[2];
|
||||
result <<= 8;
|
||||
result |= bytes[3];
|
||||
return (int)result;
|
||||
}
|
||||
|
||||
public virtual long NextLong()
|
||||
{
|
||||
return ((long)(uint) NextInt() << 32) | (long)(uint) NextInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/security/SecureRandom.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/security/SecureRandom.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c7aef9a7f8314b3d9a8f14675912518
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Security
|
||||
{
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class SecurityUtilityException
|
||||
: Exception
|
||||
{
|
||||
/**
|
||||
* base constructor.
|
||||
*/
|
||||
public SecurityUtilityException()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* create a SecurityUtilityException with the given message.
|
||||
*
|
||||
* @param message the message to be carried with the exception.
|
||||
*/
|
||||
public SecurityUtilityException(
|
||||
string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public SecurityUtilityException(
|
||||
string message,
|
||||
Exception exception)
|
||||
: base(message, exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 12d3b6c9a403d433ca9aca6cd5c545f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Security
|
||||
{
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class SignatureException : GeneralSecurityException
|
||||
{
|
||||
public SignatureException() : base() { }
|
||||
public SignatureException(string message) : base(message) { }
|
||||
public SignatureException(string message, Exception exception) : base(message, exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59d0ca6936c4d403e917251d970a979c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
570
Assets/BestHTTP/SecureProtocol/security/SignerUtilities.cs
Normal file
570
Assets/BestHTTP/SecureProtocol/security/SignerUtilities.cs
Normal file
@@ -0,0 +1,570 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
|
||||
using Org.BouncyCastle.Asn1;
|
||||
using Org.BouncyCastle.Asn1.CryptoPro;
|
||||
using Org.BouncyCastle.Asn1.Nist;
|
||||
using Org.BouncyCastle.Asn1.Pkcs;
|
||||
using Org.BouncyCastle.Asn1.TeleTrust;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Org.BouncyCastle.Asn1.X9;
|
||||
using Org.BouncyCastle.Security;
|
||||
using Org.BouncyCastle.Crypto.Digests;
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using Org.BouncyCastle.Crypto.Engines;
|
||||
using Org.BouncyCastle.Crypto.Signers;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Security
|
||||
{
|
||||
/// <summary>
|
||||
/// Signer Utility class contains methods that can not be specifically grouped into other classes.
|
||||
/// </summary>
|
||||
public sealed class SignerUtilities
|
||||
{
|
||||
private SignerUtilities()
|
||||
{
|
||||
}
|
||||
|
||||
internal static readonly IDictionary algorithms = Platform.CreateHashtable();
|
||||
internal static readonly IDictionary oids = Platform.CreateHashtable();
|
||||
|
||||
static SignerUtilities()
|
||||
{
|
||||
algorithms["MD2WITHRSA"] = "MD2withRSA";
|
||||
algorithms["MD2WITHRSAENCRYPTION"] = "MD2withRSA";
|
||||
algorithms[PkcsObjectIdentifiers.MD2WithRsaEncryption.Id] = "MD2withRSA";
|
||||
|
||||
algorithms["MD4WITHRSA"] = "MD4withRSA";
|
||||
algorithms["MD4WITHRSAENCRYPTION"] = "MD4withRSA";
|
||||
algorithms[PkcsObjectIdentifiers.MD4WithRsaEncryption.Id] = "MD4withRSA";
|
||||
|
||||
algorithms["MD5WITHRSA"] = "MD5withRSA";
|
||||
algorithms["MD5WITHRSAENCRYPTION"] = "MD5withRSA";
|
||||
algorithms[PkcsObjectIdentifiers.MD5WithRsaEncryption.Id] = "MD5withRSA";
|
||||
|
||||
algorithms["SHA1WITHRSA"] = "SHA-1withRSA";
|
||||
algorithms["SHA1WITHRSAENCRYPTION"] = "SHA-1withRSA";
|
||||
algorithms[PkcsObjectIdentifiers.Sha1WithRsaEncryption.Id] = "SHA-1withRSA";
|
||||
algorithms["SHA-1WITHRSA"] = "SHA-1withRSA";
|
||||
|
||||
algorithms["SHA224WITHRSA"] = "SHA-224withRSA";
|
||||
algorithms["SHA224WITHRSAENCRYPTION"] = "SHA-224withRSA";
|
||||
algorithms[PkcsObjectIdentifiers.Sha224WithRsaEncryption.Id] = "SHA-224withRSA";
|
||||
algorithms["SHA-224WITHRSA"] = "SHA-224withRSA";
|
||||
|
||||
algorithms["SHA256WITHRSA"] = "SHA-256withRSA";
|
||||
algorithms["SHA256WITHRSAENCRYPTION"] = "SHA-256withRSA";
|
||||
algorithms[PkcsObjectIdentifiers.Sha256WithRsaEncryption.Id] = "SHA-256withRSA";
|
||||
algorithms["SHA-256WITHRSA"] = "SHA-256withRSA";
|
||||
|
||||
algorithms["SHA384WITHRSA"] = "SHA-384withRSA";
|
||||
algorithms["SHA384WITHRSAENCRYPTION"] = "SHA-384withRSA";
|
||||
algorithms[PkcsObjectIdentifiers.Sha384WithRsaEncryption.Id] = "SHA-384withRSA";
|
||||
algorithms["SHA-384WITHRSA"] = "SHA-384withRSA";
|
||||
|
||||
algorithms["SHA512WITHRSA"] = "SHA-512withRSA";
|
||||
algorithms["SHA512WITHRSAENCRYPTION"] = "SHA-512withRSA";
|
||||
algorithms[PkcsObjectIdentifiers.Sha512WithRsaEncryption.Id] = "SHA-512withRSA";
|
||||
algorithms["SHA-512WITHRSA"] = "SHA-512withRSA";
|
||||
|
||||
algorithms["PSSWITHRSA"] = "PSSwithRSA";
|
||||
algorithms["RSASSA-PSS"] = "PSSwithRSA";
|
||||
algorithms[PkcsObjectIdentifiers.IdRsassaPss.Id] = "PSSwithRSA";
|
||||
algorithms["RSAPSS"] = "PSSwithRSA";
|
||||
|
||||
algorithms["SHA1WITHRSAANDMGF1"] = "SHA-1withRSAandMGF1";
|
||||
algorithms["SHA-1WITHRSAANDMGF1"] = "SHA-1withRSAandMGF1";
|
||||
algorithms["SHA1WITHRSA/PSS"] = "SHA-1withRSAandMGF1";
|
||||
algorithms["SHA-1WITHRSA/PSS"] = "SHA-1withRSAandMGF1";
|
||||
|
||||
algorithms["SHA224WITHRSAANDMGF1"] = "SHA-224withRSAandMGF1";
|
||||
algorithms["SHA-224WITHRSAANDMGF1"] = "SHA-224withRSAandMGF1";
|
||||
algorithms["SHA224WITHRSA/PSS"] = "SHA-224withRSAandMGF1";
|
||||
algorithms["SHA-224WITHRSA/PSS"] = "SHA-224withRSAandMGF1";
|
||||
|
||||
algorithms["SHA256WITHRSAANDMGF1"] = "SHA-256withRSAandMGF1";
|
||||
algorithms["SHA-256WITHRSAANDMGF1"] = "SHA-256withRSAandMGF1";
|
||||
algorithms["SHA256WITHRSA/PSS"] = "SHA-256withRSAandMGF1";
|
||||
algorithms["SHA-256WITHRSA/PSS"] = "SHA-256withRSAandMGF1";
|
||||
|
||||
algorithms["SHA384WITHRSAANDMGF1"] = "SHA-384withRSAandMGF1";
|
||||
algorithms["SHA-384WITHRSAANDMGF1"] = "SHA-384withRSAandMGF1";
|
||||
algorithms["SHA384WITHRSA/PSS"] = "SHA-384withRSAandMGF1";
|
||||
algorithms["SHA-384WITHRSA/PSS"] = "SHA-384withRSAandMGF1";
|
||||
|
||||
algorithms["SHA512WITHRSAANDMGF1"] = "SHA-512withRSAandMGF1";
|
||||
algorithms["SHA-512WITHRSAANDMGF1"] = "SHA-512withRSAandMGF1";
|
||||
algorithms["SHA512WITHRSA/PSS"] = "SHA-512withRSAandMGF1";
|
||||
algorithms["SHA-512WITHRSA/PSS"] = "SHA-512withRSAandMGF1";
|
||||
|
||||
algorithms["RIPEMD128WITHRSA"] = "RIPEMD128withRSA";
|
||||
algorithms["RIPEMD128WITHRSAENCRYPTION"] = "RIPEMD128withRSA";
|
||||
algorithms[TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128.Id] = "RIPEMD128withRSA";
|
||||
|
||||
algorithms["RIPEMD160WITHRSA"] = "RIPEMD160withRSA";
|
||||
algorithms["RIPEMD160WITHRSAENCRYPTION"] = "RIPEMD160withRSA";
|
||||
algorithms[TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160.Id] = "RIPEMD160withRSA";
|
||||
|
||||
algorithms["RIPEMD256WITHRSA"] = "RIPEMD256withRSA";
|
||||
algorithms["RIPEMD256WITHRSAENCRYPTION"] = "RIPEMD256withRSA";
|
||||
algorithms[TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256.Id] = "RIPEMD256withRSA";
|
||||
|
||||
algorithms["NONEWITHRSA"] = "RSA";
|
||||
algorithms["RSAWITHNONE"] = "RSA";
|
||||
algorithms["RAWRSA"] = "RSA";
|
||||
|
||||
algorithms["RAWRSAPSS"] = "RAWRSASSA-PSS";
|
||||
algorithms["NONEWITHRSAPSS"] = "RAWRSASSA-PSS";
|
||||
algorithms["NONEWITHRSASSA-PSS"] = "RAWRSASSA-PSS";
|
||||
|
||||
algorithms["NONEWITHDSA"] = "NONEwithDSA";
|
||||
algorithms["DSAWITHNONE"] = "NONEwithDSA";
|
||||
algorithms["RAWDSA"] = "NONEwithDSA";
|
||||
|
||||
algorithms["DSA"] = "SHA-1withDSA";
|
||||
algorithms["DSAWITHSHA1"] = "SHA-1withDSA";
|
||||
algorithms["DSAWITHSHA-1"] = "SHA-1withDSA";
|
||||
algorithms["SHA/DSA"] = "SHA-1withDSA";
|
||||
algorithms["SHA1/DSA"] = "SHA-1withDSA";
|
||||
algorithms["SHA-1/DSA"] = "SHA-1withDSA";
|
||||
algorithms["SHA1WITHDSA"] = "SHA-1withDSA";
|
||||
algorithms["SHA-1WITHDSA"] = "SHA-1withDSA";
|
||||
algorithms[X9ObjectIdentifiers.IdDsaWithSha1.Id] = "SHA-1withDSA";
|
||||
|
||||
algorithms["DSAWITHSHA224"] = "SHA-224withDSA";
|
||||
algorithms["DSAWITHSHA-224"] = "SHA-224withDSA";
|
||||
algorithms["SHA224/DSA"] = "SHA-224withDSA";
|
||||
algorithms["SHA-224/DSA"] = "SHA-224withDSA";
|
||||
algorithms["SHA224WITHDSA"] = "SHA-224withDSA";
|
||||
algorithms["SHA-224WITHDSA"] = "SHA-224withDSA";
|
||||
algorithms[NistObjectIdentifiers.DsaWithSha224.Id] = "SHA-224withDSA";
|
||||
|
||||
algorithms["DSAWITHSHA256"] = "SHA-256withDSA";
|
||||
algorithms["DSAWITHSHA-256"] = "SHA-256withDSA";
|
||||
algorithms["SHA256/DSA"] = "SHA-256withDSA";
|
||||
algorithms["SHA-256/DSA"] = "SHA-256withDSA";
|
||||
algorithms["SHA256WITHDSA"] = "SHA-256withDSA";
|
||||
algorithms["SHA-256WITHDSA"] = "SHA-256withDSA";
|
||||
algorithms[NistObjectIdentifiers.DsaWithSha256.Id] = "SHA-256withDSA";
|
||||
|
||||
algorithms["DSAWITHSHA384"] = "SHA-384withDSA";
|
||||
algorithms["DSAWITHSHA-384"] = "SHA-384withDSA";
|
||||
algorithms["SHA384/DSA"] = "SHA-384withDSA";
|
||||
algorithms["SHA-384/DSA"] = "SHA-384withDSA";
|
||||
algorithms["SHA384WITHDSA"] = "SHA-384withDSA";
|
||||
algorithms["SHA-384WITHDSA"] = "SHA-384withDSA";
|
||||
algorithms[NistObjectIdentifiers.DsaWithSha384.Id] = "SHA-384withDSA";
|
||||
|
||||
algorithms["DSAWITHSHA512"] = "SHA-512withDSA";
|
||||
algorithms["DSAWITHSHA-512"] = "SHA-512withDSA";
|
||||
algorithms["SHA512/DSA"] = "SHA-512withDSA";
|
||||
algorithms["SHA-512/DSA"] = "SHA-512withDSA";
|
||||
algorithms["SHA512WITHDSA"] = "SHA-512withDSA";
|
||||
algorithms["SHA-512WITHDSA"] = "SHA-512withDSA";
|
||||
algorithms[NistObjectIdentifiers.DsaWithSha512.Id] = "SHA-512withDSA";
|
||||
|
||||
algorithms["NONEWITHECDSA"] = "NONEwithECDSA";
|
||||
algorithms["ECDSAWITHNONE"] = "NONEwithECDSA";
|
||||
|
||||
algorithms["ECDSA"] = "SHA-1withECDSA";
|
||||
algorithms["SHA1/ECDSA"] = "SHA-1withECDSA";
|
||||
algorithms["SHA-1/ECDSA"] = "SHA-1withECDSA";
|
||||
algorithms["ECDSAWITHSHA1"] = "SHA-1withECDSA";
|
||||
algorithms["ECDSAWITHSHA-1"] = "SHA-1withECDSA";
|
||||
algorithms["SHA1WITHECDSA"] = "SHA-1withECDSA";
|
||||
algorithms["SHA-1WITHECDSA"] = "SHA-1withECDSA";
|
||||
algorithms[X9ObjectIdentifiers.ECDsaWithSha1.Id] = "SHA-1withECDSA";
|
||||
algorithms[TeleTrusTObjectIdentifiers.ECSignWithSha1.Id] = "SHA-1withECDSA";
|
||||
|
||||
algorithms["SHA224/ECDSA"] = "SHA-224withECDSA";
|
||||
algorithms["SHA-224/ECDSA"] = "SHA-224withECDSA";
|
||||
algorithms["ECDSAWITHSHA224"] = "SHA-224withECDSA";
|
||||
algorithms["ECDSAWITHSHA-224"] = "SHA-224withECDSA";
|
||||
algorithms["SHA224WITHECDSA"] = "SHA-224withECDSA";
|
||||
algorithms["SHA-224WITHECDSA"] = "SHA-224withECDSA";
|
||||
algorithms[X9ObjectIdentifiers.ECDsaWithSha224.Id] = "SHA-224withECDSA";
|
||||
|
||||
algorithms["SHA256/ECDSA"] = "SHA-256withECDSA";
|
||||
algorithms["SHA-256/ECDSA"] = "SHA-256withECDSA";
|
||||
algorithms["ECDSAWITHSHA256"] = "SHA-256withECDSA";
|
||||
algorithms["ECDSAWITHSHA-256"] = "SHA-256withECDSA";
|
||||
algorithms["SHA256WITHECDSA"] = "SHA-256withECDSA";
|
||||
algorithms["SHA-256WITHECDSA"] = "SHA-256withECDSA";
|
||||
algorithms[X9ObjectIdentifiers.ECDsaWithSha256.Id] = "SHA-256withECDSA";
|
||||
|
||||
algorithms["SHA384/ECDSA"] = "SHA-384withECDSA";
|
||||
algorithms["SHA-384/ECDSA"] = "SHA-384withECDSA";
|
||||
algorithms["ECDSAWITHSHA384"] = "SHA-384withECDSA";
|
||||
algorithms["ECDSAWITHSHA-384"] = "SHA-384withECDSA";
|
||||
algorithms["SHA384WITHECDSA"] = "SHA-384withECDSA";
|
||||
algorithms["SHA-384WITHECDSA"] = "SHA-384withECDSA";
|
||||
algorithms[X9ObjectIdentifiers.ECDsaWithSha384.Id] = "SHA-384withECDSA";
|
||||
|
||||
algorithms["SHA512/ECDSA"] = "SHA-512withECDSA";
|
||||
algorithms["SHA-512/ECDSA"] = "SHA-512withECDSA";
|
||||
algorithms["ECDSAWITHSHA512"] = "SHA-512withECDSA";
|
||||
algorithms["ECDSAWITHSHA-512"] = "SHA-512withECDSA";
|
||||
algorithms["SHA512WITHECDSA"] = "SHA-512withECDSA";
|
||||
algorithms["SHA-512WITHECDSA"] = "SHA-512withECDSA";
|
||||
algorithms[X9ObjectIdentifiers.ECDsaWithSha512.Id] = "SHA-512withECDSA";
|
||||
|
||||
algorithms["RIPEMD160/ECDSA"] = "RIPEMD160withECDSA";
|
||||
algorithms["ECDSAWITHRIPEMD160"] = "RIPEMD160withECDSA";
|
||||
algorithms["RIPEMD160WITHECDSA"] = "RIPEMD160withECDSA";
|
||||
algorithms[TeleTrusTObjectIdentifiers.ECSignWithRipeMD160.Id] = "RIPEMD160withECDSA";
|
||||
|
||||
algorithms["GOST-3410"] = "GOST3410";
|
||||
algorithms["GOST-3410-94"] = "GOST3410";
|
||||
algorithms["GOST3411WITHGOST3410"] = "GOST3410";
|
||||
algorithms[CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94.Id] = "GOST3410";
|
||||
|
||||
algorithms["ECGOST-3410"] = "ECGOST3410";
|
||||
algorithms["ECGOST-3410-2001"] = "ECGOST3410";
|
||||
algorithms["GOST3411WITHECGOST3410"] = "ECGOST3410";
|
||||
algorithms[CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001.Id] = "ECGOST3410";
|
||||
|
||||
|
||||
|
||||
oids["MD2withRSA"] = PkcsObjectIdentifiers.MD2WithRsaEncryption;
|
||||
oids["MD4withRSA"] = PkcsObjectIdentifiers.MD4WithRsaEncryption;
|
||||
oids["MD5withRSA"] = PkcsObjectIdentifiers.MD5WithRsaEncryption;
|
||||
|
||||
oids["SHA-1withRSA"] = PkcsObjectIdentifiers.Sha1WithRsaEncryption;
|
||||
oids["SHA-224withRSA"] = PkcsObjectIdentifiers.Sha224WithRsaEncryption;
|
||||
oids["SHA-256withRSA"] = PkcsObjectIdentifiers.Sha256WithRsaEncryption;
|
||||
oids["SHA-384withRSA"] = PkcsObjectIdentifiers.Sha384WithRsaEncryption;
|
||||
oids["SHA-512withRSA"] = PkcsObjectIdentifiers.Sha512WithRsaEncryption;
|
||||
|
||||
oids["PSSwithRSA"] = PkcsObjectIdentifiers.IdRsassaPss;
|
||||
oids["SHA-1withRSAandMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
|
||||
oids["SHA-224withRSAandMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
|
||||
oids["SHA-256withRSAandMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
|
||||
oids["SHA-384withRSAandMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
|
||||
oids["SHA-512withRSAandMGF1"] = PkcsObjectIdentifiers.IdRsassaPss;
|
||||
|
||||
oids["RIPEMD128withRSA"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD128;
|
||||
oids["RIPEMD160withRSA"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD160;
|
||||
oids["RIPEMD256withRSA"] = TeleTrusTObjectIdentifiers.RsaSignatureWithRipeMD256;
|
||||
|
||||
oids["SHA-1withDSA"] = X9ObjectIdentifiers.IdDsaWithSha1;
|
||||
|
||||
oids["SHA-1withECDSA"] = X9ObjectIdentifiers.ECDsaWithSha1;
|
||||
oids["SHA-224withECDSA"] = X9ObjectIdentifiers.ECDsaWithSha224;
|
||||
oids["SHA-256withECDSA"] = X9ObjectIdentifiers.ECDsaWithSha256;
|
||||
oids["SHA-384withECDSA"] = X9ObjectIdentifiers.ECDsaWithSha384;
|
||||
oids["SHA-512withECDSA"] = X9ObjectIdentifiers.ECDsaWithSha512;
|
||||
|
||||
oids["GOST3410"] = CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x94;
|
||||
oids["ECGOST3410"] = CryptoProObjectIdentifiers.GostR3411x94WithGostR3410x2001;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an ObjectIdentifier for a given encoding.
|
||||
/// </summary>
|
||||
/// <param name="mechanism">A string representation of the encoding.</param>
|
||||
/// <returns>A DerObjectIdentifier, null if the OID is not available.</returns>
|
||||
// TODO Don't really want to support this
|
||||
public static DerObjectIdentifier GetObjectIdentifier(
|
||||
string mechanism)
|
||||
{
|
||||
if (mechanism == null)
|
||||
throw new ArgumentNullException("mechanism");
|
||||
|
||||
mechanism = Platform.ToUpperInvariant(mechanism);
|
||||
string aliased = (string) algorithms[mechanism];
|
||||
|
||||
if (aliased != null)
|
||||
mechanism = aliased;
|
||||
|
||||
return (DerObjectIdentifier) oids[mechanism];
|
||||
}
|
||||
|
||||
public static ICollection Algorithms
|
||||
{
|
||||
get { return oids.Keys; }
|
||||
}
|
||||
|
||||
public static Asn1Encodable GetDefaultX509Parameters(
|
||||
DerObjectIdentifier id)
|
||||
{
|
||||
return GetDefaultX509Parameters(id.Id);
|
||||
}
|
||||
|
||||
public static Asn1Encodable GetDefaultX509Parameters(
|
||||
string algorithm)
|
||||
{
|
||||
if (algorithm == null)
|
||||
throw new ArgumentNullException("algorithm");
|
||||
|
||||
algorithm = Platform.ToUpperInvariant(algorithm);
|
||||
|
||||
string mechanism = (string) algorithms[algorithm];
|
||||
|
||||
if (mechanism == null)
|
||||
mechanism = algorithm;
|
||||
|
||||
if (mechanism == "PSSwithRSA")
|
||||
{
|
||||
// TODO The Sha1Digest here is a default. In JCE version, the actual digest
|
||||
// to be used can be overridden by subsequent parameter settings.
|
||||
return GetPssX509Parameters("SHA-1");
|
||||
}
|
||||
|
||||
if (Platform.EndsWith(mechanism, "withRSAandMGF1"))
|
||||
{
|
||||
string digestName = mechanism.Substring(0, mechanism.Length - "withRSAandMGF1".Length);
|
||||
return GetPssX509Parameters(digestName);
|
||||
}
|
||||
|
||||
return DerNull.Instance;
|
||||
}
|
||||
|
||||
private static Asn1Encodable GetPssX509Parameters(
|
||||
string digestName)
|
||||
{
|
||||
AlgorithmIdentifier hashAlgorithm = new AlgorithmIdentifier(
|
||||
DigestUtilities.GetObjectIdentifier(digestName), DerNull.Instance);
|
||||
|
||||
// TODO Is it possible for the MGF hash alg to be different from the PSS one?
|
||||
AlgorithmIdentifier maskGenAlgorithm = new AlgorithmIdentifier(
|
||||
PkcsObjectIdentifiers.IdMgf1, hashAlgorithm);
|
||||
|
||||
int saltLen = DigestUtilities.GetDigest(digestName).GetDigestSize();
|
||||
return new RsassaPssParameters(hashAlgorithm, maskGenAlgorithm,
|
||||
new DerInteger(saltLen), new DerInteger(1));
|
||||
}
|
||||
|
||||
public static ISigner GetSigner(
|
||||
DerObjectIdentifier id)
|
||||
{
|
||||
return GetSigner(id.Id);
|
||||
}
|
||||
|
||||
public static ISigner GetSigner(
|
||||
string algorithm)
|
||||
{
|
||||
if (algorithm == null)
|
||||
throw new ArgumentNullException("algorithm");
|
||||
|
||||
algorithm = Platform.ToUpperInvariant(algorithm);
|
||||
|
||||
string mechanism = (string) algorithms[algorithm];
|
||||
|
||||
if (mechanism == null)
|
||||
mechanism = algorithm;
|
||||
|
||||
if (mechanism.Equals("RSA"))
|
||||
{
|
||||
return (new RsaDigestSigner(new NullDigest(), (AlgorithmIdentifier)null));
|
||||
}
|
||||
if (mechanism.Equals("MD2withRSA"))
|
||||
{
|
||||
return (new RsaDigestSigner(new MD2Digest()));
|
||||
}
|
||||
if (mechanism.Equals("MD4withRSA"))
|
||||
{
|
||||
return (new RsaDigestSigner(new MD4Digest()));
|
||||
}
|
||||
if (mechanism.Equals("MD5withRSA"))
|
||||
{
|
||||
return (new RsaDigestSigner(new MD5Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-1withRSA"))
|
||||
{
|
||||
return (new RsaDigestSigner(new Sha1Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-224withRSA"))
|
||||
{
|
||||
return (new RsaDigestSigner(new Sha224Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-256withRSA"))
|
||||
{
|
||||
return (new RsaDigestSigner(new Sha256Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-384withRSA"))
|
||||
{
|
||||
return (new RsaDigestSigner(new Sha384Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-512withRSA"))
|
||||
{
|
||||
return (new RsaDigestSigner(new Sha512Digest()));
|
||||
}
|
||||
if (mechanism.Equals("RIPEMD128withRSA"))
|
||||
{
|
||||
return (new RsaDigestSigner(new RipeMD128Digest()));
|
||||
}
|
||||
if (mechanism.Equals("RIPEMD160withRSA"))
|
||||
{
|
||||
return (new RsaDigestSigner(new RipeMD160Digest()));
|
||||
}
|
||||
if (mechanism.Equals("RIPEMD256withRSA"))
|
||||
{
|
||||
return (new RsaDigestSigner(new RipeMD256Digest()));
|
||||
}
|
||||
|
||||
if (mechanism.Equals("RAWRSASSA-PSS"))
|
||||
{
|
||||
// TODO Add support for other parameter settings
|
||||
return PssSigner.CreateRawSigner(new RsaBlindedEngine(), new Sha1Digest());
|
||||
}
|
||||
if (mechanism.Equals("PSSwithRSA"))
|
||||
{
|
||||
// TODO The Sha1Digest here is a default. In JCE version, the actual digest
|
||||
// to be used can be overridden by subsequent parameter settings.
|
||||
return (new PssSigner(new RsaBlindedEngine(), new Sha1Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-1withRSAandMGF1"))
|
||||
{
|
||||
return (new PssSigner(new RsaBlindedEngine(), new Sha1Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-224withRSAandMGF1"))
|
||||
{
|
||||
return (new PssSigner(new RsaBlindedEngine(), new Sha224Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-256withRSAandMGF1"))
|
||||
{
|
||||
return (new PssSigner(new RsaBlindedEngine(), new Sha256Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-384withRSAandMGF1"))
|
||||
{
|
||||
return (new PssSigner(new RsaBlindedEngine(), new Sha384Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-512withRSAandMGF1"))
|
||||
{
|
||||
return (new PssSigner(new RsaBlindedEngine(), new Sha512Digest()));
|
||||
}
|
||||
|
||||
if (mechanism.Equals("NONEwithDSA"))
|
||||
{
|
||||
return (new DsaDigestSigner(new DsaSigner(), new NullDigest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-1withDSA"))
|
||||
{
|
||||
return (new DsaDigestSigner(new DsaSigner(), new Sha1Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-224withDSA"))
|
||||
{
|
||||
return (new DsaDigestSigner(new DsaSigner(), new Sha224Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-256withDSA"))
|
||||
{
|
||||
return (new DsaDigestSigner(new DsaSigner(), new Sha256Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-384withDSA"))
|
||||
{
|
||||
return (new DsaDigestSigner(new DsaSigner(), new Sha384Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-512withDSA"))
|
||||
{
|
||||
return (new DsaDigestSigner(new DsaSigner(), new Sha512Digest()));
|
||||
}
|
||||
|
||||
if (mechanism.Equals("NONEwithECDSA"))
|
||||
{
|
||||
return (new DsaDigestSigner(new ECDsaSigner(), new NullDigest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-1withECDSA"))
|
||||
{
|
||||
return (new DsaDigestSigner(new ECDsaSigner(), new Sha1Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-224withECDSA"))
|
||||
{
|
||||
return (new DsaDigestSigner(new ECDsaSigner(), new Sha224Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-256withECDSA"))
|
||||
{
|
||||
return (new DsaDigestSigner(new ECDsaSigner(), new Sha256Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-384withECDSA"))
|
||||
{
|
||||
return (new DsaDigestSigner(new ECDsaSigner(), new Sha384Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA-512withECDSA"))
|
||||
{
|
||||
return (new DsaDigestSigner(new ECDsaSigner(), new Sha512Digest()));
|
||||
}
|
||||
|
||||
if (mechanism.Equals("RIPEMD160withECDSA"))
|
||||
{
|
||||
return (new DsaDigestSigner(new ECDsaSigner(), new RipeMD160Digest()));
|
||||
}
|
||||
|
||||
if (mechanism.Equals("SHA1WITHECNR"))
|
||||
{
|
||||
return (new DsaDigestSigner(new ECNRSigner(), new Sha1Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA224WITHECNR"))
|
||||
{
|
||||
return (new DsaDigestSigner(new ECNRSigner(), new Sha224Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA256WITHECNR"))
|
||||
{
|
||||
return (new DsaDigestSigner(new ECNRSigner(), new Sha256Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA384WITHECNR"))
|
||||
{
|
||||
return (new DsaDigestSigner(new ECNRSigner(), new Sha384Digest()));
|
||||
}
|
||||
if (mechanism.Equals("SHA512WITHECNR"))
|
||||
{
|
||||
return (new DsaDigestSigner(new ECNRSigner(), new Sha512Digest()));
|
||||
}
|
||||
|
||||
if (mechanism.Equals("GOST3410"))
|
||||
{
|
||||
return new Gost3410DigestSigner(new Gost3410Signer(), new Gost3411Digest());
|
||||
}
|
||||
if (mechanism.Equals("ECGOST3410"))
|
||||
{
|
||||
return new Gost3410DigestSigner(new ECGost3410Signer(), new Gost3411Digest());
|
||||
}
|
||||
|
||||
if (mechanism.Equals("SHA1WITHRSA/ISO9796-2"))
|
||||
{
|
||||
return new Iso9796d2Signer(new RsaBlindedEngine(), new Sha1Digest(), true);
|
||||
}
|
||||
if (mechanism.Equals("MD5WITHRSA/ISO9796-2"))
|
||||
{
|
||||
return new Iso9796d2Signer(new RsaBlindedEngine(), new MD5Digest(), true);
|
||||
}
|
||||
if (mechanism.Equals("RIPEMD160WITHRSA/ISO9796-2"))
|
||||
{
|
||||
return new Iso9796d2Signer(new RsaBlindedEngine(), new RipeMD160Digest(), true);
|
||||
}
|
||||
|
||||
if (Platform.EndsWith(mechanism, "/X9.31"))
|
||||
{
|
||||
string x931 = mechanism.Substring(0, mechanism.Length - "/X9.31".Length);
|
||||
int withPos = Platform.IndexOf(x931, "WITH");
|
||||
if (withPos > 0)
|
||||
{
|
||||
int endPos = withPos + "WITH".Length;
|
||||
|
||||
string digestName = x931.Substring(0, withPos);
|
||||
IDigest digest = DigestUtilities.GetDigest(digestName);
|
||||
|
||||
string cipherName = x931.Substring(endPos, x931.Length - endPos);
|
||||
if (cipherName.Equals("RSA"))
|
||||
{
|
||||
IAsymmetricBlockCipher cipher = new RsaBlindedEngine();
|
||||
return new X931Signer(cipher, digest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new SecurityUtilityException("Signer " + algorithm + " not recognised.");
|
||||
}
|
||||
|
||||
public static string GetEncodingName(
|
||||
DerObjectIdentifier oid)
|
||||
{
|
||||
return (string) algorithms[oid.Id];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8032d63d53b654755b6154a92b37f920
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/BestHTTP/SecureProtocol/security/cert.meta
Normal file
8
Assets/BestHTTP/SecureProtocol/security/cert.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac8d8d3b6a76449d7bbec1afb6a8e76e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Security.Certificates
|
||||
{
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class CertificateEncodingException : CertificateException
|
||||
{
|
||||
public CertificateEncodingException() : base() { }
|
||||
public CertificateEncodingException(string msg) : base(msg) { }
|
||||
public CertificateEncodingException(string msg, Exception e) : base(msg, e) { }
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 147090e04a7864c22a3d62c84585a157
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Security.Certificates
|
||||
{
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class CertificateException : GeneralSecurityException
|
||||
{
|
||||
public CertificateException() : base() { }
|
||||
public CertificateException(string message) : base(message) { }
|
||||
public CertificateException(string message, Exception exception) : base(message, exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4b06fb6e162e43889f61e76947a4054
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Security.Certificates
|
||||
{
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class CertificateExpiredException : CertificateException
|
||||
{
|
||||
public CertificateExpiredException() : base() { }
|
||||
public CertificateExpiredException(string message) : base(message) { }
|
||||
public CertificateExpiredException(string message, Exception exception) : base(message, exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1ef794a0d7e84607ae89ca06b31b9e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Security.Certificates
|
||||
{
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class CertificateNotYetValidException : CertificateException
|
||||
{
|
||||
public CertificateNotYetValidException() : base() { }
|
||||
public CertificateNotYetValidException(string message) : base(message) { }
|
||||
public CertificateNotYetValidException(string message, Exception exception) : base(message, exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5aee826accd56475ea9ee25969e9ef7c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Security.Certificates
|
||||
{
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class CertificateParsingException : CertificateException
|
||||
{
|
||||
public CertificateParsingException() : base() { }
|
||||
public CertificateParsingException(string message) : base(message) { }
|
||||
public CertificateParsingException(string message, Exception exception) : base(message, exception) { }
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5c88acfbdbcf4a2ab1eda63056fdf9f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
Assets/BestHTTP/SecureProtocol/security/cert/CrlException.cs
Normal file
18
Assets/BestHTTP/SecureProtocol/security/cert/CrlException.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Security.Certificates
|
||||
{
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class CrlException : GeneralSecurityException
|
||||
{
|
||||
public CrlException() : base() { }
|
||||
public CrlException(string msg) : base(msg) {}
|
||||
public CrlException(string msg, Exception e) : base(msg, e) {}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 824d93f95f862451695171b938b77d7a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user