This commit is contained in:
2020-07-09 08:50:24 +08:00
parent 13d25f4707
commit c523462b82
1818 changed files with 174940 additions and 582 deletions

View File

@@ -0,0 +1,69 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class AeadParameters
: ICipherParameters
{
private readonly byte[] associatedText;
private readonly byte[] nonce;
private readonly KeyParameter key;
private readonly int macSize;
/**
* Base constructor.
*
* @param key key to be used by underlying cipher
* @param macSize macSize in bits
* @param nonce nonce to be used
*/
public AeadParameters(KeyParameter key, int macSize, byte[] nonce)
: this(key, macSize, nonce, null)
{
}
/**
* Base constructor.
*
* @param key key to be used by underlying cipher
* @param macSize macSize in bits
* @param nonce nonce to be used
* @param associatedText associated text, if any
*/
public AeadParameters(
KeyParameter key,
int macSize,
byte[] nonce,
byte[] associatedText)
{
this.key = key;
this.nonce = nonce;
this.macSize = macSize;
this.associatedText = associatedText;
}
public virtual KeyParameter Key
{
get { return key; }
}
public virtual int MacSize
{
get { return macSize; }
}
public virtual byte[] GetAssociatedText()
{
return associatedText;
}
public virtual byte[] GetNonce()
{
return nonce;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,35 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Security;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class DHKeyGenerationParameters
: KeyGenerationParameters
{
private readonly DHParameters parameters;
public DHKeyGenerationParameters(
SecureRandom random,
DHParameters parameters)
: base(random, GetStrength(parameters))
{
this.parameters = parameters;
}
public DHParameters Parameters
{
get { return parameters; }
}
internal static int GetStrength(
DHParameters parameters)
{
return parameters.L != 0 ? parameters.L : parameters.P.BitLength;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,80 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.Pkcs;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class DHKeyParameters
: AsymmetricKeyParameter
{
private readonly DHParameters parameters;
private readonly DerObjectIdentifier algorithmOid;
protected DHKeyParameters(
bool isPrivate,
DHParameters parameters)
: this(isPrivate, parameters, PkcsObjectIdentifiers.DhKeyAgreement)
{
}
protected DHKeyParameters(
bool isPrivate,
DHParameters parameters,
DerObjectIdentifier algorithmOid)
: base(isPrivate)
{
// TODO Should we allow parameters to be null?
this.parameters = parameters;
this.algorithmOid = algorithmOid;
}
public DHParameters Parameters
{
get { return parameters; }
}
public DerObjectIdentifier AlgorithmOid
{
get { return algorithmOid; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
DHKeyParameters other = obj as DHKeyParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
DHKeyParameters other)
{
return Platform.Equals(parameters, other.parameters)
&& base.Equals(other);
}
public override int GetHashCode()
{
int hc = base.GetHashCode();
if (parameters != null)
{
hc ^= parameters.GetHashCode();
}
return hc;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,189 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class DHParameters
: ICipherParameters
{
private const int DefaultMinimumLength = 160;
private readonly BigInteger p, g, q, j;
private readonly int m, l;
private readonly DHValidationParameters validation;
private static int GetDefaultMParam(
int lParam)
{
if (lParam == 0)
return DefaultMinimumLength;
return System.Math.Min(lParam, DefaultMinimumLength);
}
public DHParameters(
BigInteger p,
BigInteger g)
: this(p, g, null, 0)
{
}
public DHParameters(
BigInteger p,
BigInteger g,
BigInteger q)
: this(p, g, q, 0)
{
}
public DHParameters(
BigInteger p,
BigInteger g,
BigInteger q,
int l)
: this(p, g, q, GetDefaultMParam(l), l, null, null)
{
}
public DHParameters(
BigInteger p,
BigInteger g,
BigInteger q,
int m,
int l)
: this(p, g, q, m, l, null, null)
{
}
public DHParameters(
BigInteger p,
BigInteger g,
BigInteger q,
BigInteger j,
DHValidationParameters validation)
: this(p, g, q, DefaultMinimumLength, 0, j, validation)
{
}
public DHParameters(
BigInteger p,
BigInteger g,
BigInteger q,
int m,
int l,
BigInteger j,
DHValidationParameters validation)
{
if (p == null)
throw new ArgumentNullException("p");
if (g == null)
throw new ArgumentNullException("g");
if (!p.TestBit(0))
throw new ArgumentException("field must be an odd prime", "p");
if (g.CompareTo(BigInteger.Two) < 0
|| g.CompareTo(p.Subtract(BigInteger.Two)) > 0)
throw new ArgumentException("generator must in the range [2, p - 2]", "g");
if (q != null && q.BitLength >= p.BitLength)
throw new ArgumentException("q too big to be a factor of (p-1)", "q");
if (m >= p.BitLength)
throw new ArgumentException("m value must be < bitlength of p", "m");
if (l != 0)
{
// TODO Check this against the Java version, which has 'l > p.BitLength' here
if (l >= p.BitLength)
throw new ArgumentException("when l value specified, it must be less than bitlength(p)", "l");
if (l < m)
throw new ArgumentException("when l value specified, it may not be less than m value", "l");
}
if (j != null && j.CompareTo(BigInteger.Two) < 0)
throw new ArgumentException("subgroup factor must be >= 2", "j");
// TODO If q, j both provided, validate p = jq + 1 ?
this.p = p;
this.g = g;
this.q = q;
this.m = m;
this.l = l;
this.j = j;
this.validation = validation;
}
public BigInteger P
{
get { return p; }
}
public BigInteger G
{
get { return g; }
}
public BigInteger Q
{
get { return q; }
}
public BigInteger J
{
get { return j; }
}
/// <summary>The minimum bitlength of the private value.</summary>
public int M
{
get { return m; }
}
/// <summary>The bitlength of the private value.</summary>
public int L
{
get { return l; }
}
public DHValidationParameters ValidationParameters
{
get { return validation; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
DHParameters other = obj as DHParameters;
if (other == null)
return false;
return Equals(other);
}
protected virtual bool Equals(
DHParameters other)
{
return p.Equals(other.p)
&& g.Equals(other.g)
&& Platform.Equals(q, other.q);
}
public override int GetHashCode()
{
int hc = p.GetHashCode() ^ g.GetHashCode();
if (q != null)
{
hc ^= q.GetHashCode();
}
return hc;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,64 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class DHPrivateKeyParameters
: DHKeyParameters
{
private readonly BigInteger x;
public DHPrivateKeyParameters(
BigInteger x,
DHParameters parameters)
: base(true, parameters)
{
this.x = x;
}
public DHPrivateKeyParameters(
BigInteger x,
DHParameters parameters,
DerObjectIdentifier algorithmOid)
: base(true, parameters, algorithmOid)
{
this.x = x;
}
public BigInteger X
{
get { return x; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
DHPrivateKeyParameters other = obj as DHPrivateKeyParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
DHPrivateKeyParameters other)
{
return x.Equals(other.x) && base.Equals(other);
}
public override int GetHashCode()
{
return x.GetHashCode() ^ base.GetHashCode();
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,70 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class DHPublicKeyParameters
: DHKeyParameters
{
private readonly BigInteger y;
public DHPublicKeyParameters(
BigInteger y,
DHParameters parameters)
: base(false, parameters)
{
if (y == null)
throw new ArgumentNullException("y");
this.y = y;
}
public DHPublicKeyParameters(
BigInteger y,
DHParameters parameters,
DerObjectIdentifier algorithmOid)
: base(false, parameters, algorithmOid)
{
if (y == null)
throw new ArgumentNullException("y");
this.y = y;
}
public BigInteger Y
{
get { return y; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
DHPublicKeyParameters other = obj as DHPublicKeyParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
DHPublicKeyParameters other)
{
return y.Equals(other.y) && base.Equals(other);
}
public override int GetHashCode()
{
return y.GetHashCode() ^ base.GetHashCode();
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6c584754601a64cecba7c217c56bb17c
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)
using System;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class DHValidationParameters
{
private readonly byte[] seed;
private readonly int counter;
public DHValidationParameters(
byte[] seed,
int counter)
{
if (seed == null)
throw new ArgumentNullException("seed");
this.seed = (byte[]) seed.Clone();
this.counter = counter;
}
public byte[] GetSeed()
{
return (byte[]) seed.Clone();
}
public int Counter
{
get { return counter; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
DHValidationParameters other = obj as DHValidationParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
DHValidationParameters other)
{
return counter == other.counter
&& Arrays.AreEqual(this.seed, other.seed);
}
public override int GetHashCode()
{
return counter.GetHashCode() ^ Arrays.GetHashCode(seed);
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,144 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class DesEdeParameters
: DesParameters
{
/*
* DES-EDE Key length in bytes.
*/
public const int DesEdeKeyLength = 24;
private static byte[] FixKey(
byte[] key,
int keyOff,
int keyLen)
{
byte[] tmp = new byte[24];
switch (keyLen)
{
case 16:
Array.Copy(key, keyOff, tmp, 0, 16);
Array.Copy(key, keyOff, tmp, 16, 8);
break;
case 24:
Array.Copy(key, keyOff, tmp, 0, 24);
break;
default:
throw new ArgumentException("Bad length for DESede key: " + keyLen, "keyLen");
}
if (IsWeakKey(tmp))
throw new ArgumentException("attempt to create weak DESede key");
return tmp;
}
public DesEdeParameters(
byte[] key)
: base(FixKey(key, 0, key.Length))
{
}
public DesEdeParameters(
byte[] key,
int keyOff,
int keyLen)
: base(FixKey(key, keyOff, keyLen))
{
}
/**
* return true if the passed in key is a DES-EDE weak key.
*
* @param key bytes making up the key
* @param offset offset into the byte array the key starts at
* @param length number of bytes making up the key
*/
public static bool IsWeakKey(
byte[] key,
int offset,
int length)
{
for (int i = offset; i < length; i += DesKeyLength)
{
if (DesParameters.IsWeakKey(key, i))
{
return true;
}
}
return false;
}
/**
* return true if the passed in key is a DES-EDE weak key.
*
* @param key bytes making up the key
* @param offset offset into the byte array the key starts at
*/
public static new bool IsWeakKey(
byte[] key,
int offset)
{
return IsWeakKey(key, offset, key.Length - offset);
}
public static new bool IsWeakKey(
byte[] key)
{
return IsWeakKey(key, 0, key.Length);
}
/**
* return true if the passed in key is a real 2/3 part DES-EDE key.
*
* @param key bytes making up the key
* @param offset offset into the byte array the key starts at
*/
public static bool IsRealEdeKey(byte[] key, int offset)
{
return key.Length == 16 ? IsReal2Key(key, offset) : IsReal3Key(key, offset);
}
/**
* return true if the passed in key is a real 2 part DES-EDE key.
*
* @param key bytes making up the key
* @param offset offset into the byte array the key starts at
*/
public static bool IsReal2Key(byte[] key, int offset)
{
bool isValid = false;
for (int i = offset; i != offset + 8; i++)
{
isValid |= (key[i] != key[i + 8]);
}
return isValid;
}
/**
* return true if the passed in key is a real 3 part DES-EDE key.
*
* @param key bytes making up the key
* @param offset offset into the byte array the key starts at
*/
public static bool IsReal3Key(byte[] key, int offset)
{
bool diff12 = false, diff13 = false, diff23 = false;
for (int i = offset; i != offset + 8; i++)
{
diff12 |= (key[i] != key[i + 8]);
diff13 |= (key[i] != key[i + 16]);
diff23 |= (key[i + 8] != key[i + 16]);
}
return diff12 && diff13 && diff23;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,143 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class DesParameters
: KeyParameter
{
public DesParameters(
byte[] key)
: base(key)
{
if (IsWeakKey(key))
throw new ArgumentException("attempt to create weak DES key");
}
public DesParameters(
byte[] key,
int keyOff,
int keyLen)
: base(key, keyOff, keyLen)
{
if (IsWeakKey(key, keyOff))
throw new ArgumentException("attempt to create weak DES key");
}
/*
* DES Key Length in bytes.
*/
public const int DesKeyLength = 8;
/*
* Table of weak and semi-weak keys taken from Schneier pp281
*/
private const int N_DES_WEAK_KEYS = 16;
private static readonly byte[] DES_weak_keys =
{
/* weak keys */
(byte)0x01,(byte)0x01,(byte)0x01,(byte)0x01, (byte)0x01,(byte)0x01,(byte)0x01,(byte)0x01,
(byte)0x1f,(byte)0x1f,(byte)0x1f,(byte)0x1f, (byte)0x0e,(byte)0x0e,(byte)0x0e,(byte)0x0e,
(byte)0xe0,(byte)0xe0,(byte)0xe0,(byte)0xe0, (byte)0xf1,(byte)0xf1,(byte)0xf1,(byte)0xf1,
(byte)0xfe,(byte)0xfe,(byte)0xfe,(byte)0xfe, (byte)0xfe,(byte)0xfe,(byte)0xfe,(byte)0xfe,
/* semi-weak keys */
(byte)0x01,(byte)0xfe,(byte)0x01,(byte)0xfe, (byte)0x01,(byte)0xfe,(byte)0x01,(byte)0xfe,
(byte)0x1f,(byte)0xe0,(byte)0x1f,(byte)0xe0, (byte)0x0e,(byte)0xf1,(byte)0x0e,(byte)0xf1,
(byte)0x01,(byte)0xe0,(byte)0x01,(byte)0xe0, (byte)0x01,(byte)0xf1,(byte)0x01,(byte)0xf1,
(byte)0x1f,(byte)0xfe,(byte)0x1f,(byte)0xfe, (byte)0x0e,(byte)0xfe,(byte)0x0e,(byte)0xfe,
(byte)0x01,(byte)0x1f,(byte)0x01,(byte)0x1f, (byte)0x01,(byte)0x0e,(byte)0x01,(byte)0x0e,
(byte)0xe0,(byte)0xfe,(byte)0xe0,(byte)0xfe, (byte)0xf1,(byte)0xfe,(byte)0xf1,(byte)0xfe,
(byte)0xfe,(byte)0x01,(byte)0xfe,(byte)0x01, (byte)0xfe,(byte)0x01,(byte)0xfe,(byte)0x01,
(byte)0xe0,(byte)0x1f,(byte)0xe0,(byte)0x1f, (byte)0xf1,(byte)0x0e,(byte)0xf1,(byte)0x0e,
(byte)0xe0,(byte)0x01,(byte)0xe0,(byte)0x01, (byte)0xf1,(byte)0x01,(byte)0xf1,(byte)0x01,
(byte)0xfe,(byte)0x1f,(byte)0xfe,(byte)0x1f, (byte)0xfe,(byte)0x0e,(byte)0xfe,(byte)0x0e,
(byte)0x1f,(byte)0x01,(byte)0x1f,(byte)0x01, (byte)0x0e,(byte)0x01,(byte)0x0e,(byte)0x01,
(byte)0xfe,(byte)0xe0,(byte)0xfe,(byte)0xe0, (byte)0xfe,(byte)0xf1,(byte)0xfe,(byte)0xf1
};
/**
* DES has 16 weak keys. This method will check
* if the given DES key material is weak or semi-weak.
* Key material that is too short is regarded as weak.
* <p>
* See <a href="http://www.counterpane.com/applied.html">"Applied
* Cryptography"</a> by Bruce Schneier for more information.
* </p>
* @return true if the given DES key material is weak or semi-weak,
* false otherwise.
*/
public static bool IsWeakKey(
byte[] key,
int offset)
{
if (key.Length - offset < DesKeyLength)
throw new ArgumentException("key material too short.");
//nextkey:
for (int i = 0; i < N_DES_WEAK_KEYS; i++)
{
bool unmatch = false;
for (int j = 0; j < DesKeyLength; j++)
{
if (key[j + offset] != DES_weak_keys[i * DesKeyLength + j])
{
//continue nextkey;
unmatch = true;
break;
}
}
if (!unmatch)
{
return true;
}
}
return false;
}
public static bool IsWeakKey(
byte[] key)
{
return IsWeakKey(key, 0);
}
public static byte SetOddParity(byte b)
{
uint parity = b ^ 1U;
parity ^= (parity >> 4);
parity ^= (parity >> 2);
parity ^= (parity >> 1);
parity &= 1U;
return (byte)(b ^ parity);
}
/**
* DES Keys use the LSB as the odd parity bit. This can
* be used to check for corrupt keys.
*
* @param bytes the byte array to set the parity on.
*/
public static void SetOddParity(byte[] bytes)
{
for (int i = 0; i < bytes.Length; i++)
{
bytes[i] = SetOddParity(bytes[i]);
}
}
public static void SetOddParity(byte[] bytes, int off, int len)
{
for (int i = 0; i < len; i++)
{
bytes[off + i] = SetOddParity(bytes[off + i]);
}
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,30 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Security;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class DsaKeyGenerationParameters
: KeyGenerationParameters
{
private readonly DsaParameters parameters;
public DsaKeyGenerationParameters(
SecureRandom random,
DsaParameters parameters)
: base(random, parameters.P.BitLength - 1)
{
this.parameters = parameters;
}
public DsaParameters Parameters
{
get { return parameters; }
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 49a7a9c02915c4f909f30233a0838619
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)
using System;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Crypto.Parameters
{
public abstract class DsaKeyParameters
: AsymmetricKeyParameter
{
private readonly DsaParameters parameters;
protected DsaKeyParameters(
bool isPrivate,
DsaParameters parameters)
: base(isPrivate)
{
// Note: parameters may be null
this.parameters = parameters;
}
public DsaParameters Parameters
{
get { return parameters; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
DsaKeyParameters other = obj as DsaKeyParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
DsaKeyParameters other)
{
return Platform.Equals(parameters, other.parameters)
&& base.Equals(other);
}
public override int GetHashCode()
{
int hc = base.GetHashCode();
if (parameters != null)
{
hc ^= parameters.GetHashCode();
}
return hc;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,89 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class DsaParameters
: ICipherParameters
{
private readonly BigInteger p, q , g;
private readonly DsaValidationParameters validation;
public DsaParameters(
BigInteger p,
BigInteger q,
BigInteger g)
: this(p, q, g, null)
{
}
public DsaParameters(
BigInteger p,
BigInteger q,
BigInteger g,
DsaValidationParameters parameters)
{
if (p == null)
throw new ArgumentNullException("p");
if (q == null)
throw new ArgumentNullException("q");
if (g == null)
throw new ArgumentNullException("g");
this.p = p;
this.q = q;
this.g = g;
this.validation = parameters;
}
public BigInteger P
{
get { return p; }
}
public BigInteger Q
{
get { return q; }
}
public BigInteger G
{
get { return g; }
}
public DsaValidationParameters ValidationParameters
{
get { return validation; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
DsaParameters other = obj as DsaParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
DsaParameters other)
{
return p.Equals(other.p) && q.Equals(other.q) && g.Equals(other.g);
}
public override int GetHashCode()
{
return p.GetHashCode() ^ q.GetHashCode() ^ g.GetHashCode();
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,57 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class DsaPrivateKeyParameters
: DsaKeyParameters
{
private readonly BigInteger x;
public DsaPrivateKeyParameters(
BigInteger x,
DsaParameters parameters)
: base(true, parameters)
{
if (x == null)
throw new ArgumentNullException("x");
this.x = x;
}
public BigInteger X
{
get { return x; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
DsaPrivateKeyParameters other = obj as DsaPrivateKeyParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
DsaPrivateKeyParameters other)
{
return x.Equals(other.x) && base.Equals(other);
}
public override int GetHashCode()
{
return x.GetHashCode() ^ base.GetHashCode();
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,56 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class DsaPublicKeyParameters
: DsaKeyParameters
{
private readonly BigInteger y;
public DsaPublicKeyParameters(
BigInteger y,
DsaParameters parameters)
: base(false, parameters)
{
if (y == null)
throw new ArgumentNullException("y");
this.y = y;
}
public BigInteger Y
{
get { return y; }
}
public override bool Equals(object obj)
{
if (obj == this)
return true;
DsaPublicKeyParameters other = obj as DsaPublicKeyParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
DsaPublicKeyParameters other)
{
return y.Equals(other.y) && base.Equals(other);
}
public override int GetHashCode()
{
return y.GetHashCode() ^ base.GetHashCode();
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,76 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class DsaValidationParameters
{
private readonly byte[] seed;
private readonly int counter;
private readonly int usageIndex;
public DsaValidationParameters(byte[] seed, int counter)
: this(seed, counter, -1)
{
}
public DsaValidationParameters(
byte[] seed,
int counter,
int usageIndex)
{
if (seed == null)
throw new ArgumentNullException("seed");
this.seed = (byte[]) seed.Clone();
this.counter = counter;
this.usageIndex = usageIndex;
}
public virtual byte[] GetSeed()
{
return (byte[]) seed.Clone();
}
public virtual int Counter
{
get { return counter; }
}
public virtual int UsageIndex
{
get { return usageIndex; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
DsaValidationParameters other = obj as DsaValidationParameters;
if (other == null)
return false;
return Equals(other);
}
protected virtual bool Equals(
DsaValidationParameters other)
{
return counter == other.counter
&& Arrays.AreEqual(seed, other.seed);
}
public override int GetHashCode()
{
return counter.GetHashCode() ^ Arrays.GetHashCode(seed);
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,121 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.Math.EC;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class ECDomainParameters
{
internal ECCurve curve;
internal byte[] seed;
internal ECPoint g;
internal BigInteger n;
internal BigInteger h;
public ECDomainParameters(
ECCurve curve,
ECPoint g,
BigInteger n)
: this(curve, g, n, BigInteger.One)
{
}
public ECDomainParameters(
ECCurve curve,
ECPoint g,
BigInteger n,
BigInteger h)
: this(curve, g, n, h, null)
{
}
public ECDomainParameters(
ECCurve curve,
ECPoint g,
BigInteger n,
BigInteger h,
byte[] seed)
{
if (curve == null)
throw new ArgumentNullException("curve");
if (g == null)
throw new ArgumentNullException("g");
if (n == null)
throw new ArgumentNullException("n");
if (h == null)
throw new ArgumentNullException("h");
this.curve = curve;
this.g = g.Normalize();
this.n = n;
this.h = h;
this.seed = Arrays.Clone(seed);
}
public ECCurve Curve
{
get { return curve; }
}
public ECPoint G
{
get { return g; }
}
public BigInteger N
{
get { return n; }
}
public BigInteger H
{
get { return h; }
}
public byte[] GetSeed()
{
return Arrays.Clone(seed);
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
ECDomainParameters other = obj as ECDomainParameters;
if (other == null)
return false;
return Equals(other);
}
protected virtual bool Equals(
ECDomainParameters other)
{
return curve.Equals(other.curve)
&& g.Equals(other.g)
&& n.Equals(other.n)
&& h.Equals(other.h);
}
public override int GetHashCode()
{
int hc = curve.GetHashCode();
hc *= 37;
hc ^= g.GetHashCode();
hc *= 37;
hc ^= n.GetHashCode();
hc *= 37;
hc ^= h.GetHashCode();
return hc;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,45 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.CryptoPro;
using Org.BouncyCastle.Security;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class ECKeyGenerationParameters
: KeyGenerationParameters
{
private readonly ECDomainParameters domainParams;
private readonly DerObjectIdentifier publicKeyParamSet;
public ECKeyGenerationParameters(
ECDomainParameters domainParameters,
SecureRandom random)
: base(random, domainParameters.N.BitLength)
{
this.domainParams = domainParameters;
}
public ECKeyGenerationParameters(
DerObjectIdentifier publicKeyParamSet,
SecureRandom random)
: this(ECKeyParameters.LookupParameters(publicKeyParamSet), random)
{
this.publicKeyParamSet = publicKeyParamSet;
}
public ECDomainParameters DomainParameters
{
get { return domainParams; }
}
public DerObjectIdentifier PublicKeyParamSet
{
get { return publicKeyParamSet; }
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,140 @@
#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.X9;
using Org.BouncyCastle.Crypto.Generators;
using Org.BouncyCastle.Security;
using Org.BouncyCastle.Utilities;
using Org.BouncyCastle.Utilities.Collections;
namespace Org.BouncyCastle.Crypto.Parameters
{
public abstract class ECKeyParameters
: AsymmetricKeyParameter
{
private static readonly string[] algorithms = { "EC", "ECDSA", "ECDH", "ECDHC", "ECGOST3410", "ECMQV" };
private readonly string algorithm;
private readonly ECDomainParameters parameters;
private readonly DerObjectIdentifier publicKeyParamSet;
protected ECKeyParameters(
string algorithm,
bool isPrivate,
ECDomainParameters parameters)
: base(isPrivate)
{
if (algorithm == null)
throw new ArgumentNullException("algorithm");
if (parameters == null)
throw new ArgumentNullException("parameters");
this.algorithm = VerifyAlgorithmName(algorithm);
this.parameters = parameters;
}
protected ECKeyParameters(
string algorithm,
bool isPrivate,
DerObjectIdentifier publicKeyParamSet)
: base(isPrivate)
{
if (algorithm == null)
throw new ArgumentNullException("algorithm");
if (publicKeyParamSet == null)
throw new ArgumentNullException("publicKeyParamSet");
this.algorithm = VerifyAlgorithmName(algorithm);
this.parameters = LookupParameters(publicKeyParamSet);
this.publicKeyParamSet = publicKeyParamSet;
}
public string AlgorithmName
{
get { return algorithm; }
}
public ECDomainParameters Parameters
{
get { return parameters; }
}
public DerObjectIdentifier PublicKeyParamSet
{
get { return publicKeyParamSet; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
ECDomainParameters other = obj as ECDomainParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
ECKeyParameters other)
{
return parameters.Equals(other.parameters) && base.Equals(other);
}
public override int GetHashCode()
{
return parameters.GetHashCode() ^ base.GetHashCode();
}
internal ECKeyGenerationParameters CreateKeyGenerationParameters(
SecureRandom random)
{
if (publicKeyParamSet != null)
{
return new ECKeyGenerationParameters(publicKeyParamSet, random);
}
return new ECKeyGenerationParameters(parameters, random);
}
internal static string VerifyAlgorithmName(string algorithm)
{
string upper = Platform.ToUpperInvariant(algorithm);
if (Array.IndexOf(algorithms, algorithm, 0, algorithms.Length) < 0)
throw new ArgumentException("unrecognised algorithm: " + algorithm, "algorithm");
return upper;
}
internal static ECDomainParameters LookupParameters(
DerObjectIdentifier publicKeyParamSet)
{
if (publicKeyParamSet == null)
throw new ArgumentNullException("publicKeyParamSet");
ECDomainParameters p = ECGost3410NamedCurves.GetByOid(publicKeyParamSet);
if (p == null)
{
X9ECParameters x9 = ECKeyPairGenerator.FindECCurveByOid(publicKeyParamSet);
if (x9 == null)
{
throw new ArgumentException("OID is not a valid public key parameter set", "publicKeyParamSet");
}
p = new ECDomainParameters(x9.Curve, x9.G, x9.N, x9.H, x9.GetSeed());
}
return p;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,91 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using System.Globalization;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class ECPrivateKeyParameters
: ECKeyParameters
{
private readonly BigInteger d;
public ECPrivateKeyParameters(
BigInteger d,
ECDomainParameters parameters)
: this("EC", d, parameters)
{
}
[Obsolete("Use version with explicit 'algorithm' parameter")]
public ECPrivateKeyParameters(
BigInteger d,
DerObjectIdentifier publicKeyParamSet)
: base("ECGOST3410", true, publicKeyParamSet)
{
if (d == null)
throw new ArgumentNullException("d");
this.d = d;
}
public ECPrivateKeyParameters(
string algorithm,
BigInteger d,
ECDomainParameters parameters)
: base(algorithm, true, parameters)
{
if (d == null)
throw new ArgumentNullException("d");
this.d = d;
}
public ECPrivateKeyParameters(
string algorithm,
BigInteger d,
DerObjectIdentifier publicKeyParamSet)
: base(algorithm, true, publicKeyParamSet)
{
if (d == null)
throw new ArgumentNullException("d");
this.d = d;
}
public BigInteger D
{
get { return d; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
ECPrivateKeyParameters other = obj as ECPrivateKeyParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
ECPrivateKeyParameters other)
{
return d.Equals(other.d) && base.Equals(other);
}
public override int GetHashCode()
{
return d.GetHashCode() ^ base.GetHashCode();
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,90 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using System.Globalization;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Math.EC;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class ECPublicKeyParameters
: ECKeyParameters
{
private readonly ECPoint q;
public ECPublicKeyParameters(
ECPoint q,
ECDomainParameters parameters)
: this("EC", q, parameters)
{
}
[Obsolete("Use version with explicit 'algorithm' parameter")]
public ECPublicKeyParameters(
ECPoint q,
DerObjectIdentifier publicKeyParamSet)
: base("ECGOST3410", false, publicKeyParamSet)
{
if (q == null)
throw new ArgumentNullException("q");
this.q = q.Normalize();
}
public ECPublicKeyParameters(
string algorithm,
ECPoint q,
ECDomainParameters parameters)
: base(algorithm, false, parameters)
{
if (q == null)
throw new ArgumentNullException("q");
this.q = q.Normalize();
}
public ECPublicKeyParameters(
string algorithm,
ECPoint q,
DerObjectIdentifier publicKeyParamSet)
: base(algorithm, false, publicKeyParamSet)
{
if (q == null)
throw new ArgumentNullException("q");
this.q = q.Normalize();
}
public ECPoint Q
{
get { return q; }
}
public override bool Equals(object obj)
{
if (obj == this)
return true;
ECPublicKeyParameters other = obj as ECPublicKeyParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
ECPublicKeyParameters other)
{
return q.Equals(other.q) && base.Equals(other);
}
public override int GetHashCode()
{
return q.GetHashCode() ^ base.GetHashCode();
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,35 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Security;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class ElGamalKeyGenerationParameters
: KeyGenerationParameters
{
private readonly ElGamalParameters parameters;
public ElGamalKeyGenerationParameters(
SecureRandom random,
ElGamalParameters parameters)
: base(random, GetStrength(parameters))
{
this.parameters = parameters;
}
public ElGamalParameters Parameters
{
get { return parameters; }
}
internal static int GetStrength(
ElGamalParameters parameters)
{
return parameters.L != 0 ? parameters.L : parameters.P.BitLength;
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ea4f4cb15c2ac4963bdd4984b30b3a3e
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)
using System;
using Org.BouncyCastle.Utilities;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class ElGamalKeyParameters
: AsymmetricKeyParameter
{
private readonly ElGamalParameters parameters;
protected ElGamalKeyParameters(
bool isPrivate,
ElGamalParameters parameters)
: base(isPrivate)
{
// TODO Should we allow 'parameters' to be null?
this.parameters = parameters;
}
public ElGamalParameters Parameters
{
get { return parameters; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
ElGamalKeyParameters other = obj as ElGamalKeyParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
ElGamalKeyParameters other)
{
return Platform.Equals(parameters, other.parameters)
&& base.Equals(other);
}
public override int GetHashCode()
{
int hc = base.GetHashCode();
if (parameters != null)
{
hc ^= parameters.GetHashCode();
}
return hc;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,85 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class ElGamalParameters
: ICipherParameters
{
private readonly BigInteger p, g;
private readonly int l;
public ElGamalParameters(
BigInteger p,
BigInteger g)
: this(p, g, 0)
{
}
public ElGamalParameters(
BigInteger p,
BigInteger g,
int l)
{
if (p == null)
throw new ArgumentNullException("p");
if (g == null)
throw new ArgumentNullException("g");
this.p = p;
this.g = g;
this.l = l;
}
public BigInteger P
{
get { return p; }
}
/**
* return the generator - g
*/
public BigInteger G
{
get { return g; }
}
/**
* return private value limit - l
*/
public int L
{
get { return l; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
ElGamalParameters other = obj as ElGamalParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
ElGamalParameters other)
{
return p.Equals(other.p) && g.Equals(other.g) && l == other.l;
}
public override int GetHashCode()
{
return p.GetHashCode() ^ g.GetHashCode() ^ l;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,57 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class ElGamalPrivateKeyParameters
: ElGamalKeyParameters
{
private readonly BigInteger x;
public ElGamalPrivateKeyParameters(
BigInteger x,
ElGamalParameters parameters)
: base(true, parameters)
{
if (x == null)
throw new ArgumentNullException("x");
this.x = x;
}
public BigInteger X
{
get { return x; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
ElGamalPrivateKeyParameters other = obj as ElGamalPrivateKeyParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
ElGamalPrivateKeyParameters other)
{
return other.x.Equals(x) && base.Equals(other);
}
public override int GetHashCode()
{
return x.GetHashCode() ^ base.GetHashCode();
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,57 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class ElGamalPublicKeyParameters
: ElGamalKeyParameters
{
private readonly BigInteger y;
public ElGamalPublicKeyParameters(
BigInteger y,
ElGamalParameters parameters)
: base(false, parameters)
{
if (y == null)
throw new ArgumentNullException("y");
this.y = y;
}
public BigInteger Y
{
get { return y; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
ElGamalPublicKeyParameters other = obj as ElGamalPublicKeyParameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
ElGamalPublicKeyParameters other)
{
return y.Equals(other.y) && base.Equals(other);
}
public override int GetHashCode()
{
return y.GetHashCode() ^ base.GetHashCode();
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,62 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.CryptoPro;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public abstract class Gost3410KeyParameters
: AsymmetricKeyParameter
{
private readonly Gost3410Parameters parameters;
private readonly DerObjectIdentifier publicKeyParamSet;
protected Gost3410KeyParameters(
bool isPrivate,
Gost3410Parameters parameters)
: base(isPrivate)
{
this.parameters = parameters;
}
protected Gost3410KeyParameters(
bool isPrivate,
DerObjectIdentifier publicKeyParamSet)
: base(isPrivate)
{
this.parameters = LookupParameters(publicKeyParamSet);
this.publicKeyParamSet = publicKeyParamSet;
}
public Gost3410Parameters Parameters
{
get { return parameters; }
}
public DerObjectIdentifier PublicKeyParamSet
{
get { return publicKeyParamSet; }
}
// TODO Implement Equals/GetHashCode
private static Gost3410Parameters LookupParameters(
DerObjectIdentifier publicKeyParamSet)
{
if (publicKeyParamSet == null)
throw new ArgumentNullException("publicKeyParamSet");
Gost3410ParamSetParameters p = Gost3410NamedParameters.GetByOid(publicKeyParamSet);
if (p == null)
throw new ArgumentException("OID is not a valid CryptoPro public key parameter set", "publicKeyParamSet");
return new Gost3410Parameters(p.P, p.Q, p.A);
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,90 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class Gost3410Parameters
: ICipherParameters
{
private readonly BigInteger p, q, a;
private readonly Gost3410ValidationParameters validation;
public Gost3410Parameters(
BigInteger p,
BigInteger q,
BigInteger a)
: this(p, q, a, null)
{
}
public Gost3410Parameters(
BigInteger p,
BigInteger q,
BigInteger a,
Gost3410ValidationParameters validation)
{
if (p == null)
throw new ArgumentNullException("p");
if (q == null)
throw new ArgumentNullException("q");
if (a == null)
throw new ArgumentNullException("a");
this.p = p;
this.q = q;
this.a = a;
this.validation = validation;
}
public BigInteger P
{
get { return p; }
}
public BigInteger Q
{
get { return q; }
}
public BigInteger A
{
get { return a; }
}
public Gost3410ValidationParameters ValidationParameters
{
get { return validation; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
Gost3410Parameters other = obj as Gost3410Parameters;
if (other == null)
return false;
return Equals(other);
}
protected bool Equals(
Gost3410Parameters other)
{
return p.Equals(other.p) && q.Equals(other.q) && a.Equals(other.a);
}
public override int GetHashCode()
{
return p.GetHashCode() ^ q.GetHashCode() ^ a.GetHashCode();
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,45 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Asn1.CryptoPro;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class Gost3410PrivateKeyParameters
: Gost3410KeyParameters
{
private readonly BigInteger x;
public Gost3410PrivateKeyParameters(
BigInteger x,
Gost3410Parameters parameters)
: base(true, parameters)
{
if (x.SignValue < 1 || x.BitLength > 256 || x.CompareTo(Parameters.Q) >= 0)
throw new ArgumentException("Invalid x for GOST3410 private key", "x");
this.x = x;
}
public Gost3410PrivateKeyParameters(
BigInteger x,
DerObjectIdentifier publicKeyParamSet)
: base(true, publicKeyParamSet)
{
if (x.SignValue < 1 || x.BitLength > 256 || x.CompareTo(Parameters.Q) >= 0)
throw new ArgumentException("Invalid x for GOST3410 private key", "x");
this.x = x;
}
public BigInteger X
{
get { return x; }
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,44 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Asn1;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class Gost3410PublicKeyParameters
: Gost3410KeyParameters
{
private readonly BigInteger y;
public Gost3410PublicKeyParameters(
BigInteger y,
Gost3410Parameters parameters)
: base(false, parameters)
{
if (y.SignValue < 1 || y.CompareTo(Parameters.P) >= 0)
throw new ArgumentException("Invalid y for GOST3410 public key", "y");
this.y = y;
}
public Gost3410PublicKeyParameters(
BigInteger y,
DerObjectIdentifier publicKeyParamSet)
: base(false, publicKeyParamSet)
{
if (y.SignValue < 1 || y.CompareTo(Parameters.P) >= 0)
throw new ArgumentException("Invalid y for GOST3410 public key", "y");
this.y = y;
}
public BigInteger Y
{
get { return y; }
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 74d1e317496f84632a9bbe1fb973605c
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)
using System;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class Gost3410ValidationParameters
{
private int x0;
private int c;
private long x0L;
private long cL;
public Gost3410ValidationParameters(
int x0,
int c)
{
this.x0 = x0;
this.c = c;
}
public Gost3410ValidationParameters(
long x0L,
long cL)
{
this.x0L = x0L;
this.cL = cL;
}
public int C { get { return c; } }
public int X0 { get { return x0; } }
public long CL { get { return cL; } }
public long X0L { get { return x0L; } }
public override bool Equals(
object obj)
{
Gost3410ValidationParameters other = obj as Gost3410ValidationParameters;
return other != null
&& other.c == this.c
&& other.x0 == this.x0
&& other.cL == this.cL
&& other.x0L == this.x0L;
}
public override int GetHashCode()
{
return c.GetHashCode() ^ x0.GetHashCode() ^ cL.GetHashCode() ^ x0L.GetHashCode();
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,29 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Crypto;
namespace Org.BouncyCastle.Crypto.Parameters
{
/**
* parameters for Key derivation functions for ISO-18033
*/
public class Iso18033KdfParameters
: IDerivationParameters
{
byte[] seed;
public Iso18033KdfParameters(
byte[] seed)
{
this.seed = seed;
}
public byte[] GetSeed()
{
return seed;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,53 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Crypto;
namespace Org.BouncyCastle.Crypto.Parameters
{
/**
* parameters for using an integrated cipher in stream mode.
*/
public class IesParameters : ICipherParameters
{
private byte[] derivation;
private byte[] encoding;
private int macKeySize;
/**
* @param derivation the derivation parameter for the KDF function.
* @param encoding the encoding parameter for the KDF function.
* @param macKeySize the size of the MAC key (in bits).
*/
public IesParameters(
byte[] derivation,
byte[] encoding,
int macKeySize)
{
this.derivation = derivation;
this.encoding = encoding;
this.macKeySize = macKeySize;
}
public byte[] GetDerivationV()
{
return derivation;
}
public byte[] GetEncodingV()
{
return encoding;
}
public int MacKeySize
{
get
{
return macKeySize;
}
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,37 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class IesWithCipherParameters : IesParameters
{
private int cipherKeySize;
/**
* @param derivation the derivation parameter for the KDF function.
* @param encoding the encoding parameter for the KDF function.
* @param macKeySize the size of the MAC key (in bits).
* @param cipherKeySize the size of the associated Cipher key (in bits).
*/
public IesWithCipherParameters(
byte[] derivation,
byte[] encoding,
int macKeySize,
int cipherKeySize) : base(derivation, encoding, macKeySize)
{
this.cipherKeySize = cipherKeySize;
}
public int CipherKeySize
{
get
{
return cipherKeySize;
}
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,37 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Crypto;
namespace Org.BouncyCastle.Crypto.Parameters
{
/**
* parameters for Key derivation functions for IEEE P1363a
*/
public class KdfParameters : IDerivationParameters
{
byte[] iv;
byte[] shared;
public KdfParameters(
byte[] shared,
byte[] iv)
{
this.shared = shared;
this.iv = iv;
}
public byte[] GetSharedSecret()
{
return shared;
}
public byte[] GetIV()
{
return iv;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,47 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Crypto;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class KeyParameter
: ICipherParameters
{
private readonly byte[] key;
public KeyParameter(
byte[] key)
{
if (key == null)
throw new ArgumentNullException("key");
this.key = (byte[]) key.Clone();
}
public KeyParameter(
byte[] key,
int keyOff,
int keyLen)
{
if (key == null)
throw new ArgumentNullException("key");
if (keyOff < 0 || keyOff > key.Length)
throw new ArgumentOutOfRangeException("keyOff");
if (keyLen < 0 || (keyOff + keyLen) > key.Length)
throw new ArgumentOutOfRangeException("keyLen");
this.key = new byte[keyLen];
Array.Copy(key, keyOff, this.key, 0, keyLen);
}
public byte[] GetKey()
{
return (byte[]) key.Clone();
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,68 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class MqvPrivateParameters
: ICipherParameters
{
private readonly ECPrivateKeyParameters staticPrivateKey;
private readonly ECPrivateKeyParameters ephemeralPrivateKey;
private readonly ECPublicKeyParameters ephemeralPublicKey;
public MqvPrivateParameters(
ECPrivateKeyParameters staticPrivateKey,
ECPrivateKeyParameters ephemeralPrivateKey)
: this(staticPrivateKey, ephemeralPrivateKey, null)
{
}
public MqvPrivateParameters(
ECPrivateKeyParameters staticPrivateKey,
ECPrivateKeyParameters ephemeralPrivateKey,
ECPublicKeyParameters ephemeralPublicKey)
{
if (staticPrivateKey == null)
throw new ArgumentNullException("staticPrivateKey");
if (ephemeralPrivateKey == null)
throw new ArgumentNullException("ephemeralPrivateKey");
ECDomainParameters parameters = staticPrivateKey.Parameters;
if (!parameters.Equals(ephemeralPrivateKey.Parameters))
throw new ArgumentException("Static and ephemeral private keys have different domain parameters");
if (ephemeralPublicKey == null)
{
ephemeralPublicKey = new ECPublicKeyParameters(
parameters.G.Multiply(ephemeralPrivateKey.D),
parameters);
}
else if (!parameters.Equals(ephemeralPublicKey.Parameters))
{
throw new ArgumentException("Ephemeral public key has different domain parameters");
}
this.staticPrivateKey = staticPrivateKey;
this.ephemeralPrivateKey = ephemeralPrivateKey;
this.ephemeralPublicKey = ephemeralPublicKey;
}
public virtual ECPrivateKeyParameters StaticPrivateKey
{
get { return staticPrivateKey; }
}
public virtual ECPrivateKeyParameters EphemeralPrivateKey
{
get { return ephemeralPrivateKey; }
}
public virtual ECPublicKeyParameters EphemeralPublicKey
{
get { return ephemeralPublicKey; }
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,40 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class MqvPublicParameters
: ICipherParameters
{
private readonly ECPublicKeyParameters staticPublicKey;
private readonly ECPublicKeyParameters ephemeralPublicKey;
public MqvPublicParameters(
ECPublicKeyParameters staticPublicKey,
ECPublicKeyParameters ephemeralPublicKey)
{
if (staticPublicKey == null)
throw new ArgumentNullException("staticPublicKey");
if (ephemeralPublicKey == null)
throw new ArgumentNullException("ephemeralPublicKey");
if (!staticPublicKey.Parameters.Equals(ephemeralPublicKey.Parameters))
throw new ArgumentException("Static and ephemeral public keys have different domain parameters");
this.staticPublicKey = staticPublicKey;
this.ephemeralPublicKey = ephemeralPublicKey;
}
public virtual ECPublicKeyParameters StaticPublicKey
{
get { return staticPublicKey; }
}
public virtual ECPublicKeyParameters EphemeralPublicKey
{
get { return ephemeralPublicKey; }
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,47 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class ParametersWithIV
: ICipherParameters
{
private readonly ICipherParameters parameters;
private readonly byte[] iv;
public ParametersWithIV(
ICipherParameters parameters,
byte[] iv)
: this(parameters, iv, 0, iv.Length)
{
}
public ParametersWithIV(
ICipherParameters parameters,
byte[] iv,
int ivOff,
int ivLen)
{
// NOTE: 'parameters' may be null to imply key re-use
if (iv == null)
throw new ArgumentNullException("iv");
this.parameters = parameters;
this.iv = new byte[ivLen];
Array.Copy(iv, ivOff, this.iv, 0, ivLen);
}
public byte[] GetIV()
{
return (byte[]) iv.Clone();
}
public ICipherParameters Parameters
{
get { return parameters; }
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,52 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Security;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class ParametersWithRandom
: ICipherParameters
{
private readonly ICipherParameters parameters;
private readonly SecureRandom random;
public ParametersWithRandom(
ICipherParameters parameters,
SecureRandom random)
{
if (parameters == null)
throw new ArgumentNullException("parameters");
if (random == null)
throw new ArgumentNullException("random");
this.parameters = parameters;
this.random = random;
}
public ParametersWithRandom(
ICipherParameters parameters)
: this(parameters, new SecureRandom())
{
}
[Obsolete("Use Random property instead")]
public SecureRandom GetRandom()
{
return Random;
}
public SecureRandom Random
{
get { return random; }
}
public ICipherParameters Parameters
{
get { return parameters; }
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,28 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Crypto;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class ParametersWithSBox : ICipherParameters
{
private ICipherParameters parameters;
private byte[] sBox;
public ParametersWithSBox(
ICipherParameters parameters,
byte[] sBox)
{
this.parameters = parameters;
this.sBox = sBox;
}
public byte[] GetSBox() { return sBox; }
public ICipherParameters Parameters { get { return parameters; } }
}
}
#endif

View File

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

View File

@@ -0,0 +1,43 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Crypto;
namespace Org.BouncyCastle.Crypto.Parameters
{
/// <summary> Cipher parameters with a fixed salt value associated with them.</summary>
public class ParametersWithSalt : ICipherParameters
{
private byte[] salt;
private ICipherParameters parameters;
public ParametersWithSalt(ICipherParameters parameters, byte[] salt):this(parameters, salt, 0, salt.Length)
{
}
public ParametersWithSalt(ICipherParameters parameters, byte[] salt, int saltOff, int saltLen)
{
this.salt = new byte[saltLen];
this.parameters = parameters;
Array.Copy(salt, saltOff, this.salt, 0, saltLen);
}
public byte[] GetSalt()
{
return salt;
}
public ICipherParameters Parameters
{
get
{
return parameters;
}
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,51 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class RC2Parameters
: KeyParameter
{
private readonly int bits;
public RC2Parameters(
byte[] key)
: this(key, (key.Length > 128) ? 1024 : (key.Length * 8))
{
}
public RC2Parameters(
byte[] key,
int keyOff,
int keyLen)
: this(key, keyOff, keyLen, (keyLen > 128) ? 1024 : (keyLen * 8))
{
}
public RC2Parameters(
byte[] key,
int bits)
: base(key)
{
this.bits = bits;
}
public RC2Parameters(
byte[] key,
int keyOff,
int keyLen,
int bits)
: base(key, keyOff, keyLen)
{
this.bits = bits;
}
public int EffectiveKeyBits
{
get { return bits; }
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4ce922dfcd84e4a46a79d7196282df68
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)
using System;
using Org.BouncyCastle.Crypto;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class RC5Parameters
: KeyParameter
{
private readonly int rounds;
public RC5Parameters(
byte[] key,
int rounds)
: base(key)
{
if (key.Length > 255)
throw new ArgumentException("RC5 key length can be no greater than 255");
this.rounds = rounds;
}
public int Rounds
{
get { return rounds; }
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,38 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class RsaBlindingParameters
: ICipherParameters
{
private readonly RsaKeyParameters publicKey;
private readonly BigInteger blindingFactor;
public RsaBlindingParameters(
RsaKeyParameters publicKey,
BigInteger blindingFactor)
{
if (publicKey.IsPrivate)
throw new ArgumentException("RSA parameters should be for a public key");
this.publicKey = publicKey;
this.blindingFactor = blindingFactor;
}
public RsaKeyParameters PublicKey
{
get { return publicKey; }
}
public BigInteger BlindingFactor
{
get { return blindingFactor; }
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,59 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Math;
using Org.BouncyCastle.Security;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class RsaKeyGenerationParameters
: KeyGenerationParameters
{
private readonly BigInteger publicExponent;
private readonly int certainty;
public RsaKeyGenerationParameters(
BigInteger publicExponent,
SecureRandom random,
int strength,
int certainty)
: base(random, strength)
{
this.publicExponent = publicExponent;
this.certainty = certainty;
}
public BigInteger PublicExponent
{
get { return publicExponent; }
}
public int Certainty
{
get { return certainty; }
}
public override bool Equals(
object obj)
{
RsaKeyGenerationParameters other = obj as RsaKeyGenerationParameters;
if (other == null)
{
return false;
}
return certainty == other.certainty
&& publicExponent.Equals(other.publicExponent);
}
public override int GetHashCode()
{
return certainty.GetHashCode() ^ publicExponent.GetHashCode();
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,67 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class RsaKeyParameters
: AsymmetricKeyParameter
{
private readonly BigInteger modulus;
private readonly BigInteger exponent;
public RsaKeyParameters(
bool isPrivate,
BigInteger modulus,
BigInteger exponent)
: base(isPrivate)
{
if (modulus == null)
throw new ArgumentNullException("modulus");
if (exponent == null)
throw new ArgumentNullException("exponent");
if (modulus.SignValue <= 0)
throw new ArgumentException("Not a valid RSA modulus", "modulus");
if (exponent.SignValue <= 0)
throw new ArgumentException("Not a valid RSA exponent", "exponent");
this.modulus = modulus;
this.exponent = exponent;
}
public BigInteger Modulus
{
get { return modulus; }
}
public BigInteger Exponent
{
get { return exponent; }
}
public override bool Equals(
object obj)
{
RsaKeyParameters kp = obj as RsaKeyParameters;
if (kp == null)
{
return false;
}
return kp.IsPrivate == this.IsPrivate
&& kp.Modulus.Equals(this.modulus)
&& kp.Exponent.Equals(this.exponent);
}
public override int GetHashCode()
{
return modulus.GetHashCode() ^ exponent.GetHashCode() ^ IsPrivate.GetHashCode();
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,108 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
using System;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Math;
namespace Org.BouncyCastle.Crypto.Parameters
{
public class RsaPrivateCrtKeyParameters
: RsaKeyParameters
{
private readonly BigInteger e, p, q, dP, dQ, qInv;
public RsaPrivateCrtKeyParameters(
BigInteger modulus,
BigInteger publicExponent,
BigInteger privateExponent,
BigInteger p,
BigInteger q,
BigInteger dP,
BigInteger dQ,
BigInteger qInv)
: base(true, modulus, privateExponent)
{
ValidateValue(publicExponent, "publicExponent", "exponent");
ValidateValue(p, "p", "P value");
ValidateValue(q, "q", "Q value");
ValidateValue(dP, "dP", "DP value");
ValidateValue(dQ, "dQ", "DQ value");
ValidateValue(qInv, "qInv", "InverseQ value");
this.e = publicExponent;
this.p = p;
this.q = q;
this.dP = dP;
this.dQ = dQ;
this.qInv = qInv;
}
public BigInteger PublicExponent
{
get { return e; }
}
public BigInteger P
{
get { return p; }
}
public BigInteger Q
{
get { return q; }
}
public BigInteger DP
{
get { return dP; }
}
public BigInteger DQ
{
get { return dQ; }
}
public BigInteger QInv
{
get { return qInv; }
}
public override bool Equals(
object obj)
{
if (obj == this)
return true;
RsaPrivateCrtKeyParameters kp = obj as RsaPrivateCrtKeyParameters;
if (kp == null)
return false;
return kp.DP.Equals(dP)
&& kp.DQ.Equals(dQ)
&& kp.Exponent.Equals(this.Exponent)
&& kp.Modulus.Equals(this.Modulus)
&& kp.P.Equals(p)
&& kp.Q.Equals(q)
&& kp.PublicExponent.Equals(e)
&& kp.QInv.Equals(qInv);
}
public override int GetHashCode()
{
return DP.GetHashCode() ^ DQ.GetHashCode() ^ Exponent.GetHashCode() ^ Modulus.GetHashCode()
^ P.GetHashCode() ^ Q.GetHashCode() ^ PublicExponent.GetHashCode() ^ QInv.GetHashCode();
}
private static void ValidateValue(BigInteger x, string name, string desc)
{
if (x == null)
throw new ArgumentNullException(name);
if (x.SignValue <= 0)
throw new ArgumentException("Not a valid RSA " + desc, name);
}
}
}
#endif

View File

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