Files
ichni_Official/Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/tls/crypto/TlsHashSink.cs
2026-06-15 18:18:16 +08:00

52 lines
1.2 KiB
C#

#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Tls.Crypto
{
public class TlsHashSink
: BaseOutputStream
{
private readonly TlsHash m_hash;
public TlsHashSink(TlsHash hash)
{
this.m_hash = hash;
}
public virtual TlsHash Hash
{
get { return m_hash; }
}
public override void Write(byte[] buffer, int offset, int count)
{
Streams.ValidateBufferArguments(buffer, offset, count);
if (count > 0)
{
m_hash.Update(buffer, offset, count);
}
}
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
public override void Write(ReadOnlySpan<byte> buffer)
{
if (!buffer.IsEmpty)
{
m_hash.Update(buffer);
}
}
#endif
public override void WriteByte(byte value)
{
m_hash.Update(new byte[]{ value }, 0, 1);
}
}
}
#pragma warning restore
#endif