up
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* a holding class for public/private parameter pairs.
|
||||
*/
|
||||
public class AsymmetricCipherKeyPair
|
||||
{
|
||||
private readonly AsymmetricKeyParameter publicParameter;
|
||||
private readonly AsymmetricKeyParameter privateParameter;
|
||||
|
||||
/**
|
||||
* basic constructor.
|
||||
*
|
||||
* @param publicParam a public key parameters object.
|
||||
* @param privateParam the corresponding private key parameters.
|
||||
*/
|
||||
public AsymmetricCipherKeyPair(
|
||||
AsymmetricKeyParameter publicParameter,
|
||||
AsymmetricKeyParameter privateParameter)
|
||||
{
|
||||
if (publicParameter.IsPrivate)
|
||||
throw new ArgumentException("Expected a public key", "publicParameter");
|
||||
if (!privateParameter.IsPrivate)
|
||||
throw new ArgumentException("Expected a private key", "privateParameter");
|
||||
|
||||
this.publicParameter = publicParameter;
|
||||
this.privateParameter = privateParameter;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the public key parameters.
|
||||
*
|
||||
* @return the public key parameters.
|
||||
*/
|
||||
public AsymmetricKeyParameter Public
|
||||
{
|
||||
get { return publicParameter; }
|
||||
}
|
||||
|
||||
/**
|
||||
* return the private key parameters.
|
||||
*
|
||||
* @return the private key parameters.
|
||||
*/
|
||||
public AsymmetricKeyParameter Private
|
||||
{
|
||||
get { return privateParameter; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b79e33e997bbe42789e76b2b111a3b2d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Crypto;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
public abstract class AsymmetricKeyParameter
|
||||
: ICipherParameters
|
||||
{
|
||||
private readonly bool privateKey;
|
||||
|
||||
protected AsymmetricKeyParameter(
|
||||
bool privateKey)
|
||||
{
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public bool IsPrivate
|
||||
{
|
||||
get { return privateKey; }
|
||||
}
|
||||
|
||||
public override bool Equals(
|
||||
object obj)
|
||||
{
|
||||
AsymmetricKeyParameter other = obj as AsymmetricKeyParameter;
|
||||
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return Equals(other);
|
||||
}
|
||||
|
||||
protected bool Equals(
|
||||
AsymmetricKeyParameter other)
|
||||
{
|
||||
return privateKey == other.privateKey;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return privateKey.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45375edf37e3b4f8c9a95fce3b0cdf98
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
251
Assets/BestHTTP/SecureProtocol/crypto/BufferedAeadBlockCipher.cs
Normal file
251
Assets/BestHTTP/SecureProtocol/crypto/BufferedAeadBlockCipher.cs
Normal file
@@ -0,0 +1,251 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Crypto.Modes;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* The AEAD block ciphers already handle buffering internally, so this class
|
||||
* just takes care of implementing IBufferedCipher methods.
|
||||
*/
|
||||
public class BufferedAeadBlockCipher
|
||||
: BufferedCipherBase
|
||||
{
|
||||
private readonly IAeadBlockCipher cipher;
|
||||
|
||||
public BufferedAeadBlockCipher(
|
||||
IAeadBlockCipher cipher)
|
||||
{
|
||||
if (cipher == null)
|
||||
throw new ArgumentNullException("cipher");
|
||||
|
||||
this.cipher = cipher;
|
||||
}
|
||||
|
||||
public override string AlgorithmName
|
||||
{
|
||||
get { return cipher.AlgorithmName; }
|
||||
}
|
||||
|
||||
/**
|
||||
* initialise the cipher.
|
||||
*
|
||||
* @param forEncryption if true the cipher is initialised for
|
||||
* encryption, if false for decryption.
|
||||
* @param param the key and other data required by the cipher.
|
||||
* @exception ArgumentException if the parameters argument is
|
||||
* inappropriate.
|
||||
*/
|
||||
public override void Init(
|
||||
bool forEncryption,
|
||||
ICipherParameters parameters)
|
||||
{
|
||||
if (parameters is ParametersWithRandom)
|
||||
{
|
||||
parameters = ((ParametersWithRandom) parameters).Parameters;
|
||||
}
|
||||
|
||||
cipher.Init(forEncryption, parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* return the blocksize for the underlying cipher.
|
||||
*
|
||||
* @return the blocksize for the underlying cipher.
|
||||
*/
|
||||
public override int GetBlockSize()
|
||||
{
|
||||
return cipher.GetBlockSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* return the size of the output buffer required for an update
|
||||
* an input of len bytes.
|
||||
*
|
||||
* @param len the length of the input.
|
||||
* @return the space required to accommodate a call to update
|
||||
* with len bytes of input.
|
||||
*/
|
||||
public override int GetUpdateOutputSize(
|
||||
int length)
|
||||
{
|
||||
return cipher.GetUpdateOutputSize(length);
|
||||
}
|
||||
|
||||
/**
|
||||
* return the size of the output buffer required for an update plus a
|
||||
* doFinal with an input of len bytes.
|
||||
*
|
||||
* @param len the length of the input.
|
||||
* @return the space required to accommodate a call to update and doFinal
|
||||
* with len bytes of input.
|
||||
*/
|
||||
public override int GetOutputSize(
|
||||
int length)
|
||||
{
|
||||
return cipher.GetOutputSize(length);
|
||||
}
|
||||
|
||||
/**
|
||||
* process a single byte, producing an output block if necessary.
|
||||
*
|
||||
* @param in the input byte.
|
||||
* @param out the space for any output that might be produced.
|
||||
* @param outOff the offset from which the output will be copied.
|
||||
* @return the number of output bytes copied to out.
|
||||
* @exception DataLengthException if there isn't enough space in out.
|
||||
* @exception InvalidOperationException if the cipher isn't initialised.
|
||||
*/
|
||||
public override int ProcessByte(
|
||||
byte input,
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
return cipher.ProcessByte(input, output, outOff);
|
||||
}
|
||||
|
||||
public override byte[] ProcessByte(
|
||||
byte input)
|
||||
{
|
||||
int outLength = GetUpdateOutputSize(1);
|
||||
|
||||
byte[] outBytes = outLength > 0 ? new byte[outLength] : null;
|
||||
|
||||
int pos = ProcessByte(input, outBytes, 0);
|
||||
|
||||
if (outLength > 0 && pos < outLength)
|
||||
{
|
||||
byte[] tmp = new byte[pos];
|
||||
Array.Copy(outBytes, 0, tmp, 0, pos);
|
||||
outBytes = tmp;
|
||||
}
|
||||
|
||||
return outBytes;
|
||||
}
|
||||
|
||||
public override byte[] ProcessBytes(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length)
|
||||
{
|
||||
if (input == null)
|
||||
throw new ArgumentNullException("input");
|
||||
if (length < 1)
|
||||
return null;
|
||||
|
||||
int outLength = GetUpdateOutputSize(length);
|
||||
|
||||
byte[] outBytes = outLength > 0 ? new byte[outLength] : null;
|
||||
|
||||
int pos = ProcessBytes(input, inOff, length, outBytes, 0);
|
||||
|
||||
if (outLength > 0 && pos < outLength)
|
||||
{
|
||||
byte[] tmp = new byte[pos];
|
||||
Array.Copy(outBytes, 0, tmp, 0, pos);
|
||||
outBytes = tmp;
|
||||
}
|
||||
|
||||
return outBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* process an array of bytes, producing output if necessary.
|
||||
*
|
||||
* @param in the input byte array.
|
||||
* @param inOff the offset at which the input data starts.
|
||||
* @param len the number of bytes to be copied out of the input array.
|
||||
* @param out the space for any output that might be produced.
|
||||
* @param outOff the offset from which the output will be copied.
|
||||
* @return the number of output bytes copied to out.
|
||||
* @exception DataLengthException if there isn't enough space in out.
|
||||
* @exception InvalidOperationException if the cipher isn't initialised.
|
||||
*/
|
||||
public override int ProcessBytes(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length,
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
return cipher.ProcessBytes(input, inOff, length, output, outOff);
|
||||
}
|
||||
|
||||
public override byte[] DoFinal()
|
||||
{
|
||||
byte[] outBytes = new byte[GetOutputSize(0)];
|
||||
|
||||
int pos = DoFinal(outBytes, 0);
|
||||
|
||||
if (pos < outBytes.Length)
|
||||
{
|
||||
byte[] tmp = new byte[pos];
|
||||
Array.Copy(outBytes, 0, tmp, 0, pos);
|
||||
outBytes = tmp;
|
||||
}
|
||||
|
||||
return outBytes;
|
||||
}
|
||||
|
||||
public override byte[] DoFinal(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int inLen)
|
||||
{
|
||||
if (input == null)
|
||||
throw new ArgumentNullException("input");
|
||||
|
||||
byte[] outBytes = new byte[GetOutputSize(inLen)];
|
||||
|
||||
int pos = (inLen > 0)
|
||||
? ProcessBytes(input, inOff, inLen, outBytes, 0)
|
||||
: 0;
|
||||
|
||||
pos += DoFinal(outBytes, pos);
|
||||
|
||||
if (pos < outBytes.Length)
|
||||
{
|
||||
byte[] tmp = new byte[pos];
|
||||
Array.Copy(outBytes, 0, tmp, 0, pos);
|
||||
outBytes = tmp;
|
||||
}
|
||||
|
||||
return outBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the last block in the buffer.
|
||||
*
|
||||
* @param out the array the block currently being held is copied into.
|
||||
* @param outOff the offset at which the copying starts.
|
||||
* @return the number of output bytes copied to out.
|
||||
* @exception DataLengthException if there is insufficient space in out for
|
||||
* the output, or the input is not block size aligned and should be.
|
||||
* @exception InvalidOperationException if the underlying cipher is not
|
||||
* initialised.
|
||||
* @exception InvalidCipherTextException if padding is expected and not found.
|
||||
* @exception DataLengthException if the input is not block size
|
||||
* aligned.
|
||||
*/
|
||||
public override int DoFinal(
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
return cipher.DoFinal(output, outOff);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the buffer and cipher. After resetting the object is in the same
|
||||
* state as it was after the last init (if there was one).
|
||||
*/
|
||||
public override void Reset()
|
||||
{
|
||||
cipher.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aed61099e01624eb0967feb7b1575dac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,156 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
using Org.BouncyCastle.Crypto.Engines;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* a buffer wrapper for an asymmetric block cipher, allowing input
|
||||
* to be accumulated in a piecemeal fashion until final processing.
|
||||
*/
|
||||
public class BufferedAsymmetricBlockCipher
|
||||
: BufferedCipherBase
|
||||
{
|
||||
private readonly IAsymmetricBlockCipher cipher;
|
||||
|
||||
private byte[] buffer;
|
||||
private int bufOff;
|
||||
|
||||
/**
|
||||
* base constructor.
|
||||
*
|
||||
* @param cipher the cipher this buffering object wraps.
|
||||
*/
|
||||
public BufferedAsymmetricBlockCipher(
|
||||
IAsymmetricBlockCipher cipher)
|
||||
{
|
||||
this.cipher = cipher;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the amount of data sitting in the buffer.
|
||||
*
|
||||
* @return the amount of data sitting in the buffer.
|
||||
*/
|
||||
internal int GetBufferPosition()
|
||||
{
|
||||
return bufOff;
|
||||
}
|
||||
|
||||
public override string AlgorithmName
|
||||
{
|
||||
get { return cipher.AlgorithmName; }
|
||||
}
|
||||
|
||||
public override int GetBlockSize()
|
||||
{
|
||||
return cipher.GetInputBlockSize();
|
||||
}
|
||||
|
||||
public override int GetOutputSize(
|
||||
int length)
|
||||
{
|
||||
return cipher.GetOutputBlockSize();
|
||||
}
|
||||
|
||||
public override int GetUpdateOutputSize(
|
||||
int length)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* initialise the buffer and the underlying cipher.
|
||||
*
|
||||
* @param forEncryption if true the cipher is initialised for
|
||||
* encryption, if false for decryption.
|
||||
* @param param the key and other data required by the cipher.
|
||||
*/
|
||||
public override void Init(
|
||||
bool forEncryption,
|
||||
ICipherParameters parameters)
|
||||
{
|
||||
Reset();
|
||||
|
||||
cipher.Init(forEncryption, parameters);
|
||||
|
||||
//
|
||||
// we allow for an extra byte where people are using their own padding
|
||||
// mechanisms on a raw cipher.
|
||||
//
|
||||
this.buffer = new byte[cipher.GetInputBlockSize() + (forEncryption ? 1 : 0)];
|
||||
this.bufOff = 0;
|
||||
}
|
||||
|
||||
public override byte[] ProcessByte(
|
||||
byte input)
|
||||
{
|
||||
if (bufOff >= buffer.Length)
|
||||
throw new DataLengthException("attempt to process message to long for cipher");
|
||||
|
||||
buffer[bufOff++] = input;
|
||||
return null;
|
||||
}
|
||||
|
||||
public override byte[] ProcessBytes(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length)
|
||||
{
|
||||
if (length < 1)
|
||||
return null;
|
||||
|
||||
if (input == null)
|
||||
throw new ArgumentNullException("input");
|
||||
if (bufOff + length > buffer.Length)
|
||||
throw new DataLengthException("attempt to process message to long for cipher");
|
||||
|
||||
Array.Copy(input, inOff, buffer, bufOff, length);
|
||||
bufOff += length;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* process the contents of the buffer using the underlying
|
||||
* cipher.
|
||||
*
|
||||
* @return the result of the encryption/decryption process on the
|
||||
* buffer.
|
||||
* @exception InvalidCipherTextException if we are given a garbage block.
|
||||
*/
|
||||
public override byte[] DoFinal()
|
||||
{
|
||||
byte[] outBytes = bufOff > 0
|
||||
? cipher.ProcessBlock(buffer, 0, bufOff)
|
||||
: EmptyBuffer;
|
||||
|
||||
Reset();
|
||||
|
||||
return outBytes;
|
||||
}
|
||||
|
||||
public override byte[] DoFinal(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length)
|
||||
{
|
||||
ProcessBytes(input, inOff, length);
|
||||
return DoFinal();
|
||||
}
|
||||
|
||||
/// <summary>Reset the buffer</summary>
|
||||
public override void Reset()
|
||||
{
|
||||
if (buffer != null)
|
||||
{
|
||||
Array.Clear(buffer, 0, buffer.Length);
|
||||
bufOff = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d31ba316b39340009031757a6d63a37
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
371
Assets/BestHTTP/SecureProtocol/crypto/BufferedBlockCipher.cs
Normal file
371
Assets/BestHTTP/SecureProtocol/crypto/BufferedBlockCipher.cs
Normal file
@@ -0,0 +1,371 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* A wrapper class that allows block ciphers to be used to process data in
|
||||
* a piecemeal fashion. The BufferedBlockCipher outputs a block only when the
|
||||
* buffer is full and more data is being added, or on a doFinal.
|
||||
* <p>
|
||||
* Note: in the case where the underlying cipher is either a CFB cipher or an
|
||||
* OFB one the last block may not be a multiple of the block size.
|
||||
* </p>
|
||||
*/
|
||||
public class BufferedBlockCipher
|
||||
: BufferedCipherBase
|
||||
{
|
||||
internal byte[] buf;
|
||||
internal int bufOff;
|
||||
internal bool forEncryption;
|
||||
internal IBlockCipher cipher;
|
||||
|
||||
/**
|
||||
* constructor for subclasses
|
||||
*/
|
||||
protected BufferedBlockCipher()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a buffered block cipher without padding.
|
||||
*
|
||||
* @param cipher the underlying block cipher this buffering object wraps.
|
||||
* false otherwise.
|
||||
*/
|
||||
public BufferedBlockCipher(
|
||||
IBlockCipher cipher)
|
||||
{
|
||||
if (cipher == null)
|
||||
throw new ArgumentNullException("cipher");
|
||||
|
||||
this.cipher = cipher;
|
||||
buf = new byte[cipher.GetBlockSize()];
|
||||
bufOff = 0;
|
||||
}
|
||||
|
||||
public override string AlgorithmName
|
||||
{
|
||||
get { return cipher.AlgorithmName; }
|
||||
}
|
||||
|
||||
/**
|
||||
* initialise the cipher.
|
||||
*
|
||||
* @param forEncryption if true the cipher is initialised for
|
||||
* encryption, if false for decryption.
|
||||
* @param param the key and other data required by the cipher.
|
||||
* @exception ArgumentException if the parameters argument is
|
||||
* inappropriate.
|
||||
*/
|
||||
// Note: This doubles as the Init in the event that this cipher is being used as an IWrapper
|
||||
public override void Init(
|
||||
bool forEncryption,
|
||||
ICipherParameters parameters)
|
||||
{
|
||||
this.forEncryption = forEncryption;
|
||||
|
||||
ParametersWithRandom pwr = parameters as ParametersWithRandom;
|
||||
if (pwr != null)
|
||||
parameters = pwr.Parameters;
|
||||
|
||||
Reset();
|
||||
|
||||
cipher.Init(forEncryption, parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* return the blocksize for the underlying cipher.
|
||||
*
|
||||
* @return the blocksize for the underlying cipher.
|
||||
*/
|
||||
public override int GetBlockSize()
|
||||
{
|
||||
return cipher.GetBlockSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* return the size of the output buffer required for an update
|
||||
* an input of len bytes.
|
||||
*
|
||||
* @param len the length of the input.
|
||||
* @return the space required to accommodate a call to update
|
||||
* with len bytes of input.
|
||||
*/
|
||||
public override int GetUpdateOutputSize(
|
||||
int length)
|
||||
{
|
||||
int total = length + bufOff;
|
||||
int leftOver = total % buf.Length;
|
||||
return total - leftOver;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the size of the output buffer required for an update plus a
|
||||
* doFinal with an input of len bytes.
|
||||
*
|
||||
* @param len the length of the input.
|
||||
* @return the space required to accommodate a call to update and doFinal
|
||||
* with len bytes of input.
|
||||
*/
|
||||
public override int GetOutputSize(
|
||||
int length)
|
||||
{
|
||||
// Note: Can assume IsPartialBlockOkay is true for purposes of this calculation
|
||||
return length + bufOff;
|
||||
}
|
||||
|
||||
/**
|
||||
* process a single byte, producing an output block if necessary.
|
||||
*
|
||||
* @param in the input byte.
|
||||
* @param out the space for any output that might be produced.
|
||||
* @param outOff the offset from which the output will be copied.
|
||||
* @return the number of output bytes copied to out.
|
||||
* @exception DataLengthException if there isn't enough space in out.
|
||||
* @exception InvalidOperationException if the cipher isn't initialised.
|
||||
*/
|
||||
public override int ProcessByte(
|
||||
byte input,
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
buf[bufOff++] = input;
|
||||
|
||||
if (bufOff == buf.Length)
|
||||
{
|
||||
if ((outOff + buf.Length) > output.Length)
|
||||
throw new DataLengthException("output buffer too short");
|
||||
|
||||
bufOff = 0;
|
||||
return cipher.ProcessBlock(buf, 0, output, outOff);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override byte[] ProcessByte(
|
||||
byte input)
|
||||
{
|
||||
int outLength = GetUpdateOutputSize(1);
|
||||
|
||||
byte[] outBytes = outLength > 0 ? new byte[outLength] : null;
|
||||
|
||||
int pos = ProcessByte(input, outBytes, 0);
|
||||
|
||||
if (outLength > 0 && pos < outLength)
|
||||
{
|
||||
byte[] tmp = new byte[pos];
|
||||
Array.Copy(outBytes, 0, tmp, 0, pos);
|
||||
outBytes = tmp;
|
||||
}
|
||||
|
||||
return outBytes;
|
||||
}
|
||||
|
||||
public override byte[] ProcessBytes(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length)
|
||||
{
|
||||
if (input == null)
|
||||
throw new ArgumentNullException("input");
|
||||
if (length < 1)
|
||||
return null;
|
||||
|
||||
int outLength = GetUpdateOutputSize(length);
|
||||
|
||||
byte[] outBytes = outLength > 0 ? new byte[outLength] : null;
|
||||
|
||||
int pos = ProcessBytes(input, inOff, length, outBytes, 0);
|
||||
|
||||
if (outLength > 0 && pos < outLength)
|
||||
{
|
||||
byte[] tmp = new byte[pos];
|
||||
Array.Copy(outBytes, 0, tmp, 0, pos);
|
||||
outBytes = tmp;
|
||||
}
|
||||
|
||||
return outBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* process an array of bytes, producing output if necessary.
|
||||
*
|
||||
* @param in the input byte array.
|
||||
* @param inOff the offset at which the input data starts.
|
||||
* @param len the number of bytes to be copied out of the input array.
|
||||
* @param out the space for any output that might be produced.
|
||||
* @param outOff the offset from which the output will be copied.
|
||||
* @return the number of output bytes copied to out.
|
||||
* @exception DataLengthException if there isn't enough space in out.
|
||||
* @exception InvalidOperationException if the cipher isn't initialised.
|
||||
*/
|
||||
public override int ProcessBytes(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length,
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
if (length < 1)
|
||||
{
|
||||
if (length < 0)
|
||||
throw new ArgumentException("Can't have a negative input length!");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int blockSize = GetBlockSize();
|
||||
int outLength = GetUpdateOutputSize(length);
|
||||
|
||||
if (outLength > 0)
|
||||
{
|
||||
Check.OutputLength(output, outOff, outLength, "output buffer too short");
|
||||
}
|
||||
|
||||
int resultLen = 0;
|
||||
int gapLen = buf.Length - bufOff;
|
||||
if (length > gapLen)
|
||||
{
|
||||
Array.Copy(input, inOff, buf, bufOff, gapLen);
|
||||
resultLen += cipher.ProcessBlock(buf, 0, output, outOff);
|
||||
bufOff = 0;
|
||||
length -= gapLen;
|
||||
inOff += gapLen;
|
||||
while (length > buf.Length)
|
||||
{
|
||||
resultLen += cipher.ProcessBlock(input, inOff, output, outOff + resultLen);
|
||||
length -= blockSize;
|
||||
inOff += blockSize;
|
||||
}
|
||||
}
|
||||
Array.Copy(input, inOff, buf, bufOff, length);
|
||||
bufOff += length;
|
||||
if (bufOff == buf.Length)
|
||||
{
|
||||
resultLen += cipher.ProcessBlock(buf, 0, output, outOff + resultLen);
|
||||
bufOff = 0;
|
||||
}
|
||||
return resultLen;
|
||||
}
|
||||
|
||||
public override byte[] DoFinal()
|
||||
{
|
||||
byte[] outBytes = EmptyBuffer;
|
||||
|
||||
int length = GetOutputSize(0);
|
||||
if (length > 0)
|
||||
{
|
||||
outBytes = new byte[length];
|
||||
|
||||
int pos = DoFinal(outBytes, 0);
|
||||
if (pos < outBytes.Length)
|
||||
{
|
||||
byte[] tmp = new byte[pos];
|
||||
Array.Copy(outBytes, 0, tmp, 0, pos);
|
||||
outBytes = tmp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
return outBytes;
|
||||
}
|
||||
|
||||
public override byte[] DoFinal(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int inLen)
|
||||
{
|
||||
if (input == null)
|
||||
throw new ArgumentNullException("input");
|
||||
|
||||
int length = GetOutputSize(inLen);
|
||||
|
||||
byte[] outBytes = EmptyBuffer;
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
outBytes = new byte[length];
|
||||
|
||||
int pos = (inLen > 0)
|
||||
? ProcessBytes(input, inOff, inLen, outBytes, 0)
|
||||
: 0;
|
||||
|
||||
pos += DoFinal(outBytes, pos);
|
||||
|
||||
if (pos < outBytes.Length)
|
||||
{
|
||||
byte[] tmp = new byte[pos];
|
||||
Array.Copy(outBytes, 0, tmp, 0, pos);
|
||||
outBytes = tmp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
return outBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the last block in the buffer.
|
||||
*
|
||||
* @param out the array the block currently being held is copied into.
|
||||
* @param outOff the offset at which the copying starts.
|
||||
* @return the number of output bytes copied to out.
|
||||
* @exception DataLengthException if there is insufficient space in out for
|
||||
* the output, or the input is not block size aligned and should be.
|
||||
* @exception InvalidOperationException if the underlying cipher is not
|
||||
* initialised.
|
||||
* @exception InvalidCipherTextException if padding is expected and not found.
|
||||
* @exception DataLengthException if the input is not block size
|
||||
* aligned.
|
||||
*/
|
||||
public override int DoFinal(
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (bufOff != 0)
|
||||
{
|
||||
Check.DataLength(!cipher.IsPartialBlockOkay, "data not block size aligned");
|
||||
Check.OutputLength(output, outOff, bufOff, "output buffer too short for DoFinal()");
|
||||
|
||||
// NB: Can't copy directly, or we may write too much output
|
||||
cipher.ProcessBlock(buf, 0, buf, 0);
|
||||
Array.Copy(buf, 0, output, outOff, bufOff);
|
||||
}
|
||||
|
||||
return bufOff;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the buffer and cipher. After resetting the object is in the same
|
||||
* state as it was after the last init (if there was one).
|
||||
*/
|
||||
public override void Reset()
|
||||
{
|
||||
Array.Clear(buf, 0, buf.Length);
|
||||
bufOff = 0;
|
||||
|
||||
cipher.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 272ec6cb681fd4d3399db5635c769c52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
117
Assets/BestHTTP/SecureProtocol/crypto/BufferedCipherBase.cs
Normal file
117
Assets/BestHTTP/SecureProtocol/crypto/BufferedCipherBase.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
public abstract class BufferedCipherBase
|
||||
: IBufferedCipher
|
||||
{
|
||||
protected static readonly byte[] EmptyBuffer = new byte[0];
|
||||
|
||||
public abstract string AlgorithmName { get; }
|
||||
|
||||
public abstract void Init(bool forEncryption, ICipherParameters parameters);
|
||||
|
||||
public abstract int GetBlockSize();
|
||||
|
||||
public abstract int GetOutputSize(int inputLen);
|
||||
public abstract int GetUpdateOutputSize(int inputLen);
|
||||
|
||||
public abstract byte[] ProcessByte(byte input);
|
||||
|
||||
public virtual int ProcessByte(
|
||||
byte input,
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
byte[] outBytes = ProcessByte(input);
|
||||
if (outBytes == null)
|
||||
return 0;
|
||||
if (outOff + outBytes.Length > output.Length)
|
||||
throw new DataLengthException("output buffer too short");
|
||||
outBytes.CopyTo(output, outOff);
|
||||
return outBytes.Length;
|
||||
}
|
||||
|
||||
public virtual byte[] ProcessBytes(
|
||||
byte[] input)
|
||||
{
|
||||
return ProcessBytes(input, 0, input.Length);
|
||||
}
|
||||
|
||||
public abstract byte[] ProcessBytes(byte[] input, int inOff, int length);
|
||||
|
||||
public virtual int ProcessBytes(
|
||||
byte[] input,
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
return ProcessBytes(input, 0, input.Length, output, outOff);
|
||||
}
|
||||
|
||||
public virtual int ProcessBytes(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length,
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
byte[] outBytes = ProcessBytes(input, inOff, length);
|
||||
if (outBytes == null)
|
||||
return 0;
|
||||
if (outOff + outBytes.Length > output.Length)
|
||||
throw new DataLengthException("output buffer too short");
|
||||
outBytes.CopyTo(output, outOff);
|
||||
return outBytes.Length;
|
||||
}
|
||||
|
||||
public abstract byte[] DoFinal();
|
||||
|
||||
public virtual byte[] DoFinal(
|
||||
byte[] input)
|
||||
{
|
||||
return DoFinal(input, 0, input.Length);
|
||||
}
|
||||
|
||||
public abstract byte[] DoFinal(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length);
|
||||
|
||||
public virtual int DoFinal(
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
byte[] outBytes = DoFinal();
|
||||
if (outOff + outBytes.Length > output.Length)
|
||||
throw new DataLengthException("output buffer too short");
|
||||
outBytes.CopyTo(output, outOff);
|
||||
return outBytes.Length;
|
||||
}
|
||||
|
||||
public virtual int DoFinal(
|
||||
byte[] input,
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
return DoFinal(input, 0, input.Length, output, outOff);
|
||||
}
|
||||
|
||||
public virtual int DoFinal(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length,
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
int len = ProcessBytes(input, inOff, length, output, outOff);
|
||||
len += DoFinal(output, outOff + len);
|
||||
return len;
|
||||
}
|
||||
|
||||
public abstract void Reset();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b96f12e0fe91453aa86fc6cc4d2cc8b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
117
Assets/BestHTTP/SecureProtocol/crypto/BufferedIesCipher.cs
Normal file
117
Assets/BestHTTP/SecureProtocol/crypto/BufferedIesCipher.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Org.BouncyCastle.Crypto.Engines;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
public class BufferedIesCipher
|
||||
: BufferedCipherBase
|
||||
{
|
||||
private readonly IesEngine engine;
|
||||
private bool forEncryption;
|
||||
private MemoryStream buffer = new MemoryStream();
|
||||
|
||||
public BufferedIesCipher(
|
||||
IesEngine engine)
|
||||
{
|
||||
if (engine == null)
|
||||
throw new ArgumentNullException("engine");
|
||||
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
public override string AlgorithmName
|
||||
{
|
||||
// TODO Create IESEngine.AlgorithmName
|
||||
get { return "IES"; }
|
||||
}
|
||||
|
||||
public override void Init(
|
||||
bool forEncryption,
|
||||
ICipherParameters parameters)
|
||||
{
|
||||
this.forEncryption = forEncryption;
|
||||
|
||||
// TODO
|
||||
throw Platform.CreateNotImplementedException("IES");
|
||||
}
|
||||
|
||||
public override int GetBlockSize()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override int GetOutputSize(
|
||||
int inputLen)
|
||||
{
|
||||
if (engine == null)
|
||||
throw new InvalidOperationException("cipher not initialised");
|
||||
|
||||
int baseLen = inputLen + (int) buffer.Length;
|
||||
return forEncryption
|
||||
? baseLen + 20
|
||||
: baseLen - 20;
|
||||
}
|
||||
|
||||
public override int GetUpdateOutputSize(
|
||||
int inputLen)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override byte[] ProcessByte(
|
||||
byte input)
|
||||
{
|
||||
buffer.WriteByte(input);
|
||||
return null;
|
||||
}
|
||||
|
||||
public override byte[] ProcessBytes(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length)
|
||||
{
|
||||
if (input == null)
|
||||
throw new ArgumentNullException("input");
|
||||
if (inOff < 0)
|
||||
throw new ArgumentException("inOff");
|
||||
if (length < 0)
|
||||
throw new ArgumentException("length");
|
||||
if (inOff + length > input.Length)
|
||||
throw new ArgumentException("invalid offset/length specified for input array");
|
||||
|
||||
buffer.Write(input, inOff, length);
|
||||
return null;
|
||||
}
|
||||
|
||||
public override byte[] DoFinal()
|
||||
{
|
||||
byte[] buf = buffer.ToArray();
|
||||
|
||||
Reset();
|
||||
|
||||
return engine.ProcessBlock(buf, 0, buf.Length);
|
||||
}
|
||||
|
||||
public override byte[] DoFinal(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length)
|
||||
{
|
||||
ProcessBytes(input, inOff, length);
|
||||
return DoFinal();
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
buffer.SetLength(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e4963d80933344c5a0e970dd3372391
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
135
Assets/BestHTTP/SecureProtocol/crypto/BufferedStreamCipher.cs
Normal file
135
Assets/BestHTTP/SecureProtocol/crypto/BufferedStreamCipher.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
public class BufferedStreamCipher
|
||||
: BufferedCipherBase
|
||||
{
|
||||
private readonly IStreamCipher cipher;
|
||||
|
||||
public BufferedStreamCipher(
|
||||
IStreamCipher cipher)
|
||||
{
|
||||
if (cipher == null)
|
||||
throw new ArgumentNullException("cipher");
|
||||
|
||||
this.cipher = cipher;
|
||||
}
|
||||
|
||||
public override string AlgorithmName
|
||||
{
|
||||
get { return cipher.AlgorithmName; }
|
||||
}
|
||||
|
||||
public override void Init(
|
||||
bool forEncryption,
|
||||
ICipherParameters parameters)
|
||||
{
|
||||
if (parameters is ParametersWithRandom)
|
||||
{
|
||||
parameters = ((ParametersWithRandom) parameters).Parameters;
|
||||
}
|
||||
|
||||
cipher.Init(forEncryption, parameters);
|
||||
}
|
||||
|
||||
public override int GetBlockSize()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override int GetOutputSize(
|
||||
int inputLen)
|
||||
{
|
||||
return inputLen;
|
||||
}
|
||||
|
||||
public override int GetUpdateOutputSize(
|
||||
int inputLen)
|
||||
{
|
||||
return inputLen;
|
||||
}
|
||||
|
||||
public override byte[] ProcessByte(
|
||||
byte input)
|
||||
{
|
||||
return new byte[]{ cipher.ReturnByte(input) };
|
||||
}
|
||||
|
||||
public override int ProcessByte(
|
||||
byte input,
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
if (outOff >= output.Length)
|
||||
throw new DataLengthException("output buffer too short");
|
||||
|
||||
output[outOff] = cipher.ReturnByte(input);
|
||||
return 1;
|
||||
}
|
||||
|
||||
public override byte[] ProcessBytes(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length)
|
||||
{
|
||||
if (length < 1)
|
||||
return null;
|
||||
|
||||
byte[] output = new byte[length];
|
||||
cipher.ProcessBytes(input, inOff, length, output, 0);
|
||||
return output;
|
||||
}
|
||||
|
||||
public override int ProcessBytes(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length,
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
if (length < 1)
|
||||
return 0;
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
cipher.ProcessBytes(input, inOff, length, output, outOff);
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
public override byte[] DoFinal()
|
||||
{
|
||||
Reset();
|
||||
|
||||
return EmptyBuffer;
|
||||
}
|
||||
|
||||
public override byte[] DoFinal(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length)
|
||||
{
|
||||
if (length < 1)
|
||||
return EmptyBuffer;
|
||||
|
||||
byte[] output = ProcessBytes(input, inOff, length);
|
||||
|
||||
Reset();
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
cipher.Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d539850b5d87a4216b46b7f557ca2585
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Assets/BestHTTP/SecureProtocol/crypto/Check.cs
Normal file
29
Assets/BestHTTP/SecureProtocol/crypto/Check.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
internal class Check
|
||||
{
|
||||
internal static void DataLength(bool condition, string msg)
|
||||
{
|
||||
if (condition)
|
||||
throw new DataLengthException(msg);
|
||||
}
|
||||
|
||||
internal static void DataLength(byte[] buf, int off, int len, string msg)
|
||||
{
|
||||
if (off + len > buf.Length)
|
||||
throw new DataLengthException(msg);
|
||||
}
|
||||
|
||||
internal static void OutputLength(byte[] buf, int off, int len, string msg)
|
||||
{
|
||||
if (off + len > buf.Length)
|
||||
throw new OutputLengthException(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/crypto/Check.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/crypto/Check.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2d146e000b54489fb42896172186fce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
87
Assets/BestHTTP/SecureProtocol/crypto/CipherKeyGenerator.cs
Normal file
87
Assets/BestHTTP/SecureProtocol/crypto/CipherKeyGenerator.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Security;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* The base class for symmetric, or secret, cipher key generators.
|
||||
*/
|
||||
public class CipherKeyGenerator
|
||||
{
|
||||
protected internal SecureRandom random;
|
||||
protected internal int strength;
|
||||
private bool uninitialised = true;
|
||||
private int defaultStrength;
|
||||
|
||||
public CipherKeyGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
internal CipherKeyGenerator(
|
||||
int defaultStrength)
|
||||
{
|
||||
if (defaultStrength < 1)
|
||||
throw new ArgumentException("strength must be a positive value", "defaultStrength");
|
||||
|
||||
this.defaultStrength = defaultStrength;
|
||||
}
|
||||
|
||||
public int DefaultStrength
|
||||
{
|
||||
get { return defaultStrength; }
|
||||
}
|
||||
|
||||
/**
|
||||
* initialise the key generator.
|
||||
*
|
||||
* @param param the parameters to be used for key generation
|
||||
*/
|
||||
public void Init(
|
||||
KeyGenerationParameters parameters)
|
||||
{
|
||||
if (parameters == null)
|
||||
throw new ArgumentNullException("parameters");
|
||||
|
||||
this.uninitialised = false;
|
||||
|
||||
engineInit(parameters);
|
||||
}
|
||||
|
||||
protected virtual void engineInit(
|
||||
KeyGenerationParameters parameters)
|
||||
{
|
||||
this.random = parameters.Random;
|
||||
this.strength = (parameters.Strength + 7) / 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a secret key.
|
||||
*
|
||||
* @return a byte array containing the key value.
|
||||
*/
|
||||
public byte[] GenerateKey()
|
||||
{
|
||||
if (uninitialised)
|
||||
{
|
||||
if (defaultStrength < 1)
|
||||
throw new InvalidOperationException("Generator has not been initialised");
|
||||
|
||||
uninitialised = false;
|
||||
|
||||
engineInit(new KeyGenerationParameters(new SecureRandom(), defaultStrength));
|
||||
}
|
||||
|
||||
return engineGenerateKey();
|
||||
}
|
||||
|
||||
protected virtual byte[] engineGenerateKey()
|
||||
{
|
||||
return SecureRandom.GetNextBytes(random, strength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b88c314dd4f14a86867e866db657e62
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/BestHTTP/SecureProtocol/crypto/CryptoException.cs
Normal file
32
Assets/BestHTTP/SecureProtocol/crypto/CryptoException.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class CryptoException
|
||||
: Exception
|
||||
{
|
||||
public CryptoException()
|
||||
{
|
||||
}
|
||||
|
||||
public CryptoException(
|
||||
string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public CryptoException(
|
||||
string message,
|
||||
Exception exception)
|
||||
: base(message, exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0547c1ace0e1741449c2c6b7489e7a3b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
46
Assets/BestHTTP/SecureProtocol/crypto/DataLengthException.cs
Normal file
46
Assets/BestHTTP/SecureProtocol/crypto/DataLengthException.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* this exception is thrown if a buffer that is meant to have output
|
||||
* copied into it turns out to be too short, or if we've been given
|
||||
* insufficient input. In general this exception will Get thrown rather
|
||||
* than an ArrayOutOfBounds exception.
|
||||
*/
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class DataLengthException
|
||||
: CryptoException
|
||||
{
|
||||
/**
|
||||
* base constructor.
|
||||
*/
|
||||
public DataLengthException()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* create a DataLengthException with the given message.
|
||||
*
|
||||
* @param message the message to be carried with the exception.
|
||||
*/
|
||||
public DataLengthException(
|
||||
string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public DataLengthException(
|
||||
string message,
|
||||
Exception exception)
|
||||
: base(message, exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ccc058d880034ff4b82a6b660478aa3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/// <remarks>Base interface for a public/private key block cipher.</remarks>
|
||||
public interface IAsymmetricBlockCipher
|
||||
{
|
||||
/// <summary>The name of the algorithm this cipher implements.</summary>
|
||||
string AlgorithmName { get; }
|
||||
|
||||
/// <summary>Initialise the cipher.</summary>
|
||||
/// <param name="forEncryption">Initialise for encryption if true, for decryption if false.</param>
|
||||
/// <param name="parameters">The key or other data required by the cipher.</param>
|
||||
void Init(bool forEncryption, ICipherParameters parameters);
|
||||
|
||||
/// <returns>The maximum size, in bytes, an input block may be.</returns>
|
||||
int GetInputBlockSize();
|
||||
|
||||
/// <returns>The maximum size, in bytes, an output block will be.</returns>
|
||||
int GetOutputBlockSize();
|
||||
|
||||
/// <summary>Process a block.</summary>
|
||||
/// <param name="inBuf">The input buffer.</param>
|
||||
/// <param name="inOff">The offset into <paramref>inBuf</paramref> that the input block begins.</param>
|
||||
/// <param name="inLen">The length of the input block.</param>
|
||||
/// <exception cref="InvalidCipherTextException">Input decrypts improperly.</exception>
|
||||
/// <exception cref="DataLengthException">Input is too large for the cipher.</exception>
|
||||
byte[] ProcessBlock(byte[] inBuf, int inOff, int inLen);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2b7527978eb2427a9cbe044816c8c69
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* interface that a public/private key pair generator should conform to.
|
||||
*/
|
||||
public interface IAsymmetricCipherKeyPairGenerator
|
||||
{
|
||||
/**
|
||||
* intialise the key pair generator.
|
||||
*
|
||||
* @param the parameters the key pair is to be initialised with.
|
||||
*/
|
||||
void Init(KeyGenerationParameters parameters);
|
||||
|
||||
/**
|
||||
* return an AsymmetricCipherKeyPair containing the Generated keys.
|
||||
*
|
||||
* @return an AsymmetricCipherKeyPair containing the Generated keys.
|
||||
*/
|
||||
AsymmetricCipherKeyPair GenerateKeyPair();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5aa0f88b143df4d6a9b2abe4d5fa2ac8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/BestHTTP/SecureProtocol/crypto/IBasicAgreement.cs
Normal file
33
Assets/BestHTTP/SecureProtocol/crypto/IBasicAgreement.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
using Org.BouncyCastle.Math;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* The basic interface that basic Diffie-Hellman implementations
|
||||
* conforms to.
|
||||
*/
|
||||
public interface IBasicAgreement
|
||||
{
|
||||
/**
|
||||
* initialise the agreement engine.
|
||||
*/
|
||||
void Init(ICipherParameters parameters);
|
||||
|
||||
/**
|
||||
* return the field size for the agreement algorithm in bytes.
|
||||
*/
|
||||
int GetFieldSize();
|
||||
|
||||
/**
|
||||
* given a public key from a given party calculate the next
|
||||
* message in the agreement sequence.
|
||||
*/
|
||||
BigInteger CalculateAgreement(ICipherParameters pubKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5435283dd8fc24e09acbe4153bfea458
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/BestHTTP/SecureProtocol/crypto/IBlockCipher.cs
Normal file
40
Assets/BestHTTP/SecureProtocol/crypto/IBlockCipher.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/// <remarks>Base interface for a symmetric key block cipher.</remarks>
|
||||
public interface IBlockCipher
|
||||
{
|
||||
/// <summary>The name of the algorithm this cipher implements.</summary>
|
||||
string AlgorithmName { get; }
|
||||
|
||||
/// <summary>Initialise the cipher.</summary>
|
||||
/// <param name="forEncryption">Initialise for encryption if true, for decryption if false.</param>
|
||||
/// <param name="parameters">The key or other data required by the cipher.</param>
|
||||
void Init(bool forEncryption, ICipherParameters parameters);
|
||||
|
||||
/// <returns>The block size for this cipher, in bytes.</returns>
|
||||
int GetBlockSize();
|
||||
|
||||
/// <summary>Indicates whether this cipher can handle partial blocks.</summary>
|
||||
bool IsPartialBlockOkay { get; }
|
||||
|
||||
/// <summary>Process a block.</summary>
|
||||
/// <param name="inBuf">The input buffer.</param>
|
||||
/// <param name="inOff">The offset into <paramref>inBuf</paramref> that the input block begins.</param>
|
||||
/// <param name="outBuf">The output buffer.</param>
|
||||
/// <param name="outOff">The offset into <paramref>outBuf</paramref> to write the output block.</param>
|
||||
/// <exception cref="DataLengthException">If input block is wrong size, or outBuf too small.</exception>
|
||||
/// <returns>The number of bytes processed and produced.</returns>
|
||||
int ProcessBlock(byte[] inBuf, int inOff, byte[] outBuf, int outOff);
|
||||
|
||||
/// <summary>
|
||||
/// Reset the cipher to the same state as it was after the last init (if there was one).
|
||||
/// </summary>
|
||||
void Reset();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/crypto/IBlockCipher.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/crypto/IBlockCipher.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acf906196e67b4ba9b57a2b1efa17c38
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
27
Assets/BestHTTP/SecureProtocol/crypto/IBlockResult.cs
Normal file
27
Assets/BestHTTP/SecureProtocol/crypto/IBlockResult.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/// <summary>
|
||||
/// Operators that reduce their input to a single block return an object
|
||||
/// of this type.
|
||||
/// </summary>
|
||||
public interface IBlockResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Return the final result of the operation.
|
||||
/// </summary>
|
||||
/// <returns>A block of bytes, representing the result of an operation.</returns>
|
||||
byte[] Collect();
|
||||
|
||||
/// <summary>
|
||||
/// Store the final result of the operation by copying it into the destination array.
|
||||
/// </summary>
|
||||
/// <returns>The number of bytes copied into destination.</returns>
|
||||
/// <param name="destination">The byte array to copy the result into.</param>
|
||||
/// <param name="offset">The offset into destination to start copying the result at.</param>
|
||||
int Collect(byte[] destination, int offset);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/crypto/IBlockResult.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/crypto/IBlockResult.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e97303ec65e049b18b54385bbf044d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
48
Assets/BestHTTP/SecureProtocol/crypto/IBufferedCipher.cs
Normal file
48
Assets/BestHTTP/SecureProtocol/crypto/IBufferedCipher.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/// <remarks>Block cipher engines are expected to conform to this interface.</remarks>
|
||||
public interface IBufferedCipher
|
||||
{
|
||||
/// <summary>The name of the algorithm this cipher implements.</summary>
|
||||
string AlgorithmName { get; }
|
||||
|
||||
/// <summary>Initialise the cipher.</summary>
|
||||
/// <param name="forEncryption">If true the cipher is initialised for encryption,
|
||||
/// if false for decryption.</param>
|
||||
/// <param name="parameters">The key and other data required by the cipher.</param>
|
||||
void Init(bool forEncryption, ICipherParameters parameters);
|
||||
|
||||
int GetBlockSize();
|
||||
|
||||
int GetOutputSize(int inputLen);
|
||||
|
||||
int GetUpdateOutputSize(int inputLen);
|
||||
|
||||
byte[] ProcessByte(byte input);
|
||||
int ProcessByte(byte input, byte[] output, int outOff);
|
||||
|
||||
byte[] ProcessBytes(byte[] input);
|
||||
byte[] ProcessBytes(byte[] input, int inOff, int length);
|
||||
int ProcessBytes(byte[] input, byte[] output, int outOff);
|
||||
int ProcessBytes(byte[] input, int inOff, int length, byte[] output, int outOff);
|
||||
|
||||
byte[] DoFinal();
|
||||
byte[] DoFinal(byte[] input);
|
||||
byte[] DoFinal(byte[] input, int inOff, int length);
|
||||
int DoFinal(byte[] output, int outOff);
|
||||
int DoFinal(byte[] input, byte[] output, int outOff);
|
||||
int DoFinal(byte[] input, int inOff, int length, byte[] output, int outOff);
|
||||
|
||||
/// <summary>
|
||||
/// Reset the cipher. After resetting the cipher is in the same state
|
||||
/// as it was after the last init (if there was one).
|
||||
/// </summary>
|
||||
void Reset();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb15c60d600e044bc88869b68a585f0f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
15
Assets/BestHTTP/SecureProtocol/crypto/ICipherParameters.cs
Normal file
15
Assets/BestHTTP/SecureProtocol/crypto/ICipherParameters.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* all parameter classes implement this.
|
||||
*/
|
||||
public interface ICipherParameters
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16a2bacc0ff8f4476bbff852ca7a23e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
44
Assets/BestHTTP/SecureProtocol/crypto/IDSA.cs
Normal file
44
Assets/BestHTTP/SecureProtocol/crypto/IDSA.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
using Org.BouncyCastle.Math;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* interface for classes implementing the Digital Signature Algorithm
|
||||
*/
|
||||
public interface IDsa
|
||||
{
|
||||
string AlgorithmName { get; }
|
||||
|
||||
/**
|
||||
* initialise the signer for signature generation or signature
|
||||
* verification.
|
||||
*
|
||||
* @param forSigning true if we are generating a signature, false
|
||||
* otherwise.
|
||||
* @param param key parameters for signature generation.
|
||||
*/
|
||||
void Init(bool forSigning, ICipherParameters parameters);
|
||||
|
||||
/**
|
||||
* sign the passed in message (usually the output of a hash function).
|
||||
*
|
||||
* @param message the message to be signed.
|
||||
* @return two big integers representing the r and s values respectively.
|
||||
*/
|
||||
BigInteger[] GenerateSignature(byte[] message);
|
||||
|
||||
/**
|
||||
* verify the message message against the signature values r and s.
|
||||
*
|
||||
* @param message the message that was supposed to have been signed.
|
||||
* @param r the r signature value.
|
||||
* @param s the s signature value.
|
||||
*/
|
||||
bool VerifySignature(byte[] message, BigInteger r, BigInteger s);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/crypto/IDSA.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/crypto/IDSA.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50f3d638be3ce40dba9a0c13b209635f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
28
Assets/BestHTTP/SecureProtocol/crypto/IDerivationFunction.cs
Normal file
28
Assets/BestHTTP/SecureProtocol/crypto/IDerivationFunction.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* base interface for general purpose byte derivation functions.
|
||||
*/
|
||||
public interface IDerivationFunction
|
||||
{
|
||||
void Init(IDerivationParameters parameters);
|
||||
|
||||
/**
|
||||
* return the message digest used as the basis for the function
|
||||
*/
|
||||
IDigest Digest
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
int GenerateBytes(byte[] output, int outOff, int length);
|
||||
//throws DataLengthException, ArgumentException;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 712f42e5803284874bb78d670f7c2fd3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* Parameters for key/byte stream derivation classes
|
||||
*/
|
||||
public interface IDerivationParameters
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa860beed2ce54bcdae8c2e96d51729b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
65
Assets/BestHTTP/SecureProtocol/crypto/IDigest.cs
Normal file
65
Assets/BestHTTP/SecureProtocol/crypto/IDigest.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* interface that a message digest conforms to.
|
||||
*/
|
||||
public interface IDigest
|
||||
{
|
||||
/**
|
||||
* return the algorithm name
|
||||
*
|
||||
* @return the algorithm name
|
||||
*/
|
||||
string AlgorithmName { get; }
|
||||
|
||||
/**
|
||||
* return the size, in bytes, of the digest produced by this message digest.
|
||||
*
|
||||
* @return the size, in bytes, of the digest produced by this message digest.
|
||||
*/
|
||||
int GetDigestSize();
|
||||
|
||||
/**
|
||||
* return the size, in bytes, of the internal buffer used by this digest.
|
||||
*
|
||||
* @return the size, in bytes, of the internal buffer used by this digest.
|
||||
*/
|
||||
int GetByteLength();
|
||||
|
||||
/**
|
||||
* update the message digest with a single byte.
|
||||
*
|
||||
* @param inByte the input byte to be entered.
|
||||
*/
|
||||
void Update(byte input);
|
||||
|
||||
/**
|
||||
* update the message digest with a block of bytes.
|
||||
*
|
||||
* @param input the byte array containing the data.
|
||||
* @param inOff the offset into the byte array where the data starts.
|
||||
* @param len the length of the data.
|
||||
*/
|
||||
void BlockUpdate(byte[] input, int inOff, int length);
|
||||
|
||||
/**
|
||||
* Close the digest, producing the final digest value. The doFinal
|
||||
* call leaves the digest reset.
|
||||
*
|
||||
* @param output the array the digest is to be copied into.
|
||||
* @param outOff the offset into the out array the digest is to start at.
|
||||
*/
|
||||
int DoFinal(byte[] output, int outOff);
|
||||
|
||||
/**
|
||||
* reset the digest back to it's initial state.
|
||||
*/
|
||||
void Reset();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/crypto/IDigest.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/crypto/IDigest.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2cfcaf13f69ce4d7990ea902621b5c70
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
73
Assets/BestHTTP/SecureProtocol/crypto/IMac.cs
Normal file
73
Assets/BestHTTP/SecureProtocol/crypto/IMac.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* The base interface for implementations of message authentication codes (MACs).
|
||||
*/
|
||||
public interface IMac
|
||||
{
|
||||
/**
|
||||
* Initialise the MAC.
|
||||
*
|
||||
* @param param the key and other data required by the MAC.
|
||||
* @exception ArgumentException if the parameters argument is
|
||||
* inappropriate.
|
||||
*/
|
||||
void Init(ICipherParameters parameters);
|
||||
|
||||
/**
|
||||
* Return the name of the algorithm the MAC implements.
|
||||
*
|
||||
* @return the name of the algorithm the MAC implements.
|
||||
*/
|
||||
string AlgorithmName { get; }
|
||||
|
||||
/**
|
||||
* Return the block size for this MAC (in bytes).
|
||||
*
|
||||
* @return the block size for this MAC in bytes.
|
||||
*/
|
||||
int GetMacSize();
|
||||
|
||||
/**
|
||||
* add a single byte to the mac for processing.
|
||||
*
|
||||
* @param in the byte to be processed.
|
||||
* @exception InvalidOperationException if the MAC is not initialised.
|
||||
*/
|
||||
void Update(byte input);
|
||||
|
||||
/**
|
||||
* @param in the array containing the input.
|
||||
* @param inOff the index in the array the data begins at.
|
||||
* @param len the length of the input starting at inOff.
|
||||
* @exception InvalidOperationException if the MAC is not initialised.
|
||||
* @exception DataLengthException if there isn't enough data in in.
|
||||
*/
|
||||
void BlockUpdate(byte[] input, int inOff, int len);
|
||||
|
||||
/**
|
||||
* Compute the final stage of the MAC writing the output to the out
|
||||
* parameter.
|
||||
* <p>
|
||||
* doFinal leaves the MAC in the same state it was after the last init.
|
||||
* </p>
|
||||
* @param out the array the MAC is to be output to.
|
||||
* @param outOff the offset into the out buffer the output is to start at.
|
||||
* @exception DataLengthException if there isn't enough space in out.
|
||||
* @exception InvalidOperationException if the MAC is not initialised.
|
||||
*/
|
||||
int DoFinal(byte[] output, int outOff);
|
||||
|
||||
/**
|
||||
* Reset the MAC. At the end of resetting the MAC should be in the
|
||||
* in the same state it was after the last init (if there was one).
|
||||
*/
|
||||
void Reset();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/crypto/IMac.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/crypto/IMac.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb6a35cf8f0a44fb7a751747e0229a9a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/BestHTTP/SecureProtocol/crypto/ISignatureFactory.cs
Normal file
24
Assets/BestHTTP/SecureProtocol/crypto/ISignatureFactory.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/// <summary>
|
||||
/// Base interface for operators that serve as stream-based signature calculators.
|
||||
/// </summary>
|
||||
public interface ISignatureFactory
|
||||
{
|
||||
/// <summary>The algorithm details object for this calculator.</summary>
|
||||
Object AlgorithmDetails { get ; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a stream calculator for this signature calculator. The stream
|
||||
/// calculator is used for the actual operation of entering the data to be signed
|
||||
/// and producing the signature block.
|
||||
/// </summary>
|
||||
/// <returns>A calculator producing an IBlockResult with a signature in it.</returns>
|
||||
IStreamCalculator CreateCalculator();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3cb7e0a693cbe4322a11bbdf93597245
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
54
Assets/BestHTTP/SecureProtocol/crypto/ISigner.cs
Normal file
54
Assets/BestHTTP/SecureProtocol/crypto/ISigner.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
public interface ISigner
|
||||
{
|
||||
/**
|
||||
* Return the name of the algorithm the signer implements.
|
||||
*
|
||||
* @return the name of the algorithm the signer implements.
|
||||
*/
|
||||
string AlgorithmName { get; }
|
||||
|
||||
/**
|
||||
* Initialise the signer for signing or verification.
|
||||
*
|
||||
* @param forSigning true if for signing, false otherwise
|
||||
* @param param necessary parameters.
|
||||
*/
|
||||
void Init(bool forSigning, ICipherParameters parameters);
|
||||
|
||||
/**
|
||||
* update the internal digest with the byte b
|
||||
*/
|
||||
void Update(byte input);
|
||||
|
||||
/**
|
||||
* update the internal digest with the byte array in
|
||||
*/
|
||||
void BlockUpdate(byte[] input, int inOff, int length);
|
||||
|
||||
/**
|
||||
* Generate a signature for the message we've been loaded with using
|
||||
* the key we were initialised with.
|
||||
*/
|
||||
byte[] GenerateSignature();
|
||||
/**
|
||||
* return true if the internal state represents the signature described
|
||||
* in the passed in array.
|
||||
*/
|
||||
bool VerifySignature(byte[] signature);
|
||||
|
||||
/**
|
||||
* reset the internal state
|
||||
*/
|
||||
void Reset();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/crypto/ISigner.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/crypto/ISigner.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28af3c60758404c83abd2617891322f6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/BestHTTP/SecureProtocol/crypto/ISignerWithRecovery.cs
Normal file
41
Assets/BestHTTP/SecureProtocol/crypto/ISignerWithRecovery.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* Signer with message recovery.
|
||||
*/
|
||||
public interface ISignerWithRecovery
|
||||
: ISigner
|
||||
{
|
||||
/**
|
||||
* Returns true if the signer has recovered the full message as
|
||||
* part of signature verification.
|
||||
*
|
||||
* @return true if full message recovered.
|
||||
*/
|
||||
bool HasFullMessage();
|
||||
|
||||
/**
|
||||
* Returns a reference to what message was recovered (if any).
|
||||
*
|
||||
* @return full/partial message, null if nothing.
|
||||
*/
|
||||
byte[] GetRecoveredMessage();
|
||||
|
||||
/**
|
||||
* Perform an update with the recovered message before adding any other data. This must
|
||||
* be the first update method called, and calling it will result in the signer assuming
|
||||
* that further calls to update will include message content past what is recoverable.
|
||||
*
|
||||
* @param signature the signature that we are in the process of verifying.
|
||||
* @throws IllegalStateException
|
||||
*/
|
||||
void UpdateWithRecoveredMessage(byte[] signature);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0077bd32776b34d059aacbffa89325e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/BestHTTP/SecureProtocol/crypto/IStreamCalculator.cs
Normal file
26
Assets/BestHTTP/SecureProtocol/crypto/IStreamCalculator.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/// <summary>
|
||||
/// Base interface for cryptographic operations such as Hashes, MACs, and Signatures which reduce a stream of data
|
||||
/// to a single value.
|
||||
/// </summary>
|
||||
public interface IStreamCalculator
|
||||
{
|
||||
/// <summary>Return a "sink" stream which only exists to update the implementing object.</summary>
|
||||
/// <returns>A stream to write to in order to update the implementing object.</returns>
|
||||
Stream Stream { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Return the result of processing the stream. This value is only available once the stream
|
||||
/// has been closed.
|
||||
/// </summary>
|
||||
/// <returns>The result of processing the stream.</returns>
|
||||
Object GetResult();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 307be6ac5d7fc4bfeb427ea8b4691f04
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
49
Assets/BestHTTP/SecureProtocol/crypto/IStreamCipher.cs
Normal file
49
Assets/BestHTTP/SecureProtocol/crypto/IStreamCipher.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/// <summary>The interface stream ciphers conform to.</summary>
|
||||
public interface IStreamCipher
|
||||
{
|
||||
/// <summary>The name of the algorithm this cipher implements.</summary>
|
||||
string AlgorithmName { get; }
|
||||
|
||||
/// <summary>Initialise the cipher.</summary>
|
||||
/// <param name="forEncryption">If true the cipher is initialised for encryption,
|
||||
/// if false for decryption.</param>
|
||||
/// <param name="parameters">The key and other data required by the cipher.</param>
|
||||
/// <exception cref="ArgumentException">
|
||||
/// If the parameters argument is inappropriate.
|
||||
/// </exception>
|
||||
void Init(bool forEncryption, ICipherParameters parameters);
|
||||
|
||||
/// <summary>encrypt/decrypt a single byte returning the result.</summary>
|
||||
/// <param name="input">the byte to be processed.</param>
|
||||
/// <returns>the result of processing the input byte.</returns>
|
||||
byte ReturnByte(byte input);
|
||||
|
||||
/// <summary>
|
||||
/// Process a block of bytes from <c>input</c> putting the result into <c>output</c>.
|
||||
/// </summary>
|
||||
/// <param name="input">The input byte array.</param>
|
||||
/// <param name="inOff">
|
||||
/// The offset into <c>input</c> where the data to be processed starts.
|
||||
/// </param>
|
||||
/// <param name="length">The number of bytes to be processed.</param>
|
||||
/// <param name="output">The output buffer the processed bytes go into.</param>
|
||||
/// <param name="outOff">
|
||||
/// The offset into <c>output</c> the processed data starts at.
|
||||
/// </param>
|
||||
/// <exception cref="DataLengthException">If the output buffer is too small.</exception>
|
||||
void ProcessBytes(byte[] input, int inOff, int length, byte[] output, int outOff);
|
||||
|
||||
/// <summary>
|
||||
/// Reset the cipher to the same state as it was after the last init (if there was one).
|
||||
/// </summary>
|
||||
void Reset();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/crypto/IStreamCipher.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/crypto/IStreamCipher.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e96ae3925f7294024bba341e1a5949b0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
28
Assets/BestHTTP/SecureProtocol/crypto/IVerifier.cs
Normal file
28
Assets/BestHTTP/SecureProtocol/crypto/IVerifier.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/// <summary>
|
||||
/// Operators that reduce their input to the validation of a signature produce this type.
|
||||
/// </summary>
|
||||
public interface IVerifier
|
||||
{
|
||||
/// <summary>
|
||||
/// Return true if the passed in data matches what is expected by the verification result.
|
||||
/// </summary>
|
||||
/// <param name="data">The bytes representing the signature.</param>
|
||||
/// <returns>true if the signature verifies, false otherwise.</returns>
|
||||
bool IsVerified(byte[] data);
|
||||
|
||||
/// <summary>
|
||||
/// Return true if the length bytes from off in the source array match the signature
|
||||
/// expected by the verification result.
|
||||
/// </summary>
|
||||
/// <param name="source">Byte array containing the signature.</param>
|
||||
/// <param name="off">The offset into the source array where the signature starts.</param>
|
||||
/// <param name="length">The number of bytes in source making up the signature.</param>
|
||||
/// <returns>true if the signature verifies, false otherwise.</returns>
|
||||
bool IsVerified(byte[] source, int off, int length);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/crypto/IVerifier.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/crypto/IVerifier.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff4d783f9c0fa42e29b0c281a649060a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/BestHTTP/SecureProtocol/crypto/IVerifierFactory.cs
Normal file
24
Assets/BestHTTP/SecureProtocol/crypto/IVerifierFactory.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/// <summary>
|
||||
/// Base interface for operators that serve as stream-based signature verifiers.
|
||||
/// </summary>
|
||||
public interface IVerifierFactory
|
||||
{
|
||||
/// <summary>The algorithm details object for this verifier.</summary>
|
||||
Object AlgorithmDetails { get ; }
|
||||
|
||||
/// <summary>
|
||||
/// Create a stream calculator for this verifier. The stream
|
||||
/// calculator is used for the actual operation of entering the data to be verified
|
||||
/// and producing a result which can be used to verify the original signature.
|
||||
/// </summary>
|
||||
/// <returns>A calculator producing an IVerifier which can verify the signature.</returns>
|
||||
IStreamCalculator CreateCalculator();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e3de14f453ada4f9fbfb525dfce2aab0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/// <summary>
|
||||
/// Base interface for a provider to support the dynamic creation of signature verifiers.
|
||||
/// </summary>
|
||||
public interface IVerifierFactoryProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// Return a signature verfier for signature algorithm described in the passed in algorithm details object.
|
||||
/// </summary>
|
||||
/// <param name="algorithmDetails">The details of the signature algorithm verification is required for.</param>
|
||||
/// <returns>A new signature verifier.</returns>
|
||||
IVerifierFactory CreateVerifierFactory (Object algorithmDetails);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c56be9496cb9c44a7a1b3f5b439028bb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
22
Assets/BestHTTP/SecureProtocol/crypto/IWrapper.cs
Normal file
22
Assets/BestHTTP/SecureProtocol/crypto/IWrapper.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Security;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
public interface IWrapper
|
||||
{
|
||||
/// <summary>The name of the algorithm this cipher implements.</summary>
|
||||
string AlgorithmName { get; }
|
||||
|
||||
void Init(bool forWrapping, ICipherParameters parameters);
|
||||
|
||||
byte[] Wrap(byte[] input, int inOff, int length);
|
||||
|
||||
byte[] Unwrap(byte[] input, int inOff, int length);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/crypto/IWrapper.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/crypto/IWrapper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a42e683ff50ec4c4195d2d52467e4094
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/BestHTTP/SecureProtocol/crypto/IXof.cs
Normal file
33
Assets/BestHTTP/SecureProtocol/crypto/IXof.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/// <remarks>
|
||||
/// With FIPS PUB 202 a new kind of message digest was announced which supported extendable output, or variable digest sizes.
|
||||
/// This interface provides the extra method required to support variable output on a digest implementation.
|
||||
/// </remarks>
|
||||
public interface IXof
|
||||
: IDigest
|
||||
{
|
||||
/// <summary>
|
||||
/// Output the results of the final calculation for this digest to outLen number of bytes.
|
||||
/// </summary>
|
||||
/// <param name="output">output array to write the output bytes to.</param>
|
||||
/// <param name="outOff">offset to start writing the bytes at.</param>
|
||||
/// <param name="outLen">the number of output bytes requested.</param>
|
||||
/// <returns>the number of bytes written</returns>
|
||||
int DoFinal(byte[] output, int outOff, int outLen);
|
||||
|
||||
/// <summary>
|
||||
/// Start outputting the results of the final calculation for this digest. Unlike DoFinal, this method
|
||||
/// will continue producing output until the Xof is explicitly reset, or signals otherwise.
|
||||
/// </summary>
|
||||
/// <param name="output">output array to write the output bytes to.</param>
|
||||
/// <param name="outOff">offset to start writing the bytes at.</param>
|
||||
/// <param name="outLen">the number of output bytes requested.</param>
|
||||
/// <returns>the number of bytes written</returns>
|
||||
int DoOutput(byte[] output, int outOff, int outLen);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/crypto/IXof.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/crypto/IXof.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 627760da2f0c3428da9fbcf5e530172b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,44 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* this exception is thrown whenever we find something we don't expect in a
|
||||
* message.
|
||||
*/
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class InvalidCipherTextException
|
||||
: CryptoException
|
||||
{
|
||||
/**
|
||||
* base constructor.
|
||||
*/
|
||||
public InvalidCipherTextException()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* create a InvalidCipherTextException with the given message.
|
||||
*
|
||||
* @param message the message to be carried with the exception.
|
||||
*/
|
||||
public InvalidCipherTextException(
|
||||
string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public InvalidCipherTextException(
|
||||
string message,
|
||||
Exception exception)
|
||||
: base(message, exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b15ab0ca5e5d74af1b0d105e5439ff98
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,59 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
using Org.BouncyCastle.Security;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* The base class for parameters to key generators.
|
||||
*/
|
||||
public class KeyGenerationParameters
|
||||
{
|
||||
private SecureRandom random;
|
||||
private int strength;
|
||||
|
||||
/**
|
||||
* initialise the generator with a source of randomness
|
||||
* and a strength (in bits).
|
||||
*
|
||||
* @param random the random byte source.
|
||||
* @param strength the size, in bits, of the keys we want to produce.
|
||||
*/
|
||||
public KeyGenerationParameters(
|
||||
SecureRandom random,
|
||||
int strength)
|
||||
{
|
||||
if (random == null)
|
||||
throw new ArgumentNullException("random");
|
||||
if (strength < 1)
|
||||
throw new ArgumentException("strength must be a positive value", "strength");
|
||||
|
||||
this.random = random;
|
||||
this.strength = strength;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the random source associated with this
|
||||
* generator.
|
||||
*
|
||||
* @return the generators random source.
|
||||
*/
|
||||
public SecureRandom Random
|
||||
{
|
||||
get { return random; }
|
||||
}
|
||||
|
||||
/**
|
||||
* return the bit strength for keys produced by this generator,
|
||||
*
|
||||
* @return the strength of the keys this generator produces (in bits).
|
||||
*/
|
||||
public int Strength
|
||||
{
|
||||
get { return strength; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8acdf68b4e3e940c1a612e8e592680f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,36 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/// <summary>
|
||||
/// This exception is thrown whenever a cipher requires a change of key, iv
|
||||
/// or similar after x amount of bytes enciphered
|
||||
/// </summary>
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class MaxBytesExceededException
|
||||
: CryptoException
|
||||
{
|
||||
public MaxBytesExceededException()
|
||||
{
|
||||
}
|
||||
|
||||
public MaxBytesExceededException(
|
||||
string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public MaxBytesExceededException(
|
||||
string message,
|
||||
Exception e)
|
||||
: base(message, e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d9ded660aaecb40f2845057082c1768b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,32 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
#if !(NETCF_1_0 || NETCF_2_0 || SILVERLIGHT || NETFX_CORE || PORTABLE)
|
||||
[Serializable]
|
||||
#endif
|
||||
public class OutputLengthException
|
||||
: DataLengthException
|
||||
{
|
||||
public OutputLengthException()
|
||||
{
|
||||
}
|
||||
|
||||
public OutputLengthException(
|
||||
string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public OutputLengthException(
|
||||
string message,
|
||||
Exception exception)
|
||||
: base(message, exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fad8b23f476804fe08ddeee3adae3377
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
206
Assets/BestHTTP/SecureProtocol/crypto/PbeParametersGenerator.cs
Normal file
206
Assets/BestHTTP/SecureProtocol/crypto/PbeParametersGenerator.cs
Normal file
@@ -0,0 +1,206 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto
|
||||
{
|
||||
/**
|
||||
* super class for all Password Based Encyrption (Pbe) parameter generator classes.
|
||||
*/
|
||||
public abstract class PbeParametersGenerator
|
||||
{
|
||||
protected byte[] mPassword;
|
||||
protected byte[] mSalt;
|
||||
protected int mIterationCount;
|
||||
|
||||
/**
|
||||
* base constructor.
|
||||
*/
|
||||
protected PbeParametersGenerator()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* initialise the Pbe generator.
|
||||
*
|
||||
* @param password the password converted into bytes (see below).
|
||||
* @param salt the salt to be mixed with the password.
|
||||
* @param iterationCount the number of iterations the "mixing" function
|
||||
* is to be applied for.
|
||||
*/
|
||||
public virtual void Init(
|
||||
byte[] password,
|
||||
byte[] salt,
|
||||
int iterationCount)
|
||||
{
|
||||
if (password == null)
|
||||
throw new ArgumentNullException("password");
|
||||
if (salt == null)
|
||||
throw new ArgumentNullException("salt");
|
||||
|
||||
this.mPassword = Arrays.Clone(password);
|
||||
this.mSalt = Arrays.Clone(salt);
|
||||
this.mIterationCount = iterationCount;
|
||||
}
|
||||
|
||||
public virtual byte[] Password
|
||||
{
|
||||
get { return Arrays.Clone(mPassword); }
|
||||
}
|
||||
|
||||
/**
|
||||
* return the password byte array.
|
||||
*
|
||||
* @return the password byte array.
|
||||
*/
|
||||
[Obsolete("Use 'Password' property")]
|
||||
public byte[] GetPassword()
|
||||
{
|
||||
return Password;
|
||||
}
|
||||
|
||||
public virtual byte[] Salt
|
||||
{
|
||||
get { return Arrays.Clone(mSalt); }
|
||||
}
|
||||
|
||||
/**
|
||||
* return the salt byte array.
|
||||
*
|
||||
* @return the salt byte array.
|
||||
*/
|
||||
[Obsolete("Use 'Salt' property")]
|
||||
public byte[] GetSalt()
|
||||
{
|
||||
return Salt;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the iteration count.
|
||||
*
|
||||
* @return the iteration count.
|
||||
*/
|
||||
public virtual int IterationCount
|
||||
{
|
||||
get { return mIterationCount; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate derived parameters for a key of length keySize.
|
||||
*
|
||||
* @param keySize the length, in bits, of the key required.
|
||||
* @return a parameters object representing a key.
|
||||
*/
|
||||
[Obsolete("Use version with 'algorithm' parameter")]
|
||||
public abstract ICipherParameters GenerateDerivedParameters(int keySize);
|
||||
public abstract ICipherParameters GenerateDerivedParameters(string algorithm, int keySize);
|
||||
|
||||
/**
|
||||
* Generate derived parameters for a key of length keySize, and
|
||||
* an initialisation vector (IV) of length ivSize.
|
||||
*
|
||||
* @param keySize the length, in bits, of the key required.
|
||||
* @param ivSize the length, in bits, of the iv required.
|
||||
* @return a parameters object representing a key and an IV.
|
||||
*/
|
||||
[Obsolete("Use version with 'algorithm' parameter")]
|
||||
public abstract ICipherParameters GenerateDerivedParameters(int keySize, int ivSize);
|
||||
public abstract ICipherParameters GenerateDerivedParameters(string algorithm, int keySize, int ivSize);
|
||||
|
||||
/**
|
||||
* Generate derived parameters for a key of length keySize, specifically
|
||||
* for use with a MAC.
|
||||
*
|
||||
* @param keySize the length, in bits, of the key required.
|
||||
* @return a parameters object representing a key.
|
||||
*/
|
||||
public abstract ICipherParameters GenerateDerivedMacParameters(int keySize);
|
||||
|
||||
/**
|
||||
* converts a password to a byte array according to the scheme in
|
||||
* Pkcs5 (ascii, no padding)
|
||||
*
|
||||
* @param password a character array representing the password.
|
||||
* @return a byte array representing the password.
|
||||
*/
|
||||
public static byte[] Pkcs5PasswordToBytes(
|
||||
char[] password)
|
||||
{
|
||||
if (password == null)
|
||||
return new byte[0];
|
||||
|
||||
return Strings.ToByteArray(password);
|
||||
}
|
||||
|
||||
[Obsolete("Use version taking 'char[]' instead")]
|
||||
public static byte[] Pkcs5PasswordToBytes(
|
||||
string password)
|
||||
{
|
||||
if (password == null)
|
||||
return new byte[0];
|
||||
|
||||
return Strings.ToByteArray(password);
|
||||
}
|
||||
|
||||
/**
|
||||
* converts a password to a byte array according to the scheme in
|
||||
* PKCS5 (UTF-8, no padding)
|
||||
*
|
||||
* @param password a character array representing the password.
|
||||
* @return a byte array representing the password.
|
||||
*/
|
||||
public static byte[] Pkcs5PasswordToUtf8Bytes(
|
||||
char[] password)
|
||||
{
|
||||
if (password == null)
|
||||
return new byte[0];
|
||||
|
||||
return Encoding.UTF8.GetBytes(password);
|
||||
}
|
||||
|
||||
[Obsolete("Use version taking 'char[]' instead")]
|
||||
public static byte[] Pkcs5PasswordToUtf8Bytes(
|
||||
string password)
|
||||
{
|
||||
if (password == null)
|
||||
return new byte[0];
|
||||
|
||||
return Encoding.UTF8.GetBytes(password);
|
||||
}
|
||||
|
||||
/**
|
||||
* converts a password to a byte array according to the scheme in
|
||||
* Pkcs12 (unicode, big endian, 2 zero pad bytes at the end).
|
||||
*
|
||||
* @param password a character array representing the password.
|
||||
* @return a byte array representing the password.
|
||||
*/
|
||||
public static byte[] Pkcs12PasswordToBytes(
|
||||
char[] password)
|
||||
{
|
||||
return Pkcs12PasswordToBytes(password, false);
|
||||
}
|
||||
|
||||
public static byte[] Pkcs12PasswordToBytes(
|
||||
char[] password,
|
||||
bool wrongPkcs12Zero)
|
||||
{
|
||||
if (password == null || password.Length < 1)
|
||||
{
|
||||
return new byte[wrongPkcs12Zero ? 2 : 0];
|
||||
}
|
||||
|
||||
// +1 for extra 2 pad bytes.
|
||||
byte[] bytes = new byte[(password.Length + 1) * 2];
|
||||
|
||||
Encoding.BigEndianUnicode.GetBytes(password, 0, password.Length, bytes, 0);
|
||||
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5172b65ed8f9f495fb501f72fd7dca73
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/BestHTTP/SecureProtocol/crypto/agreement.meta
Normal file
8
Assets/BestHTTP/SecureProtocol/crypto/agreement.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8b2a07d8579340a3b20f4f3cd48d7f4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
using Org.BouncyCastle.Math;
|
||||
using Org.BouncyCastle.Security;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto.Agreement
|
||||
{
|
||||
/**
|
||||
* a Diffie-Hellman key agreement class.
|
||||
* <p>
|
||||
* note: This is only the basic algorithm, it doesn't take advantage of
|
||||
* long term public keys if they are available. See the DHAgreement class
|
||||
* for a "better" implementation.</p>
|
||||
*/
|
||||
public class DHBasicAgreement
|
||||
: IBasicAgreement
|
||||
{
|
||||
private DHPrivateKeyParameters key;
|
||||
private DHParameters dhParams;
|
||||
|
||||
public virtual void Init(
|
||||
ICipherParameters parameters)
|
||||
{
|
||||
if (parameters is ParametersWithRandom)
|
||||
{
|
||||
parameters = ((ParametersWithRandom) parameters).Parameters;
|
||||
}
|
||||
|
||||
if (!(parameters is DHPrivateKeyParameters))
|
||||
{
|
||||
throw new ArgumentException("DHEngine expects DHPrivateKeyParameters");
|
||||
}
|
||||
|
||||
this.key = (DHPrivateKeyParameters) parameters;
|
||||
this.dhParams = key.Parameters;
|
||||
}
|
||||
|
||||
public virtual int GetFieldSize()
|
||||
{
|
||||
return (key.Parameters.P.BitLength + 7) / 8;
|
||||
}
|
||||
|
||||
/**
|
||||
* given a short term public key from a given party calculate the next
|
||||
* message in the agreement sequence.
|
||||
*/
|
||||
public virtual BigInteger CalculateAgreement(
|
||||
ICipherParameters pubKey)
|
||||
{
|
||||
if (this.key == null)
|
||||
throw new InvalidOperationException("Agreement algorithm not initialised");
|
||||
|
||||
DHPublicKeyParameters pub = (DHPublicKeyParameters)pubKey;
|
||||
|
||||
if (!pub.Parameters.Equals(dhParams))
|
||||
{
|
||||
throw new ArgumentException("Diffie-Hellman public key has wrong parameters.");
|
||||
}
|
||||
|
||||
return pub.Y.ModPow(key.X, dhParams.P);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45ee4f8892942406aa9e00926a7a33c7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Math;
|
||||
using Org.BouncyCastle.Math.EC;
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto.Agreement
|
||||
{
|
||||
/**
|
||||
* P1363 7.2.1 ECSVDP-DH
|
||||
*
|
||||
* ECSVDP-DH is Elliptic Curve Secret Value Derivation Primitive,
|
||||
* Diffie-Hellman version. It is based on the work of [DH76], [Mil86],
|
||||
* and [Kob87]. This primitive derives a shared secret value from one
|
||||
* party's private key and another party's public key, where both have
|
||||
* the same set of EC domain parameters. If two parties correctly
|
||||
* execute this primitive, they will produce the same output. This
|
||||
* primitive can be invoked by a scheme to derive a shared secret key;
|
||||
* specifically, it may be used with the schemes ECKAS-DH1 and
|
||||
* DL/ECKAS-DH2. It assumes that the input keys are valid (see also
|
||||
* Section 7.2.2).
|
||||
*/
|
||||
public class ECDHBasicAgreement
|
||||
: IBasicAgreement
|
||||
{
|
||||
protected internal ECPrivateKeyParameters privKey;
|
||||
|
||||
public virtual void Init(
|
||||
ICipherParameters parameters)
|
||||
{
|
||||
if (parameters is ParametersWithRandom)
|
||||
{
|
||||
parameters = ((ParametersWithRandom)parameters).Parameters;
|
||||
}
|
||||
|
||||
this.privKey = (ECPrivateKeyParameters)parameters;
|
||||
}
|
||||
|
||||
public virtual int GetFieldSize()
|
||||
{
|
||||
return (privKey.Parameters.Curve.FieldSize + 7) / 8;
|
||||
}
|
||||
|
||||
public virtual BigInteger CalculateAgreement(
|
||||
ICipherParameters pubKey)
|
||||
{
|
||||
ECPublicKeyParameters pub = (ECPublicKeyParameters) pubKey;
|
||||
if (!pub.Parameters.Equals(privKey.Parameters))
|
||||
throw new InvalidOperationException("ECDH public key has wrong domain parameters");
|
||||
|
||||
ECPoint P = pub.Q.Multiply(privKey.D).Normalize();
|
||||
|
||||
if (P.IsInfinity)
|
||||
throw new InvalidOperationException("Infinity is not a valid agreement value for ECDH");
|
||||
|
||||
return P.AffineXCoord.ToBigInteger();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 615c7c8f13cea4ef4b07840b0e1bfbc4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/BestHTTP/SecureProtocol/crypto/digests.meta
Normal file
8
Assets/BestHTTP/SecureProtocol/crypto/digests.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52436231c87c0465980f2edf02298bf7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
360
Assets/BestHTTP/SecureProtocol/crypto/digests/GOST3411Digest.cs
Normal file
360
Assets/BestHTTP/SecureProtocol/crypto/digests/GOST3411Digest.cs
Normal file
@@ -0,0 +1,360 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Crypto.Engines;
|
||||
using Org.BouncyCastle.Crypto.Parameters;
|
||||
using Org.BouncyCastle.Crypto.Utilities;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto.Digests
|
||||
{
|
||||
/**
|
||||
* implementation of GOST R 34.11-94
|
||||
*/
|
||||
public class Gost3411Digest
|
||||
: IDigest, IMemoable
|
||||
{
|
||||
private const int DIGEST_LENGTH = 32;
|
||||
|
||||
private byte[] H = new byte[32], L = new byte[32],
|
||||
M = new byte[32], Sum = new byte[32];
|
||||
private byte[][] C = MakeC();
|
||||
|
||||
private byte[] xBuf = new byte[32];
|
||||
private int xBufOff;
|
||||
private ulong byteCount;
|
||||
|
||||
private readonly IBlockCipher cipher = new Gost28147Engine();
|
||||
private byte[] sBox;
|
||||
|
||||
private static byte[][] MakeC()
|
||||
{
|
||||
byte[][] c = new byte[4][];
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
c[i] = new byte[32];
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard constructor
|
||||
*/
|
||||
public Gost3411Digest()
|
||||
{
|
||||
sBox = Gost28147Engine.GetSBox("D-A");
|
||||
cipher.Init(true, new ParametersWithSBox(null, sBox));
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor to allow use of a particular sbox with GOST28147
|
||||
* @see GOST28147Engine#getSBox(String)
|
||||
*/
|
||||
public Gost3411Digest(byte[] sBoxParam)
|
||||
{
|
||||
sBox = Arrays.Clone(sBoxParam);
|
||||
cipher.Init(true, new ParametersWithSBox(null, sBox));
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor. This will copy the state of the provided
|
||||
* message digest.
|
||||
*/
|
||||
public Gost3411Digest(Gost3411Digest t)
|
||||
{
|
||||
Reset(t);
|
||||
}
|
||||
|
||||
public string AlgorithmName
|
||||
{
|
||||
get { return "Gost3411"; }
|
||||
}
|
||||
|
||||
public int GetDigestSize()
|
||||
{
|
||||
return DIGEST_LENGTH;
|
||||
}
|
||||
|
||||
public void Update(
|
||||
byte input)
|
||||
{
|
||||
xBuf[xBufOff++] = input;
|
||||
if (xBufOff == xBuf.Length)
|
||||
{
|
||||
sumByteArray(xBuf); // calc sum M
|
||||
processBlock(xBuf, 0);
|
||||
xBufOff = 0;
|
||||
}
|
||||
byteCount++;
|
||||
}
|
||||
|
||||
public void BlockUpdate(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length)
|
||||
{
|
||||
while ((xBufOff != 0) && (length > 0))
|
||||
{
|
||||
Update(input[inOff]);
|
||||
inOff++;
|
||||
length--;
|
||||
}
|
||||
|
||||
while (length > xBuf.Length)
|
||||
{
|
||||
Array.Copy(input, inOff, xBuf, 0, xBuf.Length);
|
||||
|
||||
sumByteArray(xBuf); // calc sum M
|
||||
processBlock(xBuf, 0);
|
||||
inOff += xBuf.Length;
|
||||
length -= xBuf.Length;
|
||||
byteCount += (uint)xBuf.Length;
|
||||
}
|
||||
|
||||
// load in the remainder.
|
||||
while (length > 0)
|
||||
{
|
||||
Update(input[inOff]);
|
||||
inOff++;
|
||||
length--;
|
||||
}
|
||||
}
|
||||
|
||||
// (i + 1 + 4(k - 1)) = 8i + k i = 0-3, k = 1-8
|
||||
private byte[] K = new byte[32];
|
||||
|
||||
private byte[] P(byte[] input)
|
||||
{
|
||||
int fourK = 0;
|
||||
for(int k = 0; k < 8; k++)
|
||||
{
|
||||
K[fourK++] = input[k];
|
||||
K[fourK++] = input[8 + k];
|
||||
K[fourK++] = input[16 + k];
|
||||
K[fourK++] = input[24 + k];
|
||||
}
|
||||
|
||||
return K;
|
||||
}
|
||||
|
||||
//A (x) = (x0 ^ x1) || x3 || x2 || x1
|
||||
byte[] a = new byte[8];
|
||||
private byte[] A(byte[] input)
|
||||
{
|
||||
for(int j=0; j<8; j++)
|
||||
{
|
||||
a[j]=(byte)(input[j] ^ input[j+8]);
|
||||
}
|
||||
|
||||
Array.Copy(input, 8, input, 0, 24);
|
||||
Array.Copy(a, 0, input, 24, 8);
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
//Encrypt function, ECB mode
|
||||
private void E(byte[] key, byte[] s, int sOff, byte[] input, int inOff)
|
||||
{
|
||||
cipher.Init(true, new KeyParameter(key));
|
||||
|
||||
cipher.ProcessBlock(input, inOff, s, sOff);
|
||||
}
|
||||
|
||||
// (in:) n16||..||n1 ==> (out:) n1^n2^n3^n4^n13^n16||n16||..||n2
|
||||
internal short[] wS = new short[16], w_S = new short[16];
|
||||
|
||||
private void fw(byte[] input)
|
||||
{
|
||||
cpyBytesToShort(input, wS);
|
||||
w_S[15] = (short)(wS[0] ^ wS[1] ^ wS[2] ^ wS[3] ^ wS[12] ^ wS[15]);
|
||||
Array.Copy(wS, 1, w_S, 0, 15);
|
||||
cpyShortToBytes(w_S, input);
|
||||
}
|
||||
|
||||
// block processing
|
||||
internal byte[] S = new byte[32], U = new byte[32], V = new byte[32], W = new byte[32];
|
||||
|
||||
private void processBlock(byte[] input, int inOff)
|
||||
{
|
||||
Array.Copy(input, inOff, M, 0, 32);
|
||||
|
||||
//key step 1
|
||||
|
||||
// H = h3 || h2 || h1 || h0
|
||||
// S = s3 || s2 || s1 || s0
|
||||
H.CopyTo(U, 0);
|
||||
M.CopyTo(V, 0);
|
||||
for (int j=0; j<32; j++)
|
||||
{
|
||||
W[j] = (byte)(U[j]^V[j]);
|
||||
}
|
||||
// Encrypt gost28147-ECB
|
||||
E(P(W), S, 0, H, 0); // s0 = EK0 [h0]
|
||||
|
||||
//keys step 2,3,4
|
||||
for (int i=1; i<4; i++)
|
||||
{
|
||||
byte[] tmpA = A(U);
|
||||
for (int j=0; j<32; j++)
|
||||
{
|
||||
U[j] = (byte)(tmpA[j] ^ C[i][j]);
|
||||
}
|
||||
V = A(A(V));
|
||||
for (int j=0; j<32; j++)
|
||||
{
|
||||
W[j] = (byte)(U[j]^V[j]);
|
||||
}
|
||||
// Encrypt gost28147-ECB
|
||||
E(P(W), S, i * 8, H, i * 8); // si = EKi [hi]
|
||||
}
|
||||
|
||||
// x(M, H) = y61(H^y(M^y12(S)))
|
||||
for(int n = 0; n < 12; n++)
|
||||
{
|
||||
fw(S);
|
||||
}
|
||||
for(int n = 0; n < 32; n++)
|
||||
{
|
||||
S[n] = (byte)(S[n] ^ M[n]);
|
||||
}
|
||||
|
||||
fw(S);
|
||||
|
||||
for(int n = 0; n < 32; n++)
|
||||
{
|
||||
S[n] = (byte)(H[n] ^ S[n]);
|
||||
}
|
||||
for(int n = 0; n < 61; n++)
|
||||
{
|
||||
fw(S);
|
||||
}
|
||||
Array.Copy(S, 0, H, 0, H.Length);
|
||||
}
|
||||
|
||||
private void finish()
|
||||
{
|
||||
ulong bitCount = byteCount * 8;
|
||||
Pack.UInt64_To_LE(bitCount, L);
|
||||
|
||||
while (xBufOff != 0)
|
||||
{
|
||||
Update((byte)0);
|
||||
}
|
||||
|
||||
processBlock(L, 0);
|
||||
processBlock(Sum, 0);
|
||||
}
|
||||
|
||||
public int DoFinal(
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
finish();
|
||||
|
||||
H.CopyTo(output, outOff);
|
||||
|
||||
Reset();
|
||||
|
||||
return DIGEST_LENGTH;
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the chaining variables to the IV values.
|
||||
*/
|
||||
private static readonly byte[] C2 = {
|
||||
0x00,(byte)0xFF,0x00,(byte)0xFF,0x00,(byte)0xFF,0x00,(byte)0xFF,
|
||||
(byte)0xFF,0x00,(byte)0xFF,0x00,(byte)0xFF,0x00,(byte)0xFF,0x00,
|
||||
0x00,(byte)0xFF,(byte)0xFF,0x00,(byte)0xFF,0x00,0x00,(byte)0xFF,
|
||||
(byte)0xFF,0x00,0x00,0x00,(byte)0xFF,(byte)0xFF,0x00,(byte)0xFF
|
||||
};
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
byteCount = 0;
|
||||
xBufOff = 0;
|
||||
|
||||
Array.Clear(H, 0, H.Length);
|
||||
Array.Clear(L, 0, L.Length);
|
||||
Array.Clear(M, 0, M.Length);
|
||||
Array.Clear(C[1], 0, C[1].Length); // real index C = +1 because index array with 0.
|
||||
Array.Clear(C[3], 0, C[3].Length);
|
||||
Array.Clear(Sum, 0, Sum.Length);
|
||||
Array.Clear(xBuf, 0, xBuf.Length);
|
||||
|
||||
C2.CopyTo(C[2], 0);
|
||||
}
|
||||
|
||||
// 256 bitsblock modul -> (Sum + a mod (2^256))
|
||||
private void sumByteArray(
|
||||
byte[] input)
|
||||
{
|
||||
int carry = 0;
|
||||
|
||||
for (int i = 0; i != Sum.Length; i++)
|
||||
{
|
||||
int sum = (Sum[i] & 0xff) + (input[i] & 0xff) + carry;
|
||||
|
||||
Sum[i] = (byte)sum;
|
||||
|
||||
carry = sum >> 8;
|
||||
}
|
||||
}
|
||||
|
||||
private static void cpyBytesToShort(byte[] S, short[] wS)
|
||||
{
|
||||
for(int i = 0; i < S.Length / 2; i++)
|
||||
{
|
||||
wS[i] = (short)(((S[i*2+1]<<8)&0xFF00)|(S[i*2]&0xFF));
|
||||
}
|
||||
}
|
||||
|
||||
private static void cpyShortToBytes(short[] wS, byte[] S)
|
||||
{
|
||||
for(int i=0; i<S.Length/2; i++)
|
||||
{
|
||||
S[i*2 + 1] = (byte)(wS[i] >> 8);
|
||||
S[i*2] = (byte)wS[i];
|
||||
}
|
||||
}
|
||||
|
||||
public int GetByteLength()
|
||||
{
|
||||
return 32;
|
||||
}
|
||||
|
||||
public IMemoable Copy()
|
||||
{
|
||||
return new Gost3411Digest(this);
|
||||
}
|
||||
|
||||
public void Reset(IMemoable other)
|
||||
{
|
||||
Gost3411Digest t = (Gost3411Digest)other;
|
||||
|
||||
this.sBox = t.sBox;
|
||||
cipher.Init(true, new ParametersWithSBox(null, sBox));
|
||||
|
||||
Reset();
|
||||
|
||||
Array.Copy(t.H, 0, this.H, 0, t.H.Length);
|
||||
Array.Copy(t.L, 0, this.L, 0, t.L.Length);
|
||||
Array.Copy(t.M, 0, this.M, 0, t.M.Length);
|
||||
Array.Copy(t.Sum, 0, this.Sum, 0, t.Sum.Length);
|
||||
Array.Copy(t.C[1], 0, this.C[1], 0, t.C[1].Length);
|
||||
Array.Copy(t.C[2], 0, this.C[2], 0, t.C[2].Length);
|
||||
Array.Copy(t.C[3], 0, this.C[3], 0, t.C[3].Length);
|
||||
Array.Copy(t.xBuf, 0, this.xBuf, 0, t.xBuf.Length);
|
||||
|
||||
this.xBufOff = t.xBufOff;
|
||||
this.byteCount = t.byteCount;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 554f286adc0a5413fbf149bfa9794301
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
137
Assets/BestHTTP/SecureProtocol/crypto/digests/GeneralDigest.cs
Normal file
137
Assets/BestHTTP/SecureProtocol/crypto/digests/GeneralDigest.cs
Normal file
@@ -0,0 +1,137 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto.Digests
|
||||
{
|
||||
/**
|
||||
* base implementation of MD4 family style digest as outlined in
|
||||
* "Handbook of Applied Cryptography", pages 344 - 347.
|
||||
*/
|
||||
public abstract class GeneralDigest
|
||||
: IDigest, IMemoable
|
||||
{
|
||||
private const int BYTE_LENGTH = 64;
|
||||
|
||||
private byte[] xBuf;
|
||||
private int xBufOff;
|
||||
|
||||
private long byteCount;
|
||||
|
||||
internal GeneralDigest()
|
||||
{
|
||||
xBuf = new byte[4];
|
||||
}
|
||||
|
||||
internal GeneralDigest(GeneralDigest t)
|
||||
{
|
||||
xBuf = new byte[t.xBuf.Length];
|
||||
CopyIn(t);
|
||||
}
|
||||
|
||||
protected void CopyIn(GeneralDigest t)
|
||||
{
|
||||
Array.Copy(t.xBuf, 0, xBuf, 0, t.xBuf.Length);
|
||||
|
||||
xBufOff = t.xBufOff;
|
||||
byteCount = t.byteCount;
|
||||
}
|
||||
|
||||
public void Update(byte input)
|
||||
{
|
||||
xBuf[xBufOff++] = input;
|
||||
|
||||
if (xBufOff == xBuf.Length)
|
||||
{
|
||||
ProcessWord(xBuf, 0);
|
||||
xBufOff = 0;
|
||||
}
|
||||
|
||||
byteCount++;
|
||||
}
|
||||
|
||||
public void BlockUpdate(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length)
|
||||
{
|
||||
length = System.Math.Max(0, length);
|
||||
|
||||
//
|
||||
// fill the current word
|
||||
//
|
||||
int i = 0;
|
||||
if (xBufOff != 0)
|
||||
{
|
||||
while (i < length)
|
||||
{
|
||||
xBuf[xBufOff++] = input[inOff + i++];
|
||||
if (xBufOff == 4)
|
||||
{
|
||||
ProcessWord(xBuf, 0);
|
||||
xBufOff = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// process whole words.
|
||||
//
|
||||
int limit = ((length - i) & ~3) + i;
|
||||
for (; i < limit; i += 4)
|
||||
{
|
||||
ProcessWord(input, inOff + i);
|
||||
}
|
||||
|
||||
//
|
||||
// load in the remainder.
|
||||
//
|
||||
while (i < length)
|
||||
{
|
||||
xBuf[xBufOff++] = input[inOff + i++];
|
||||
}
|
||||
|
||||
byteCount += length;
|
||||
}
|
||||
|
||||
public void Finish()
|
||||
{
|
||||
long bitLength = (byteCount << 3);
|
||||
|
||||
//
|
||||
// add the pad bytes.
|
||||
//
|
||||
Update((byte)128);
|
||||
|
||||
while (xBufOff != 0) Update((byte)0);
|
||||
ProcessLength(bitLength);
|
||||
ProcessBlock();
|
||||
}
|
||||
|
||||
public virtual void Reset()
|
||||
{
|
||||
byteCount = 0;
|
||||
xBufOff = 0;
|
||||
Array.Clear(xBuf, 0, xBuf.Length);
|
||||
}
|
||||
|
||||
public int GetByteLength()
|
||||
{
|
||||
return BYTE_LENGTH;
|
||||
}
|
||||
|
||||
internal abstract void ProcessWord(byte[] input, int inOff);
|
||||
internal abstract void ProcessLength(long bitLength);
|
||||
internal abstract void ProcessBlock();
|
||||
public abstract string AlgorithmName { get; }
|
||||
public abstract int GetDigestSize();
|
||||
public abstract int DoFinal(byte[] output, int outOff);
|
||||
public abstract IMemoable Copy();
|
||||
public abstract void Reset(IMemoable t);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e6ab8d3dfc8c44d3978b1c713f10f67
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
538
Assets/BestHTTP/SecureProtocol/crypto/digests/KeccakDigest.cs
Normal file
538
Assets/BestHTTP/SecureProtocol/crypto/digests/KeccakDigest.cs
Normal file
@@ -0,0 +1,538 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto.Digests
|
||||
{
|
||||
/// <summary>
|
||||
/// Implementation of Keccak based on following KeccakNISTInterface.c from http://keccak.noekeon.org/
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Following the naming conventions used in the C source code to enable easy review of the implementation.
|
||||
/// </remarks>
|
||||
public class KeccakDigest
|
||||
: IDigest, IMemoable
|
||||
{
|
||||
private static readonly ulong[] KeccakRoundConstants = KeccakInitializeRoundConstants();
|
||||
|
||||
private static readonly int[] KeccakRhoOffsets = KeccakInitializeRhoOffsets();
|
||||
|
||||
private static ulong[] KeccakInitializeRoundConstants()
|
||||
{
|
||||
ulong[] keccakRoundConstants = new ulong[24];
|
||||
byte LFSRState = 0x01;
|
||||
|
||||
for (int i = 0; i < 24; i++)
|
||||
{
|
||||
keccakRoundConstants[i] = 0;
|
||||
for (int j = 0; j < 7; j++)
|
||||
{
|
||||
int bitPosition = (1 << j) - 1;
|
||||
|
||||
// LFSR86540
|
||||
|
||||
bool loBit = (LFSRState & 0x01) != 0;
|
||||
if (loBit)
|
||||
{
|
||||
keccakRoundConstants[i] ^= 1UL << bitPosition;
|
||||
}
|
||||
|
||||
bool hiBit = (LFSRState & 0x80) != 0;
|
||||
LFSRState <<= 1;
|
||||
if (hiBit)
|
||||
{
|
||||
LFSRState ^= 0x71;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return keccakRoundConstants;
|
||||
}
|
||||
|
||||
private static int[] KeccakInitializeRhoOffsets()
|
||||
{
|
||||
int[] keccakRhoOffsets = new int[25];
|
||||
int x, y, t, newX, newY;
|
||||
|
||||
int rhoOffset = 0;
|
||||
keccakRhoOffsets[(((0) % 5) + 5 * ((0) % 5))] = rhoOffset;
|
||||
x = 1;
|
||||
y = 0;
|
||||
for (t = 1; t < 25; t++)
|
||||
{
|
||||
//rhoOffset = ((t + 1) * (t + 2) / 2) % 64;
|
||||
rhoOffset = (rhoOffset + t) & 63;
|
||||
keccakRhoOffsets[(((x) % 5) + 5 * ((y) % 5))] = rhoOffset;
|
||||
newX = (0 * x + 1 * y) % 5;
|
||||
newY = (2 * x + 3 * y) % 5;
|
||||
x = newX;
|
||||
y = newY;
|
||||
}
|
||||
|
||||
return keccakRhoOffsets;
|
||||
}
|
||||
|
||||
protected byte[] state = new byte[(1600 / 8)];
|
||||
protected byte[] dataQueue = new byte[(1536 / 8)];
|
||||
protected int rate;
|
||||
protected int bitsInQueue;
|
||||
protected int fixedOutputLength;
|
||||
protected bool squeezing;
|
||||
protected int bitsAvailableForSqueezing;
|
||||
protected byte[] chunk;
|
||||
protected byte[] oneByte;
|
||||
|
||||
private void ClearDataQueueSection(int off, int len)
|
||||
{
|
||||
for (int i = off; i != off + len; i++)
|
||||
{
|
||||
dataQueue[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public KeccakDigest()
|
||||
: this(288)
|
||||
{
|
||||
}
|
||||
|
||||
public KeccakDigest(int bitLength)
|
||||
{
|
||||
Init(bitLength);
|
||||
}
|
||||
|
||||
public KeccakDigest(KeccakDigest source)
|
||||
{
|
||||
CopyIn(source);
|
||||
}
|
||||
|
||||
private void CopyIn(KeccakDigest source)
|
||||
{
|
||||
Array.Copy(source.state, 0, this.state, 0, source.state.Length);
|
||||
Array.Copy(source.dataQueue, 0, this.dataQueue, 0, source.dataQueue.Length);
|
||||
this.rate = source.rate;
|
||||
this.bitsInQueue = source.bitsInQueue;
|
||||
this.fixedOutputLength = source.fixedOutputLength;
|
||||
this.squeezing = source.squeezing;
|
||||
this.bitsAvailableForSqueezing = source.bitsAvailableForSqueezing;
|
||||
this.chunk = Arrays.Clone(source.chunk);
|
||||
this.oneByte = Arrays.Clone(source.oneByte);
|
||||
}
|
||||
|
||||
public virtual string AlgorithmName
|
||||
{
|
||||
get { return "Keccak-" + fixedOutputLength; }
|
||||
}
|
||||
|
||||
public virtual int GetDigestSize()
|
||||
{
|
||||
return fixedOutputLength / 8;
|
||||
}
|
||||
|
||||
public virtual void Update(byte input)
|
||||
{
|
||||
oneByte[0] = input;
|
||||
|
||||
Absorb(oneByte, 0, 8L);
|
||||
}
|
||||
|
||||
public virtual void BlockUpdate(byte[] input, int inOff, int len)
|
||||
{
|
||||
Absorb(input, inOff, len * 8L);
|
||||
}
|
||||
|
||||
public virtual int DoFinal(byte[] output, int outOff)
|
||||
{
|
||||
Squeeze(output, outOff, fixedOutputLength);
|
||||
|
||||
Reset();
|
||||
|
||||
return GetDigestSize();
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO Possible API change to support partial-byte suffixes.
|
||||
*/
|
||||
protected virtual int DoFinal(byte[] output, int outOff, byte partialByte, int partialBits)
|
||||
{
|
||||
if (partialBits > 0)
|
||||
{
|
||||
oneByte[0] = partialByte;
|
||||
Absorb(oneByte, 0, partialBits);
|
||||
}
|
||||
|
||||
Squeeze(output, outOff, fixedOutputLength);
|
||||
|
||||
Reset();
|
||||
|
||||
return GetDigestSize();
|
||||
}
|
||||
|
||||
public virtual void Reset()
|
||||
{
|
||||
Init(fixedOutputLength);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the size of block that the compression function is applied to in bytes.
|
||||
*
|
||||
* @return internal byte length of a block.
|
||||
*/
|
||||
public virtual int GetByteLength()
|
||||
{
|
||||
return rate / 8;
|
||||
}
|
||||
|
||||
private void Init(int bitLength)
|
||||
{
|
||||
switch (bitLength)
|
||||
{
|
||||
case 128:
|
||||
InitSponge(1344, 256);
|
||||
break;
|
||||
case 224:
|
||||
InitSponge(1152, 448);
|
||||
break;
|
||||
case 256:
|
||||
InitSponge(1088, 512);
|
||||
break;
|
||||
case 288:
|
||||
InitSponge(1024, 576);
|
||||
break;
|
||||
case 384:
|
||||
InitSponge(832, 768);
|
||||
break;
|
||||
case 512:
|
||||
InitSponge(576, 1024);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("must be one of 128, 224, 256, 288, 384, or 512.", "bitLength");
|
||||
}
|
||||
}
|
||||
|
||||
private void InitSponge(int rate, int capacity)
|
||||
{
|
||||
if (rate + capacity != 1600)
|
||||
{
|
||||
throw new InvalidOperationException("rate + capacity != 1600");
|
||||
}
|
||||
if ((rate <= 0) || (rate >= 1600) || ((rate % 64) != 0))
|
||||
{
|
||||
throw new InvalidOperationException("invalid rate value");
|
||||
}
|
||||
|
||||
this.rate = rate;
|
||||
// this is never read, need to check to see why we want to save it
|
||||
// this.capacity = capacity;
|
||||
this.fixedOutputLength = 0;
|
||||
Arrays.Fill(this.state, (byte)0);
|
||||
Arrays.Fill(this.dataQueue, (byte)0);
|
||||
this.bitsInQueue = 0;
|
||||
this.squeezing = false;
|
||||
this.bitsAvailableForSqueezing = 0;
|
||||
this.fixedOutputLength = capacity / 2;
|
||||
this.chunk = new byte[rate / 8];
|
||||
this.oneByte = new byte[1];
|
||||
}
|
||||
|
||||
private void AbsorbQueue()
|
||||
{
|
||||
KeccakAbsorb(state, dataQueue, rate / 8);
|
||||
|
||||
bitsInQueue = 0;
|
||||
}
|
||||
|
||||
protected virtual void Absorb(byte[] data, int off, long databitlen)
|
||||
{
|
||||
long i, j, wholeBlocks;
|
||||
|
||||
if ((bitsInQueue % 8) != 0)
|
||||
{
|
||||
throw new InvalidOperationException("attempt to absorb with odd length queue");
|
||||
}
|
||||
if (squeezing)
|
||||
{
|
||||
throw new InvalidOperationException("attempt to absorb while squeezing");
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < databitlen)
|
||||
{
|
||||
if ((bitsInQueue == 0) && (databitlen >= rate) && (i <= (databitlen - rate)))
|
||||
{
|
||||
wholeBlocks = (databitlen - i) / rate;
|
||||
|
||||
for (j = 0; j < wholeBlocks; j++)
|
||||
{
|
||||
Array.Copy(data, (int)(off + (i / 8) + (j * chunk.Length)), chunk, 0, chunk.Length);
|
||||
|
||||
KeccakAbsorb(state, chunk, chunk.Length);
|
||||
}
|
||||
|
||||
i += wholeBlocks * rate;
|
||||
}
|
||||
else
|
||||
{
|
||||
int partialBlock = (int)(databitlen - i);
|
||||
if (partialBlock + bitsInQueue > rate)
|
||||
{
|
||||
partialBlock = rate - bitsInQueue;
|
||||
}
|
||||
int partialByte = partialBlock % 8;
|
||||
partialBlock -= partialByte;
|
||||
Array.Copy(data, off + (int)(i / 8), dataQueue, bitsInQueue / 8, partialBlock / 8);
|
||||
|
||||
bitsInQueue += partialBlock;
|
||||
i += partialBlock;
|
||||
if (bitsInQueue == rate)
|
||||
{
|
||||
AbsorbQueue();
|
||||
}
|
||||
if (partialByte > 0)
|
||||
{
|
||||
int mask = (1 << partialByte) - 1;
|
||||
dataQueue[bitsInQueue / 8] = (byte)(data[off + ((int)(i / 8))] & mask);
|
||||
bitsInQueue += partialByte;
|
||||
i += partialByte;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void PadAndSwitchToSqueezingPhase()
|
||||
{
|
||||
if (bitsInQueue + 1 == rate)
|
||||
{
|
||||
dataQueue[bitsInQueue / 8] |= (byte)(1U << (bitsInQueue % 8));
|
||||
AbsorbQueue();
|
||||
ClearDataQueueSection(0, rate / 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearDataQueueSection((bitsInQueue + 7) / 8, rate / 8 - (bitsInQueue + 7) / 8);
|
||||
dataQueue[bitsInQueue / 8] |= (byte)(1U << (bitsInQueue % 8));
|
||||
}
|
||||
dataQueue[(rate - 1) / 8] |= (byte)(1U << ((rate - 1) % 8));
|
||||
AbsorbQueue();
|
||||
|
||||
if (rate == 1024)
|
||||
{
|
||||
KeccakExtract1024bits(state, dataQueue);
|
||||
bitsAvailableForSqueezing = 1024;
|
||||
}
|
||||
else
|
||||
{
|
||||
KeccakExtract(state, dataQueue, rate / 64);
|
||||
bitsAvailableForSqueezing = rate;
|
||||
}
|
||||
|
||||
squeezing = true;
|
||||
}
|
||||
|
||||
protected virtual void Squeeze(byte[] output, int offset, long outputLength)
|
||||
{
|
||||
long i;
|
||||
int partialBlock;
|
||||
|
||||
if (!squeezing)
|
||||
{
|
||||
PadAndSwitchToSqueezingPhase();
|
||||
}
|
||||
if ((outputLength % 8) != 0)
|
||||
{
|
||||
throw new InvalidOperationException("outputLength not a multiple of 8");
|
||||
}
|
||||
|
||||
i = 0;
|
||||
while (i < outputLength)
|
||||
{
|
||||
if (bitsAvailableForSqueezing == 0)
|
||||
{
|
||||
KeccakPermutation(state);
|
||||
|
||||
if (rate == 1024)
|
||||
{
|
||||
KeccakExtract1024bits(state, dataQueue);
|
||||
bitsAvailableForSqueezing = 1024;
|
||||
}
|
||||
else
|
||||
{
|
||||
KeccakExtract(state, dataQueue, rate / 64);
|
||||
bitsAvailableForSqueezing = rate;
|
||||
}
|
||||
}
|
||||
partialBlock = bitsAvailableForSqueezing;
|
||||
if ((long)partialBlock > outputLength - i)
|
||||
{
|
||||
partialBlock = (int)(outputLength - i);
|
||||
}
|
||||
|
||||
Array.Copy(dataQueue, (rate - bitsAvailableForSqueezing) / 8, output, offset + (int)(i / 8), partialBlock / 8);
|
||||
bitsAvailableForSqueezing -= partialBlock;
|
||||
i += partialBlock;
|
||||
}
|
||||
}
|
||||
|
||||
private static void FromBytesToWords(ulong[] stateAsWords, byte[] state)
|
||||
{
|
||||
for (int i = 0; i < (1600 / 64); i++)
|
||||
{
|
||||
stateAsWords[i] = 0;
|
||||
int index = i * (64 / 8);
|
||||
for (int j = 0; j < (64 / 8); j++)
|
||||
{
|
||||
stateAsWords[i] |= ((ulong)state[index + j] & 0xff) << ((8 * j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void FromWordsToBytes(byte[] state, ulong[] stateAsWords)
|
||||
{
|
||||
for (int i = 0; i < (1600 / 64); i++)
|
||||
{
|
||||
int index = i * (64 / 8);
|
||||
for (int j = 0; j < (64 / 8); j++)
|
||||
{
|
||||
state[index + j] = (byte)(stateAsWords[i] >> (8 * j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void KeccakPermutation(byte[] state)
|
||||
{
|
||||
ulong[] longState = new ulong[state.Length / 8];
|
||||
|
||||
FromBytesToWords(longState, state);
|
||||
|
||||
KeccakPermutationOnWords(longState);
|
||||
|
||||
FromWordsToBytes(state, longState);
|
||||
}
|
||||
|
||||
private void KeccakPermutationAfterXor(byte[] state, byte[] data, int dataLengthInBytes)
|
||||
{
|
||||
for (int i = 0; i < dataLengthInBytes; i++)
|
||||
{
|
||||
state[i] ^= data[i];
|
||||
}
|
||||
|
||||
KeccakPermutation(state);
|
||||
}
|
||||
|
||||
private void KeccakPermutationOnWords(ulong[] state)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 24; i++)
|
||||
{
|
||||
Theta(state);
|
||||
Rho(state);
|
||||
Pi(state);
|
||||
Chi(state);
|
||||
Iota(state, i);
|
||||
}
|
||||
}
|
||||
|
||||
ulong[] C = new ulong[5];
|
||||
|
||||
private void Theta(ulong[] A)
|
||||
{
|
||||
for (int x = 0; x < 5; x++)
|
||||
{
|
||||
C[x] = 0;
|
||||
for (int y = 0; y < 5; y++)
|
||||
{
|
||||
C[x] ^= A[x + 5 * y];
|
||||
}
|
||||
}
|
||||
for (int x = 0; x < 5; x++)
|
||||
{
|
||||
ulong dX = ((((C[(x + 1) % 5]) << 1) ^ ((C[(x + 1) % 5]) >> (64 - 1)))) ^ C[(x + 4) % 5];
|
||||
for (int y = 0; y < 5; y++)
|
||||
{
|
||||
A[x + 5 * y] ^= dX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Rho(ulong[] A)
|
||||
{
|
||||
for (int x = 0; x < 5; x++)
|
||||
{
|
||||
for (int y = 0; y < 5; y++)
|
||||
{
|
||||
int index = x + 5 * y;
|
||||
A[index] = ((KeccakRhoOffsets[index] != 0) ? (((A[index]) << KeccakRhoOffsets[index]) ^ ((A[index]) >> (64 - KeccakRhoOffsets[index]))) : A[index]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ulong[] tempA = new ulong[25];
|
||||
|
||||
private void Pi(ulong[] A)
|
||||
{
|
||||
Array.Copy(A, 0, tempA, 0, tempA.Length);
|
||||
|
||||
for (int x = 0; x < 5; x++)
|
||||
{
|
||||
for (int y = 0; y < 5; y++)
|
||||
{
|
||||
A[y + 5 * ((2 * x + 3 * y) % 5)] = tempA[x + 5 * y];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ulong[] chiC = new ulong[5];
|
||||
|
||||
private void Chi(ulong[] A)
|
||||
{
|
||||
for (int y = 0; y < 5; y++)
|
||||
{
|
||||
for (int x = 0; x < 5; x++)
|
||||
{
|
||||
chiC[x] = A[x + 5 * y] ^ ((~A[(((x + 1) % 5) + 5 * y)]) & A[(((x + 2) % 5) + 5 * y)]);
|
||||
}
|
||||
for (int x = 0; x < 5; x++)
|
||||
{
|
||||
A[x + 5 * y] = chiC[x];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void Iota(ulong[] A, int indexRound)
|
||||
{
|
||||
A[(((0) % 5) + 5 * ((0) % 5))] ^= KeccakRoundConstants[indexRound];
|
||||
}
|
||||
|
||||
private void KeccakAbsorb(byte[] byteState, byte[] data, int dataInBytes)
|
||||
{
|
||||
KeccakPermutationAfterXor(byteState, data, dataInBytes);
|
||||
}
|
||||
|
||||
private void KeccakExtract1024bits(byte[] byteState, byte[] data)
|
||||
{
|
||||
Array.Copy(byteState, 0, data, 0, 128);
|
||||
}
|
||||
|
||||
private void KeccakExtract(byte[] byteState, byte[] data, int laneCount)
|
||||
{
|
||||
Array.Copy(byteState, 0, data, 0, laneCount * 8);
|
||||
}
|
||||
|
||||
public virtual IMemoable Copy()
|
||||
{
|
||||
return new KeccakDigest(this);
|
||||
}
|
||||
|
||||
public virtual void Reset(IMemoable other)
|
||||
{
|
||||
KeccakDigest d = (KeccakDigest)other;
|
||||
|
||||
CopyIn(d);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8ea9be2008de40c1b23963d59a5c209
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
359
Assets/BestHTTP/SecureProtocol/crypto/digests/LongDigest.cs
Normal file
359
Assets/BestHTTP/SecureProtocol/crypto/digests/LongDigest.cs
Normal file
@@ -0,0 +1,359 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using Org.BouncyCastle.Crypto.Utilities;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto.Digests
|
||||
{
|
||||
/**
|
||||
* Base class for SHA-384 and SHA-512.
|
||||
*/
|
||||
public abstract class LongDigest
|
||||
: IDigest, IMemoable
|
||||
{
|
||||
private int MyByteLength = 128;
|
||||
|
||||
private byte[] xBuf;
|
||||
private int xBufOff;
|
||||
|
||||
private long byteCount1;
|
||||
private long byteCount2;
|
||||
|
||||
internal ulong H1, H2, H3, H4, H5, H6, H7, H8;
|
||||
|
||||
private ulong[] W = new ulong[80];
|
||||
private int wOff;
|
||||
|
||||
/**
|
||||
* Constructor for variable length word
|
||||
*/
|
||||
internal LongDigest()
|
||||
{
|
||||
xBuf = new byte[8];
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor. We are using copy constructors in place
|
||||
* of the object.Clone() interface as this interface is not
|
||||
* supported by J2ME.
|
||||
*/
|
||||
internal LongDigest(
|
||||
LongDigest t)
|
||||
{
|
||||
xBuf = new byte[t.xBuf.Length];
|
||||
|
||||
CopyIn(t);
|
||||
}
|
||||
|
||||
protected void CopyIn(LongDigest t)
|
||||
{
|
||||
Array.Copy(t.xBuf, 0, xBuf, 0, t.xBuf.Length);
|
||||
|
||||
xBufOff = t.xBufOff;
|
||||
byteCount1 = t.byteCount1;
|
||||
byteCount2 = t.byteCount2;
|
||||
|
||||
H1 = t.H1;
|
||||
H2 = t.H2;
|
||||
H3 = t.H3;
|
||||
H4 = t.H4;
|
||||
H5 = t.H5;
|
||||
H6 = t.H6;
|
||||
H7 = t.H7;
|
||||
H8 = t.H8;
|
||||
|
||||
Array.Copy(t.W, 0, W, 0, t.W.Length);
|
||||
wOff = t.wOff;
|
||||
}
|
||||
|
||||
public void Update(
|
||||
byte input)
|
||||
{
|
||||
xBuf[xBufOff++] = input;
|
||||
|
||||
if (xBufOff == xBuf.Length)
|
||||
{
|
||||
ProcessWord(xBuf, 0);
|
||||
xBufOff = 0;
|
||||
}
|
||||
|
||||
byteCount1++;
|
||||
}
|
||||
|
||||
public void BlockUpdate(
|
||||
byte[] input,
|
||||
int inOff,
|
||||
int length)
|
||||
{
|
||||
//
|
||||
// fill the current word
|
||||
//
|
||||
while ((xBufOff != 0) && (length > 0))
|
||||
{
|
||||
Update(input[inOff]);
|
||||
|
||||
inOff++;
|
||||
length--;
|
||||
}
|
||||
|
||||
//
|
||||
// process whole words.
|
||||
//
|
||||
while (length > xBuf.Length)
|
||||
{
|
||||
ProcessWord(input, inOff);
|
||||
|
||||
inOff += xBuf.Length;
|
||||
length -= xBuf.Length;
|
||||
byteCount1 += xBuf.Length;
|
||||
}
|
||||
|
||||
//
|
||||
// load in the remainder.
|
||||
//
|
||||
while (length > 0)
|
||||
{
|
||||
Update(input[inOff]);
|
||||
|
||||
inOff++;
|
||||
length--;
|
||||
}
|
||||
}
|
||||
|
||||
public void Finish()
|
||||
{
|
||||
AdjustByteCounts();
|
||||
|
||||
long lowBitLength = byteCount1 << 3;
|
||||
long hiBitLength = byteCount2;
|
||||
|
||||
//
|
||||
// add the pad bytes.
|
||||
//
|
||||
Update((byte)128);
|
||||
|
||||
while (xBufOff != 0)
|
||||
{
|
||||
Update((byte)0);
|
||||
}
|
||||
|
||||
ProcessLength(lowBitLength, hiBitLength);
|
||||
|
||||
ProcessBlock();
|
||||
}
|
||||
|
||||
public virtual void Reset()
|
||||
{
|
||||
byteCount1 = 0;
|
||||
byteCount2 = 0;
|
||||
|
||||
xBufOff = 0;
|
||||
for ( int i = 0; i < xBuf.Length; i++ )
|
||||
{
|
||||
xBuf[i] = 0;
|
||||
}
|
||||
|
||||
wOff = 0;
|
||||
Array.Clear(W, 0, W.Length);
|
||||
}
|
||||
|
||||
internal void ProcessWord(
|
||||
byte[] input,
|
||||
int inOff)
|
||||
{
|
||||
W[wOff] = Pack.BE_To_UInt64(input, inOff);
|
||||
|
||||
if (++wOff == 16)
|
||||
{
|
||||
ProcessBlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* adjust the byte counts so that byteCount2 represents the
|
||||
* upper long (less 3 bits) word of the byte count.
|
||||
*/
|
||||
private void AdjustByteCounts()
|
||||
{
|
||||
if (byteCount1 > 0x1fffffffffffffffL)
|
||||
{
|
||||
byteCount2 += (long) ((ulong) byteCount1 >> 61);
|
||||
byteCount1 &= 0x1fffffffffffffffL;
|
||||
}
|
||||
}
|
||||
|
||||
internal void ProcessLength(
|
||||
long lowW,
|
||||
long hiW)
|
||||
{
|
||||
if (wOff > 14)
|
||||
{
|
||||
ProcessBlock();
|
||||
}
|
||||
|
||||
W[14] = (ulong)hiW;
|
||||
W[15] = (ulong)lowW;
|
||||
}
|
||||
|
||||
internal void ProcessBlock()
|
||||
{
|
||||
AdjustByteCounts();
|
||||
|
||||
//
|
||||
// expand 16 word block into 80 word blocks.
|
||||
//
|
||||
for (int ti = 16; ti <= 79; ++ti)
|
||||
{
|
||||
W[ti] = Sigma1(W[ti - 2]) + W[ti - 7] + Sigma0(W[ti - 15]) + W[ti - 16];
|
||||
}
|
||||
|
||||
//
|
||||
// set up working variables.
|
||||
//
|
||||
ulong a = H1;
|
||||
ulong b = H2;
|
||||
ulong c = H3;
|
||||
ulong d = H4;
|
||||
ulong e = H5;
|
||||
ulong f = H6;
|
||||
ulong g = H7;
|
||||
ulong h = H8;
|
||||
|
||||
int t = 0;
|
||||
for(int i = 0; i < 10; i ++)
|
||||
{
|
||||
// t = 8 * i
|
||||
h += Sum1(e) + Ch(e, f, g) + K[t] + W[t++];
|
||||
d += h;
|
||||
h += Sum0(a) + Maj(a, b, c);
|
||||
|
||||
// t = 8 * i + 1
|
||||
g += Sum1(d) + Ch(d, e, f) + K[t] + W[t++];
|
||||
c += g;
|
||||
g += Sum0(h) + Maj(h, a, b);
|
||||
|
||||
// t = 8 * i + 2
|
||||
f += Sum1(c) + Ch(c, d, e) + K[t] + W[t++];
|
||||
b += f;
|
||||
f += Sum0(g) + Maj(g, h, a);
|
||||
|
||||
// t = 8 * i + 3
|
||||
e += Sum1(b) + Ch(b, c, d) + K[t] + W[t++];
|
||||
a += e;
|
||||
e += Sum0(f) + Maj(f, g, h);
|
||||
|
||||
// t = 8 * i + 4
|
||||
d += Sum1(a) + Ch(a, b, c) + K[t] + W[t++];
|
||||
h += d;
|
||||
d += Sum0(e) + Maj(e, f, g);
|
||||
|
||||
// t = 8 * i + 5
|
||||
c += Sum1(h) + Ch(h, a, b) + K[t] + W[t++];
|
||||
g += c;
|
||||
c += Sum0(d) + Maj(d, e, f);
|
||||
|
||||
// t = 8 * i + 6
|
||||
b += Sum1(g) + Ch(g, h, a) + K[t] + W[t++];
|
||||
f += b;
|
||||
b += Sum0(c) + Maj(c, d, e);
|
||||
|
||||
// t = 8 * i + 7
|
||||
a += Sum1(f) + Ch(f, g, h) + K[t] + W[t++];
|
||||
e += a;
|
||||
a += Sum0(b) + Maj(b, c, d);
|
||||
}
|
||||
|
||||
H1 += a;
|
||||
H2 += b;
|
||||
H3 += c;
|
||||
H4 += d;
|
||||
H5 += e;
|
||||
H6 += f;
|
||||
H7 += g;
|
||||
H8 += h;
|
||||
|
||||
//
|
||||
// reset the offset and clean out the word buffer.
|
||||
//
|
||||
wOff = 0;
|
||||
Array.Clear(W, 0, 16);
|
||||
}
|
||||
|
||||
/* SHA-384 and SHA-512 functions (as for SHA-256 but for longs) */
|
||||
private static ulong Ch(ulong x, ulong y, ulong z)
|
||||
{
|
||||
return (x & y) ^ (~x & z);
|
||||
}
|
||||
|
||||
private static ulong Maj(ulong x, ulong y, ulong z)
|
||||
{
|
||||
return (x & y) ^ (x & z) ^ (y & z);
|
||||
}
|
||||
|
||||
private static ulong Sum0(ulong x)
|
||||
{
|
||||
return ((x << 36) | (x >> 28)) ^ ((x << 30) | (x >> 34)) ^ ((x << 25) | (x >> 39));
|
||||
}
|
||||
|
||||
private static ulong Sum1(ulong x)
|
||||
{
|
||||
return ((x << 50) | (x >> 14)) ^ ((x << 46) | (x >> 18)) ^ ((x << 23) | (x >> 41));
|
||||
}
|
||||
|
||||
private static ulong Sigma0(ulong x)
|
||||
{
|
||||
return ((x << 63) | (x >> 1)) ^ ((x << 56) | (x >> 8)) ^ (x >> 7);
|
||||
}
|
||||
|
||||
private static ulong Sigma1(ulong x)
|
||||
{
|
||||
return ((x << 45) | (x >> 19)) ^ ((x << 3) | (x >> 61)) ^ (x >> 6);
|
||||
}
|
||||
|
||||
/* SHA-384 and SHA-512 Constants
|
||||
* (represent the first 64 bits of the fractional parts of the
|
||||
* cube roots of the first sixty-four prime numbers)
|
||||
*/
|
||||
internal static readonly ulong[] K =
|
||||
{
|
||||
0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f, 0xe9b5dba58189dbbc,
|
||||
0x3956c25bf348b538, 0x59f111f1b605d019, 0x923f82a4af194f9b, 0xab1c5ed5da6d8118,
|
||||
0xd807aa98a3030242, 0x12835b0145706fbe, 0x243185be4ee4b28c, 0x550c7dc3d5ffb4e2,
|
||||
0x72be5d74f27b896f, 0x80deb1fe3b1696b1, 0x9bdc06a725c71235, 0xc19bf174cf692694,
|
||||
0xe49b69c19ef14ad2, 0xefbe4786384f25e3, 0x0fc19dc68b8cd5b5, 0x240ca1cc77ac9c65,
|
||||
0x2de92c6f592b0275, 0x4a7484aa6ea6e483, 0x5cb0a9dcbd41fbd4, 0x76f988da831153b5,
|
||||
0x983e5152ee66dfab, 0xa831c66d2db43210, 0xb00327c898fb213f, 0xbf597fc7beef0ee4,
|
||||
0xc6e00bf33da88fc2, 0xd5a79147930aa725, 0x06ca6351e003826f, 0x142929670a0e6e70,
|
||||
0x27b70a8546d22ffc, 0x2e1b21385c26c926, 0x4d2c6dfc5ac42aed, 0x53380d139d95b3df,
|
||||
0x650a73548baf63de, 0x766a0abb3c77b2a8, 0x81c2c92e47edaee6, 0x92722c851482353b,
|
||||
0xa2bfe8a14cf10364, 0xa81a664bbc423001, 0xc24b8b70d0f89791, 0xc76c51a30654be30,
|
||||
0xd192e819d6ef5218, 0xd69906245565a910, 0xf40e35855771202a, 0x106aa07032bbd1b8,
|
||||
0x19a4c116b8d2d0c8, 0x1e376c085141ab53, 0x2748774cdf8eeb99, 0x34b0bcb5e19b48a8,
|
||||
0x391c0cb3c5c95a63, 0x4ed8aa4ae3418acb, 0x5b9cca4f7763e373, 0x682e6ff3d6b2b8a3,
|
||||
0x748f82ee5defb2fc, 0x78a5636f43172f60, 0x84c87814a1f0ab72, 0x8cc702081a6439ec,
|
||||
0x90befffa23631e28, 0xa4506cebde82bde9, 0xbef9a3f7b2c67915, 0xc67178f2e372532b,
|
||||
0xca273eceea26619c, 0xd186b8c721c0c207, 0xeada7dd6cde0eb1e, 0xf57d4f7fee6ed178,
|
||||
0x06f067aa72176fba, 0x0a637dc5a2c898a6, 0x113f9804bef90dae, 0x1b710b35131c471b,
|
||||
0x28db77f523047d84, 0x32caab7b40c72493, 0x3c9ebe0a15c9bebc, 0x431d67c49c100d4c,
|
||||
0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817
|
||||
};
|
||||
|
||||
public int GetByteLength()
|
||||
{
|
||||
return MyByteLength;
|
||||
}
|
||||
|
||||
public abstract string AlgorithmName { get; }
|
||||
public abstract int GetDigestSize();
|
||||
public abstract int DoFinal(byte[] output, int outOff);
|
||||
public abstract IMemoable Copy();
|
||||
public abstract void Reset(IMemoable t);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 163a07327a6544ead8453a31d10178e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
273
Assets/BestHTTP/SecureProtocol/crypto/digests/MD2Digest.cs
Normal file
273
Assets/BestHTTP/SecureProtocol/crypto/digests/MD2Digest.cs
Normal file
@@ -0,0 +1,273 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Crypto;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto.Digests
|
||||
{
|
||||
|
||||
/**
|
||||
* implementation of MD2
|
||||
* as outlined in RFC1319 by B.Kaliski from RSA Laboratories April 1992
|
||||
*/
|
||||
public class MD2Digest
|
||||
: IDigest, IMemoable
|
||||
{
|
||||
private const int DigestLength = 16;
|
||||
private const int BYTE_LENGTH = 16;
|
||||
|
||||
/* X buffer */
|
||||
private byte[] X = new byte[48];
|
||||
private int xOff;
|
||||
|
||||
/* M buffer */
|
||||
|
||||
private byte[] M = new byte[16];
|
||||
private int mOff;
|
||||
|
||||
/* check sum */
|
||||
|
||||
private byte[] C = new byte[16];
|
||||
private int COff;
|
||||
|
||||
public MD2Digest()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
public MD2Digest(MD2Digest t)
|
||||
{
|
||||
CopyIn(t);
|
||||
}
|
||||
|
||||
private void CopyIn(MD2Digest t)
|
||||
{
|
||||
Array.Copy(t.X, 0, X, 0, t.X.Length);
|
||||
xOff = t.xOff;
|
||||
Array.Copy(t.M, 0, M, 0, t.M.Length);
|
||||
mOff = t.mOff;
|
||||
Array.Copy(t.C, 0, C, 0, t.C.Length);
|
||||
COff = t.COff;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the algorithm name
|
||||
*
|
||||
* @return the algorithm name
|
||||
*/
|
||||
public string AlgorithmName
|
||||
{
|
||||
get { return "MD2"; }
|
||||
}
|
||||
|
||||
public int GetDigestSize()
|
||||
{
|
||||
return DigestLength;
|
||||
}
|
||||
|
||||
public int GetByteLength()
|
||||
{
|
||||
return BYTE_LENGTH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the digest, producing the final digest value. The doFinal
|
||||
* call leaves the digest reset.
|
||||
*
|
||||
* @param out the array the digest is to be copied into.
|
||||
* @param outOff the offset into the out array the digest is to start at.
|
||||
*/
|
||||
public int DoFinal(byte[] output, int outOff)
|
||||
{
|
||||
// add padding
|
||||
byte paddingByte = (byte)(M.Length - mOff);
|
||||
for (int i=mOff;i<M.Length;i++)
|
||||
{
|
||||
M[i] = paddingByte;
|
||||
}
|
||||
//do final check sum
|
||||
ProcessChecksum(M);
|
||||
// do final block process
|
||||
ProcessBlock(M);
|
||||
|
||||
ProcessBlock(C);
|
||||
|
||||
Array.Copy(X, xOff, output, outOff, 16);
|
||||
|
||||
Reset();
|
||||
|
||||
return DigestLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the digest back to it's initial state.
|
||||
*/
|
||||
public void Reset()
|
||||
{
|
||||
xOff = 0;
|
||||
for (int i = 0; i != X.Length; i++)
|
||||
{
|
||||
X[i] = 0;
|
||||
}
|
||||
mOff = 0;
|
||||
for (int i = 0; i != M.Length; i++)
|
||||
{
|
||||
M[i] = 0;
|
||||
}
|
||||
COff = 0;
|
||||
for (int i = 0; i != C.Length; i++)
|
||||
{
|
||||
C[i] = 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* update the message digest with a single byte.
|
||||
*
|
||||
* @param in the input byte to be entered.
|
||||
*/
|
||||
public void Update(byte input)
|
||||
{
|
||||
M[mOff++] = input;
|
||||
|
||||
if (mOff == 16)
|
||||
{
|
||||
ProcessChecksum(M);
|
||||
ProcessBlock(M);
|
||||
mOff = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* update the message digest with a block of bytes.
|
||||
*
|
||||
* @param in the byte array containing the data.
|
||||
* @param inOff the offset into the byte array where the data starts.
|
||||
* @param len the length of the data.
|
||||
*/
|
||||
public void BlockUpdate(byte[] input, int inOff, int length)
|
||||
{
|
||||
//
|
||||
// fill the current word
|
||||
//
|
||||
while ((mOff != 0) && (length > 0))
|
||||
{
|
||||
Update(input[inOff]);
|
||||
inOff++;
|
||||
length--;
|
||||
}
|
||||
|
||||
//
|
||||
// process whole words.
|
||||
//
|
||||
while (length > 16)
|
||||
{
|
||||
Array.Copy(input,inOff,M,0,16);
|
||||
ProcessChecksum(M);
|
||||
ProcessBlock(M);
|
||||
length -= 16;
|
||||
inOff += 16;
|
||||
}
|
||||
|
||||
//
|
||||
// load in the remainder.
|
||||
//
|
||||
while (length > 0)
|
||||
{
|
||||
Update(input[inOff]);
|
||||
inOff++;
|
||||
length--;
|
||||
}
|
||||
}
|
||||
|
||||
internal void ProcessChecksum(byte[] m)
|
||||
{
|
||||
int L = C[15];
|
||||
for (int i=0;i<16;i++)
|
||||
{
|
||||
C[i] ^= S[(m[i] ^ L) & 0xff];
|
||||
L = C[i];
|
||||
}
|
||||
}
|
||||
internal void ProcessBlock(byte[] m)
|
||||
{
|
||||
for (int i=0;i<16;i++)
|
||||
{
|
||||
X[i+16] = m[i];
|
||||
X[i+32] = (byte)(m[i] ^ X[i]);
|
||||
}
|
||||
// encrypt block
|
||||
int t = 0;
|
||||
|
||||
for (int j=0;j<18;j++)
|
||||
{
|
||||
for (int k=0;k<48;k++)
|
||||
{
|
||||
t = X[k] ^= S[t];
|
||||
t = t & 0xff;
|
||||
}
|
||||
t = (t + j)%256;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 256-byte random permutation constructed from the digits of PI
|
||||
private static readonly byte[] S = {
|
||||
(byte)41,(byte)46,(byte)67,(byte)201,(byte)162,(byte)216,(byte)124,
|
||||
(byte)1,(byte)61,(byte)54,(byte)84,(byte)161,(byte)236,(byte)240,
|
||||
(byte)6,(byte)19,(byte)98,(byte)167,(byte)5,(byte)243,(byte)192,
|
||||
(byte)199,(byte)115,(byte)140,(byte)152,(byte)147,(byte)43,(byte)217,
|
||||
(byte)188,(byte)76,(byte)130,(byte)202,(byte)30,(byte)155,(byte)87,
|
||||
(byte)60,(byte)253,(byte)212,(byte)224,(byte)22,(byte)103,(byte)66,
|
||||
(byte)111,(byte)24,(byte)138,(byte)23,(byte)229,(byte)18,(byte)190,
|
||||
(byte)78,(byte)196,(byte)214,(byte)218,(byte)158,(byte)222,(byte)73,
|
||||
(byte)160,(byte)251,(byte)245,(byte)142,(byte)187,(byte)47,(byte)238,
|
||||
(byte)122,(byte)169,(byte)104,(byte)121,(byte)145,(byte)21,(byte)178,
|
||||
(byte)7,(byte)63,(byte)148,(byte)194,(byte)16,(byte)137,(byte)11,
|
||||
(byte)34,(byte)95,(byte)33,(byte)128,(byte)127,(byte)93,(byte)154,
|
||||
(byte)90,(byte)144,(byte)50,(byte)39,(byte)53,(byte)62,(byte)204,
|
||||
(byte)231,(byte)191,(byte)247,(byte)151,(byte)3,(byte)255,(byte)25,
|
||||
(byte)48,(byte)179,(byte)72,(byte)165,(byte)181,(byte)209,(byte)215,
|
||||
(byte)94,(byte)146,(byte)42,(byte)172,(byte)86,(byte)170,(byte)198,
|
||||
(byte)79,(byte)184,(byte)56,(byte)210,(byte)150,(byte)164,(byte)125,
|
||||
(byte)182,(byte)118,(byte)252,(byte)107,(byte)226,(byte)156,(byte)116,
|
||||
(byte)4,(byte)241,(byte)69,(byte)157,(byte)112,(byte)89,(byte)100,
|
||||
(byte)113,(byte)135,(byte)32,(byte)134,(byte)91,(byte)207,(byte)101,
|
||||
(byte)230,(byte)45,(byte)168,(byte)2,(byte)27,(byte)96,(byte)37,
|
||||
(byte)173,(byte)174,(byte)176,(byte)185,(byte)246,(byte)28,(byte)70,
|
||||
(byte)97,(byte)105,(byte)52,(byte)64,(byte)126,(byte)15,(byte)85,
|
||||
(byte)71,(byte)163,(byte)35,(byte)221,(byte)81,(byte)175,(byte)58,
|
||||
(byte)195,(byte)92,(byte)249,(byte)206,(byte)186,(byte)197,(byte)234,
|
||||
(byte)38,(byte)44,(byte)83,(byte)13,(byte)110,(byte)133,(byte)40,
|
||||
(byte)132, 9,(byte)211,(byte)223,(byte)205,(byte)244,(byte)65,
|
||||
(byte)129,(byte)77,(byte)82,(byte)106,(byte)220,(byte)55,(byte)200,
|
||||
(byte)108,(byte)193,(byte)171,(byte)250,(byte)36,(byte)225,(byte)123,
|
||||
(byte)8,(byte)12,(byte)189,(byte)177,(byte)74,(byte)120,(byte)136,
|
||||
(byte)149,(byte)139,(byte)227,(byte)99,(byte)232,(byte)109,(byte)233,
|
||||
(byte)203,(byte)213,(byte)254,(byte)59,(byte)0,(byte)29,(byte)57,
|
||||
(byte)242,(byte)239,(byte)183,(byte)14,(byte)102,(byte)88,(byte)208,
|
||||
(byte)228,(byte)166,(byte)119,(byte)114,(byte)248,(byte)235,(byte)117,
|
||||
(byte)75,(byte)10,(byte)49,(byte)68,(byte)80,(byte)180,(byte)143,
|
||||
(byte)237,(byte)31,(byte)26,(byte)219,(byte)153,(byte)141,(byte)51,
|
||||
(byte)159,(byte)17,(byte)131,(byte)20
|
||||
};
|
||||
|
||||
public IMemoable Copy()
|
||||
{
|
||||
return new MD2Digest(this);
|
||||
}
|
||||
|
||||
public void Reset(IMemoable other)
|
||||
{
|
||||
MD2Digest d = (MD2Digest)other;
|
||||
|
||||
CopyIn(d);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6061c69a145174df39b384456c7cd2d7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
296
Assets/BestHTTP/SecureProtocol/crypto/digests/MD4Digest.cs
Normal file
296
Assets/BestHTTP/SecureProtocol/crypto/digests/MD4Digest.cs
Normal file
@@ -0,0 +1,296 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto.Digests
|
||||
{
|
||||
/**
|
||||
* implementation of MD4 as RFC 1320 by R. Rivest, MIT Laboratory for
|
||||
* Computer Science and RSA Data Security, Inc.
|
||||
* <p>
|
||||
* <b>NOTE</b>: This algorithm is only included for backwards compatibility
|
||||
* with legacy applications, it's not secure, don't use it for anything new!</p>
|
||||
*/
|
||||
public class MD4Digest
|
||||
: GeneralDigest
|
||||
{
|
||||
private const int DigestLength = 16;
|
||||
|
||||
private int H1, H2, H3, H4; // IV's
|
||||
|
||||
private int[] X = new int[16];
|
||||
private int xOff;
|
||||
|
||||
/**
|
||||
* Standard constructor
|
||||
*/
|
||||
public MD4Digest()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor. This will copy the state of the provided
|
||||
* message digest.
|
||||
*/
|
||||
public MD4Digest(MD4Digest t) : base(t)
|
||||
{
|
||||
CopyIn(t);
|
||||
}
|
||||
|
||||
private void CopyIn(MD4Digest t)
|
||||
{
|
||||
base.CopyIn(t);
|
||||
H1 = t.H1;
|
||||
H2 = t.H2;
|
||||
H3 = t.H3;
|
||||
H4 = t.H4;
|
||||
|
||||
Array.Copy(t.X, 0, X, 0, t.X.Length);
|
||||
xOff = t.xOff;
|
||||
}
|
||||
|
||||
public override string AlgorithmName
|
||||
{
|
||||
get { return "MD4"; }
|
||||
}
|
||||
|
||||
public override int GetDigestSize()
|
||||
{
|
||||
return DigestLength;
|
||||
}
|
||||
|
||||
internal override void ProcessWord(
|
||||
byte[] input,
|
||||
int inOff)
|
||||
{
|
||||
X[xOff++] = (input[inOff] & 0xff) | ((input[inOff + 1] & 0xff) << 8)
|
||||
| ((input[inOff + 2] & 0xff) << 16) | ((input[inOff + 3] & 0xff) << 24);
|
||||
|
||||
if (xOff == 16)
|
||||
{
|
||||
ProcessBlock();
|
||||
}
|
||||
}
|
||||
|
||||
internal override void ProcessLength(
|
||||
long bitLength)
|
||||
{
|
||||
if (xOff > 14)
|
||||
{
|
||||
ProcessBlock();
|
||||
}
|
||||
|
||||
X[14] = (int)(bitLength & 0xffffffff);
|
||||
X[15] = (int)((ulong) bitLength >> 32);
|
||||
}
|
||||
|
||||
private void UnpackWord(
|
||||
int word,
|
||||
byte[] outBytes,
|
||||
int outOff)
|
||||
{
|
||||
outBytes[outOff] = (byte)word;
|
||||
outBytes[outOff + 1] = (byte)((uint) word >> 8);
|
||||
outBytes[outOff + 2] = (byte)((uint) word >> 16);
|
||||
outBytes[outOff + 3] = (byte)((uint) word >> 24);
|
||||
}
|
||||
|
||||
public override int DoFinal(
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
Finish();
|
||||
|
||||
UnpackWord(H1, output, outOff);
|
||||
UnpackWord(H2, output, outOff + 4);
|
||||
UnpackWord(H3, output, outOff + 8);
|
||||
UnpackWord(H4, output, outOff + 12);
|
||||
|
||||
Reset();
|
||||
|
||||
return DigestLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the chaining variables to the IV values.
|
||||
*/
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
H1 = unchecked((int) 0x67452301);
|
||||
H2 = unchecked((int) 0xefcdab89);
|
||||
H3 = unchecked((int) 0x98badcfe);
|
||||
H4 = unchecked((int) 0x10325476);
|
||||
|
||||
xOff = 0;
|
||||
|
||||
for (int i = 0; i != X.Length; i++)
|
||||
{
|
||||
X[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// round 1 left rotates
|
||||
//
|
||||
private const int S11 = 3;
|
||||
private const int S12 = 7;
|
||||
private const int S13 = 11;
|
||||
private const int S14 = 19;
|
||||
|
||||
//
|
||||
// round 2 left rotates
|
||||
//
|
||||
private const int S21 = 3;
|
||||
private const int S22 = 5;
|
||||
private const int S23 = 9;
|
||||
private const int S24 = 13;
|
||||
|
||||
//
|
||||
// round 3 left rotates
|
||||
//
|
||||
private const int S31 = 3;
|
||||
private const int S32 = 9;
|
||||
private const int S33 = 11;
|
||||
private const int S34 = 15;
|
||||
|
||||
/*
|
||||
* rotate int x left n bits.
|
||||
*/
|
||||
private int RotateLeft(
|
||||
int x,
|
||||
int n)
|
||||
{
|
||||
return (x << n) | (int) ((uint) x >> (32 - n));
|
||||
}
|
||||
|
||||
/*
|
||||
* F, G, H and I are the basic MD4 functions.
|
||||
*/
|
||||
private int F(
|
||||
int u,
|
||||
int v,
|
||||
int w)
|
||||
{
|
||||
return (u & v) | (~u & w);
|
||||
}
|
||||
|
||||
private int G(
|
||||
int u,
|
||||
int v,
|
||||
int w)
|
||||
{
|
||||
return (u & v) | (u & w) | (v & w);
|
||||
}
|
||||
|
||||
private int H(
|
||||
int u,
|
||||
int v,
|
||||
int w)
|
||||
{
|
||||
return u ^ v ^ w;
|
||||
}
|
||||
|
||||
internal override void ProcessBlock()
|
||||
{
|
||||
int a = H1;
|
||||
int b = H2;
|
||||
int c = H3;
|
||||
int d = H4;
|
||||
|
||||
//
|
||||
// Round 1 - F cycle, 16 times.
|
||||
//
|
||||
a = RotateLeft((a + F(b, c, d) + X[ 0]), S11);
|
||||
d = RotateLeft((d + F(a, b, c) + X[ 1]), S12);
|
||||
c = RotateLeft((c + F(d, a, b) + X[ 2]), S13);
|
||||
b = RotateLeft((b + F(c, d, a) + X[ 3]), S14);
|
||||
a = RotateLeft((a + F(b, c, d) + X[ 4]), S11);
|
||||
d = RotateLeft((d + F(a, b, c) + X[ 5]), S12);
|
||||
c = RotateLeft((c + F(d, a, b) + X[ 6]), S13);
|
||||
b = RotateLeft((b + F(c, d, a) + X[ 7]), S14);
|
||||
a = RotateLeft((a + F(b, c, d) + X[ 8]), S11);
|
||||
d = RotateLeft((d + F(a, b, c) + X[ 9]), S12);
|
||||
c = RotateLeft((c + F(d, a, b) + X[10]), S13);
|
||||
b = RotateLeft((b + F(c, d, a) + X[11]), S14);
|
||||
a = RotateLeft((a + F(b, c, d) + X[12]), S11);
|
||||
d = RotateLeft((d + F(a, b, c) + X[13]), S12);
|
||||
c = RotateLeft((c + F(d, a, b) + X[14]), S13);
|
||||
b = RotateLeft((b + F(c, d, a) + X[15]), S14);
|
||||
|
||||
//
|
||||
// Round 2 - G cycle, 16 times.
|
||||
//
|
||||
a = RotateLeft((a + G(b, c, d) + X[ 0] + 0x5a827999), S21);
|
||||
d = RotateLeft((d + G(a, b, c) + X[ 4] + 0x5a827999), S22);
|
||||
c = RotateLeft((c + G(d, a, b) + X[ 8] + 0x5a827999), S23);
|
||||
b = RotateLeft((b + G(c, d, a) + X[12] + 0x5a827999), S24);
|
||||
a = RotateLeft((a + G(b, c, d) + X[ 1] + 0x5a827999), S21);
|
||||
d = RotateLeft((d + G(a, b, c) + X[ 5] + 0x5a827999), S22);
|
||||
c = RotateLeft((c + G(d, a, b) + X[ 9] + 0x5a827999), S23);
|
||||
b = RotateLeft((b + G(c, d, a) + X[13] + 0x5a827999), S24);
|
||||
a = RotateLeft((a + G(b, c, d) + X[ 2] + 0x5a827999), S21);
|
||||
d = RotateLeft((d + G(a, b, c) + X[ 6] + 0x5a827999), S22);
|
||||
c = RotateLeft((c + G(d, a, b) + X[10] + 0x5a827999), S23);
|
||||
b = RotateLeft((b + G(c, d, a) + X[14] + 0x5a827999), S24);
|
||||
a = RotateLeft((a + G(b, c, d) + X[ 3] + 0x5a827999), S21);
|
||||
d = RotateLeft((d + G(a, b, c) + X[ 7] + 0x5a827999), S22);
|
||||
c = RotateLeft((c + G(d, a, b) + X[11] + 0x5a827999), S23);
|
||||
b = RotateLeft((b + G(c, d, a) + X[15] + 0x5a827999), S24);
|
||||
|
||||
//
|
||||
// Round 3 - H cycle, 16 times.
|
||||
//
|
||||
a = RotateLeft((a + H(b, c, d) + X[ 0] + 0x6ed9eba1), S31);
|
||||
d = RotateLeft((d + H(a, b, c) + X[ 8] + 0x6ed9eba1), S32);
|
||||
c = RotateLeft((c + H(d, a, b) + X[ 4] + 0x6ed9eba1), S33);
|
||||
b = RotateLeft((b + H(c, d, a) + X[12] + 0x6ed9eba1), S34);
|
||||
a = RotateLeft((a + H(b, c, d) + X[ 2] + 0x6ed9eba1), S31);
|
||||
d = RotateLeft((d + H(a, b, c) + X[10] + 0x6ed9eba1), S32);
|
||||
c = RotateLeft((c + H(d, a, b) + X[ 6] + 0x6ed9eba1), S33);
|
||||
b = RotateLeft((b + H(c, d, a) + X[14] + 0x6ed9eba1), S34);
|
||||
a = RotateLeft((a + H(b, c, d) + X[ 1] + 0x6ed9eba1), S31);
|
||||
d = RotateLeft((d + H(a, b, c) + X[ 9] + 0x6ed9eba1), S32);
|
||||
c = RotateLeft((c + H(d, a, b) + X[ 5] + 0x6ed9eba1), S33);
|
||||
b = RotateLeft((b + H(c, d, a) + X[13] + 0x6ed9eba1), S34);
|
||||
a = RotateLeft((a + H(b, c, d) + X[ 3] + 0x6ed9eba1), S31);
|
||||
d = RotateLeft((d + H(a, b, c) + X[11] + 0x6ed9eba1), S32);
|
||||
c = RotateLeft((c + H(d, a, b) + X[ 7] + 0x6ed9eba1), S33);
|
||||
b = RotateLeft((b + H(c, d, a) + X[15] + 0x6ed9eba1), S34);
|
||||
|
||||
H1 += a;
|
||||
H2 += b;
|
||||
H3 += c;
|
||||
H4 += d;
|
||||
|
||||
//
|
||||
// reset the offset and clean out the word buffer.
|
||||
//
|
||||
xOff = 0;
|
||||
for (int i = 0; i != X.Length; i++)
|
||||
{
|
||||
X[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public override IMemoable Copy()
|
||||
{
|
||||
return new MD4Digest(this);
|
||||
}
|
||||
|
||||
public override void Reset(IMemoable other)
|
||||
{
|
||||
MD4Digest d = (MD4Digest)other;
|
||||
|
||||
CopyIn(d);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ca5c384f14e94d6a9a9738abdca3945
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
317
Assets/BestHTTP/SecureProtocol/crypto/digests/MD5Digest.cs
Normal file
317
Assets/BestHTTP/SecureProtocol/crypto/digests/MD5Digest.cs
Normal file
@@ -0,0 +1,317 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Crypto.Utilities;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto.Digests
|
||||
{
|
||||
/**
|
||||
* implementation of MD5 as outlined in "Handbook of Applied Cryptography", pages 346 - 347.
|
||||
*/
|
||||
public class MD5Digest
|
||||
: GeneralDigest
|
||||
{
|
||||
private const int DigestLength = 16;
|
||||
|
||||
private uint H1, H2, H3, H4; // IV's
|
||||
|
||||
private uint[] X = new uint[16];
|
||||
private int xOff;
|
||||
|
||||
public MD5Digest()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor. This will copy the state of the provided
|
||||
* message digest.
|
||||
*/
|
||||
public MD5Digest(MD5Digest t)
|
||||
: base(t)
|
||||
{
|
||||
CopyIn(t);
|
||||
}
|
||||
|
||||
private void CopyIn(MD5Digest t)
|
||||
{
|
||||
base.CopyIn(t);
|
||||
H1 = t.H1;
|
||||
H2 = t.H2;
|
||||
H3 = t.H3;
|
||||
H4 = t.H4;
|
||||
|
||||
Array.Copy(t.X, 0, X, 0, t.X.Length);
|
||||
xOff = t.xOff;
|
||||
}
|
||||
|
||||
public override string AlgorithmName
|
||||
{
|
||||
get { return "MD5"; }
|
||||
}
|
||||
|
||||
public override int GetDigestSize()
|
||||
{
|
||||
return DigestLength;
|
||||
}
|
||||
|
||||
internal override void ProcessWord(
|
||||
byte[] input,
|
||||
int inOff)
|
||||
{
|
||||
X[xOff] = Pack.LE_To_UInt32(input, inOff);
|
||||
|
||||
if (++xOff == 16)
|
||||
{
|
||||
ProcessBlock();
|
||||
}
|
||||
}
|
||||
|
||||
internal override void ProcessLength(
|
||||
long bitLength)
|
||||
{
|
||||
if (xOff > 14)
|
||||
{
|
||||
if (xOff == 15)
|
||||
X[15] = 0;
|
||||
|
||||
ProcessBlock();
|
||||
}
|
||||
|
||||
for (int i = xOff; i < 14; ++i)
|
||||
{
|
||||
X[i] = 0;
|
||||
}
|
||||
|
||||
X[14] = (uint)((ulong)bitLength);
|
||||
X[15] = (uint)((ulong)bitLength >> 32);
|
||||
}
|
||||
|
||||
public override int DoFinal(
|
||||
byte[] output,
|
||||
int outOff)
|
||||
{
|
||||
Finish();
|
||||
|
||||
Pack.UInt32_To_LE(H1, output, outOff);
|
||||
Pack.UInt32_To_LE(H2, output, outOff + 4);
|
||||
Pack.UInt32_To_LE(H3, output, outOff + 8);
|
||||
Pack.UInt32_To_LE(H4, output, outOff + 12);
|
||||
|
||||
Reset();
|
||||
|
||||
return DigestLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* reset the chaining variables to the IV values.
|
||||
*/
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
H1 = 0x67452301;
|
||||
H2 = 0xefcdab89;
|
||||
H3 = 0x98badcfe;
|
||||
H4 = 0x10325476;
|
||||
|
||||
xOff = 0;
|
||||
|
||||
for (int i = 0; i != X.Length; i++)
|
||||
{
|
||||
X[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// round 1 left rotates
|
||||
//
|
||||
private static readonly int S11 = 7;
|
||||
private static readonly int S12 = 12;
|
||||
private static readonly int S13 = 17;
|
||||
private static readonly int S14 = 22;
|
||||
|
||||
//
|
||||
// round 2 left rotates
|
||||
//
|
||||
private static readonly int S21 = 5;
|
||||
private static readonly int S22 = 9;
|
||||
private static readonly int S23 = 14;
|
||||
private static readonly int S24 = 20;
|
||||
|
||||
//
|
||||
// round 3 left rotates
|
||||
//
|
||||
private static readonly int S31 = 4;
|
||||
private static readonly int S32 = 11;
|
||||
private static readonly int S33 = 16;
|
||||
private static readonly int S34 = 23;
|
||||
|
||||
//
|
||||
// round 4 left rotates
|
||||
//
|
||||
private static readonly int S41 = 6;
|
||||
private static readonly int S42 = 10;
|
||||
private static readonly int S43 = 15;
|
||||
private static readonly int S44 = 21;
|
||||
|
||||
/*
|
||||
* rotate int x left n bits.
|
||||
*/
|
||||
private static uint RotateLeft(
|
||||
uint x,
|
||||
int n)
|
||||
{
|
||||
return (x << n) | (x >> (32 - n));
|
||||
}
|
||||
|
||||
/*
|
||||
* F, G, H and I are the basic MD5 functions.
|
||||
*/
|
||||
private static uint F(
|
||||
uint u,
|
||||
uint v,
|
||||
uint w)
|
||||
{
|
||||
return (u & v) | (~u & w);
|
||||
}
|
||||
|
||||
private static uint G(
|
||||
uint u,
|
||||
uint v,
|
||||
uint w)
|
||||
{
|
||||
return (u & w) | (v & ~w);
|
||||
}
|
||||
|
||||
private static uint H(
|
||||
uint u,
|
||||
uint v,
|
||||
uint w)
|
||||
{
|
||||
return u ^ v ^ w;
|
||||
}
|
||||
|
||||
private static uint K(
|
||||
uint u,
|
||||
uint v,
|
||||
uint w)
|
||||
{
|
||||
return v ^ (u | ~w);
|
||||
}
|
||||
|
||||
internal override void ProcessBlock()
|
||||
{
|
||||
uint a = H1;
|
||||
uint b = H2;
|
||||
uint c = H3;
|
||||
uint d = H4;
|
||||
|
||||
//
|
||||
// Round 1 - F cycle, 16 times.
|
||||
//
|
||||
a = RotateLeft((a + F(b, c, d) + X[0] + 0xd76aa478), S11) + b;
|
||||
d = RotateLeft((d + F(a, b, c) + X[1] + 0xe8c7b756), S12) + a;
|
||||
c = RotateLeft((c + F(d, a, b) + X[2] + 0x242070db), S13) + d;
|
||||
b = RotateLeft((b + F(c, d, a) + X[3] + 0xc1bdceee), S14) + c;
|
||||
a = RotateLeft((a + F(b, c, d) + X[4] + 0xf57c0faf), S11) + b;
|
||||
d = RotateLeft((d + F(a, b, c) + X[5] + 0x4787c62a), S12) + a;
|
||||
c = RotateLeft((c + F(d, a, b) + X[6] + 0xa8304613), S13) + d;
|
||||
b = RotateLeft((b + F(c, d, a) + X[7] + 0xfd469501), S14) + c;
|
||||
a = RotateLeft((a + F(b, c, d) + X[8] + 0x698098d8), S11) + b;
|
||||
d = RotateLeft((d + F(a, b, c) + X[9] + 0x8b44f7af), S12) + a;
|
||||
c = RotateLeft((c + F(d, a, b) + X[10] + 0xffff5bb1), S13) + d;
|
||||
b = RotateLeft((b + F(c, d, a) + X[11] + 0x895cd7be), S14) + c;
|
||||
a = RotateLeft((a + F(b, c, d) + X[12] + 0x6b901122), S11) + b;
|
||||
d = RotateLeft((d + F(a, b, c) + X[13] + 0xfd987193), S12) + a;
|
||||
c = RotateLeft((c + F(d, a, b) + X[14] + 0xa679438e), S13) + d;
|
||||
b = RotateLeft((b + F(c, d, a) + X[15] + 0x49b40821), S14) + c;
|
||||
|
||||
//
|
||||
// Round 2 - G cycle, 16 times.
|
||||
//
|
||||
a = RotateLeft((a + G(b, c, d) + X[1] + 0xf61e2562), S21) + b;
|
||||
d = RotateLeft((d + G(a, b, c) + X[6] + 0xc040b340), S22) + a;
|
||||
c = RotateLeft((c + G(d, a, b) + X[11] + 0x265e5a51), S23) + d;
|
||||
b = RotateLeft((b + G(c, d, a) + X[0] + 0xe9b6c7aa), S24) + c;
|
||||
a = RotateLeft((a + G(b, c, d) + X[5] + 0xd62f105d), S21) + b;
|
||||
d = RotateLeft((d + G(a, b, c) + X[10] + 0x02441453), S22) + a;
|
||||
c = RotateLeft((c + G(d, a, b) + X[15] + 0xd8a1e681), S23) + d;
|
||||
b = RotateLeft((b + G(c, d, a) + X[4] + 0xe7d3fbc8), S24) + c;
|
||||
a = RotateLeft((a + G(b, c, d) + X[9] + 0x21e1cde6), S21) + b;
|
||||
d = RotateLeft((d + G(a, b, c) + X[14] + 0xc33707d6), S22) + a;
|
||||
c = RotateLeft((c + G(d, a, b) + X[3] + 0xf4d50d87), S23) + d;
|
||||
b = RotateLeft((b + G(c, d, a) + X[8] + 0x455a14ed), S24) + c;
|
||||
a = RotateLeft((a + G(b, c, d) + X[13] + 0xa9e3e905), S21) + b;
|
||||
d = RotateLeft((d + G(a, b, c) + X[2] + 0xfcefa3f8), S22) + a;
|
||||
c = RotateLeft((c + G(d, a, b) + X[7] + 0x676f02d9), S23) + d;
|
||||
b = RotateLeft((b + G(c, d, a) + X[12] + 0x8d2a4c8a), S24) + c;
|
||||
|
||||
//
|
||||
// Round 3 - H cycle, 16 times.
|
||||
//
|
||||
a = RotateLeft((a + H(b, c, d) + X[5] + 0xfffa3942), S31) + b;
|
||||
d = RotateLeft((d + H(a, b, c) + X[8] + 0x8771f681), S32) + a;
|
||||
c = RotateLeft((c + H(d, a, b) + X[11] + 0x6d9d6122), S33) + d;
|
||||
b = RotateLeft((b + H(c, d, a) + X[14] + 0xfde5380c), S34) + c;
|
||||
a = RotateLeft((a + H(b, c, d) + X[1] + 0xa4beea44), S31) + b;
|
||||
d = RotateLeft((d + H(a, b, c) + X[4] + 0x4bdecfa9), S32) + a;
|
||||
c = RotateLeft((c + H(d, a, b) + X[7] + 0xf6bb4b60), S33) + d;
|
||||
b = RotateLeft((b + H(c, d, a) + X[10] + 0xbebfbc70), S34) + c;
|
||||
a = RotateLeft((a + H(b, c, d) + X[13] + 0x289b7ec6), S31) + b;
|
||||
d = RotateLeft((d + H(a, b, c) + X[0] + 0xeaa127fa), S32) + a;
|
||||
c = RotateLeft((c + H(d, a, b) + X[3] + 0xd4ef3085), S33) + d;
|
||||
b = RotateLeft((b + H(c, d, a) + X[6] + 0x04881d05), S34) + c;
|
||||
a = RotateLeft((a + H(b, c, d) + X[9] + 0xd9d4d039), S31) + b;
|
||||
d = RotateLeft((d + H(a, b, c) + X[12] + 0xe6db99e5), S32) + a;
|
||||
c = RotateLeft((c + H(d, a, b) + X[15] + 0x1fa27cf8), S33) + d;
|
||||
b = RotateLeft((b + H(c, d, a) + X[2] + 0xc4ac5665), S34) + c;
|
||||
|
||||
//
|
||||
// Round 4 - K cycle, 16 times.
|
||||
//
|
||||
a = RotateLeft((a + K(b, c, d) + X[0] + 0xf4292244), S41) + b;
|
||||
d = RotateLeft((d + K(a, b, c) + X[7] + 0x432aff97), S42) + a;
|
||||
c = RotateLeft((c + K(d, a, b) + X[14] + 0xab9423a7), S43) + d;
|
||||
b = RotateLeft((b + K(c, d, a) + X[5] + 0xfc93a039), S44) + c;
|
||||
a = RotateLeft((a + K(b, c, d) + X[12] + 0x655b59c3), S41) + b;
|
||||
d = RotateLeft((d + K(a, b, c) + X[3] + 0x8f0ccc92), S42) + a;
|
||||
c = RotateLeft((c + K(d, a, b) + X[10] + 0xffeff47d), S43) + d;
|
||||
b = RotateLeft((b + K(c, d, a) + X[1] + 0x85845dd1), S44) + c;
|
||||
a = RotateLeft((a + K(b, c, d) + X[8] + 0x6fa87e4f), S41) + b;
|
||||
d = RotateLeft((d + K(a, b, c) + X[15] + 0xfe2ce6e0), S42) + a;
|
||||
c = RotateLeft((c + K(d, a, b) + X[6] + 0xa3014314), S43) + d;
|
||||
b = RotateLeft((b + K(c, d, a) + X[13] + 0x4e0811a1), S44) + c;
|
||||
a = RotateLeft((a + K(b, c, d) + X[4] + 0xf7537e82), S41) + b;
|
||||
d = RotateLeft((d + K(a, b, c) + X[11] + 0xbd3af235), S42) + a;
|
||||
c = RotateLeft((c + K(d, a, b) + X[2] + 0x2ad7d2bb), S43) + d;
|
||||
b = RotateLeft((b + K(c, d, a) + X[9] + 0xeb86d391), S44) + c;
|
||||
|
||||
H1 += a;
|
||||
H2 += b;
|
||||
H3 += c;
|
||||
H4 += d;
|
||||
|
||||
xOff = 0;
|
||||
}
|
||||
|
||||
public override IMemoable Copy()
|
||||
{
|
||||
return new MD5Digest(this);
|
||||
}
|
||||
|
||||
public override void Reset(IMemoable other)
|
||||
{
|
||||
MD5Digest d = (MD5Digest)other;
|
||||
|
||||
CopyIn(d);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1a584ad4cccf459f8bf48f4f66363c0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
Assets/BestHTTP/SecureProtocol/crypto/digests/NullDigest.cs
Normal file
53
Assets/BestHTTP/SecureProtocol/crypto/digests/NullDigest.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Org.BouncyCastle.Crypto.Digests
|
||||
{
|
||||
public class NullDigest : IDigest
|
||||
{
|
||||
private readonly MemoryStream bOut = new MemoryStream();
|
||||
|
||||
public string AlgorithmName
|
||||
{
|
||||
get { return "NULL"; }
|
||||
}
|
||||
|
||||
public int GetByteLength()
|
||||
{
|
||||
// TODO Is this okay?
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int GetDigestSize()
|
||||
{
|
||||
return (int) bOut.Length;
|
||||
}
|
||||
|
||||
public void Update(byte b)
|
||||
{
|
||||
bOut.WriteByte(b);
|
||||
}
|
||||
|
||||
public void BlockUpdate(byte[] inBytes, int inOff, int len)
|
||||
{
|
||||
bOut.Write(inBytes, inOff, len);
|
||||
}
|
||||
|
||||
public int DoFinal(byte[] outBytes, int outOff)
|
||||
{
|
||||
byte[] res = bOut.ToArray();
|
||||
res.CopyTo(outBytes, outOff);
|
||||
Reset();
|
||||
return res.Length;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
bOut.SetLength(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df5f2c0436a404f89b28f1e16f929b69
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user