add all
This commit is contained in:
90
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/crypto/digests/NullDigest.cs
vendored
Normal file
90
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/crypto/digests/NullDigest.cs
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.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 Convert.ToInt32(bOut.Length);
|
||||
}
|
||||
|
||||
public void Update(byte b)
|
||||
{
|
||||
bOut.WriteByte(b);
|
||||
}
|
||||
|
||||
public void BlockUpdate(byte[] inBytes, int inOff, int len)
|
||||
{
|
||||
bOut.Write(inBytes, inOff, len);
|
||||
}
|
||||
|
||||
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
|
||||
public void BlockUpdate(ReadOnlySpan<byte> input)
|
||||
{
|
||||
bOut.Write(input);
|
||||
}
|
||||
#endif
|
||||
|
||||
public int DoFinal(byte[] outBytes, int outOff)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] data = bOut.GetBuffer();
|
||||
int length = Convert.ToInt32(bOut.Length);
|
||||
|
||||
Array.Copy(data, 0, outBytes, outOff, length);
|
||||
|
||||
return length;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
|
||||
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
|
||||
public int DoFinal(Span<byte> output)
|
||||
{
|
||||
try
|
||||
{
|
||||
byte[] data = bOut.GetBuffer();
|
||||
int length = Convert.ToInt32(bOut.Length);
|
||||
|
||||
data.AsSpan(0, length).CopyTo(output);
|
||||
|
||||
return length;
|
||||
}
|
||||
finally
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
bOut.SetLength(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
Reference in New Issue
Block a user