add all
This commit is contained in:
57
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BaseInputStream.cs
vendored
Normal file
57
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BaseInputStream.cs
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
|
||||
{
|
||||
public abstract class BaseInputStream
|
||||
: Stream
|
||||
{
|
||||
public sealed override bool CanRead { get { return true; } }
|
||||
public sealed override bool CanSeek { get { return false; } }
|
||||
public sealed override bool CanWrite { get { return false; } }
|
||||
|
||||
public sealed override void Flush() {}
|
||||
public sealed override long Length { get { throw new NotSupportedException(); } }
|
||||
public sealed override long Position
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
set { throw new NotSupportedException(); }
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
Streams.ValidateBufferArguments(buffer, offset, count);
|
||||
|
||||
int pos = 0;
|
||||
try
|
||||
{
|
||||
while (pos < count)
|
||||
{
|
||||
int b = ReadByte();
|
||||
if (b < 0)
|
||||
break;
|
||||
|
||||
buffer[offset + pos++] = (byte)b;
|
||||
}
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
if (pos == 0)
|
||||
throw;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
public sealed override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException(); }
|
||||
public sealed override void SetLength(long value) { throw new NotSupportedException(); }
|
||||
public sealed override void Write(byte[] buffer, int offset, int count) { throw new NotSupportedException(); }
|
||||
|
||||
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
|
||||
public override void Write(ReadOnlySpan<byte> buffer) { throw new NotSupportedException(); }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BaseInputStream.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BaseInputStream.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d3c7df3d713db44b8a85441a7f79523
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
49
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BaseOutputStream.cs
vendored
Normal file
49
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BaseOutputStream.cs
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
|
||||
{
|
||||
public abstract class BaseOutputStream
|
||||
: Stream
|
||||
{
|
||||
public sealed override bool CanRead { get { return false; } }
|
||||
public sealed override bool CanSeek { get { return false; } }
|
||||
public sealed override bool CanWrite { get { return true; } }
|
||||
|
||||
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER || (UNITY_2021_2_OR_NEWER && (NET_STANDARD_2_0 || NET_STANDARD_2_1))
|
||||
public override void CopyTo(Stream destination, int bufferSize) { throw new NotSupportedException(); }
|
||||
#endif
|
||||
public override void Flush() {}
|
||||
public sealed override long Length { get { throw new NotSupportedException(); } }
|
||||
public sealed override long Position
|
||||
{
|
||||
get { throw new NotSupportedException(); }
|
||||
set { throw new NotSupportedException(); }
|
||||
}
|
||||
public sealed override int Read(byte[] buffer, int offset, int count) { throw new NotSupportedException(); }
|
||||
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
|
||||
public sealed override int Read(Span<byte> buffer) { throw new NotSupportedException(); }
|
||||
#endif
|
||||
public sealed override long Seek(long offset, SeekOrigin origin) { throw new NotSupportedException(); }
|
||||
public sealed override void SetLength(long value) { throw new NotSupportedException(); }
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
Streams.ValidateBufferArguments(buffer, offset, count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
WriteByte(buffer[offset + i]);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Write(params byte[] buffer)
|
||||
{
|
||||
Write(buffer, 0, buffer.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BaseOutputStream.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BaseOutputStream.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c619d8578417f68448ce7e16e61d6826
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
98
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BinaryReaders.cs
vendored
Normal file
98
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BinaryReaders.cs
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
|
||||
{
|
||||
public static class BinaryReaders
|
||||
{
|
||||
public static byte[] ReadBytesFully(BinaryReader binaryReader, int count)
|
||||
{
|
||||
byte[] bytes = binaryReader.ReadBytes(count);
|
||||
if (bytes == null || bytes.Length != count)
|
||||
throw new EndOfStreamException();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static short ReadInt16BigEndian(BinaryReader binaryReader)
|
||||
{
|
||||
short n = binaryReader.ReadInt16();
|
||||
return BitConverter.IsLittleEndian ? Shorts.ReverseBytes(n) : n;
|
||||
}
|
||||
|
||||
public static short ReadInt16LittleEndian(BinaryReader binaryReader)
|
||||
{
|
||||
short n = binaryReader.ReadInt16();
|
||||
return BitConverter.IsLittleEndian ? n : Shorts.ReverseBytes(n);
|
||||
}
|
||||
|
||||
public static int ReadInt32BigEndian(BinaryReader binaryReader)
|
||||
{
|
||||
int n = binaryReader.ReadInt32();
|
||||
return BitConverter.IsLittleEndian ? Integers.ReverseBytes(n) : n;
|
||||
}
|
||||
|
||||
public static int ReadInt32LittleEndian(BinaryReader binaryReader)
|
||||
{
|
||||
int n = binaryReader.ReadInt32();
|
||||
return BitConverter.IsLittleEndian ? n : Integers.ReverseBytes(n);
|
||||
}
|
||||
|
||||
public static long ReadInt64BigEndian(BinaryReader binaryReader)
|
||||
{
|
||||
long n = binaryReader.ReadInt64();
|
||||
return BitConverter.IsLittleEndian ? Longs.ReverseBytes(n) : n;
|
||||
}
|
||||
|
||||
public static long ReadInt64LittleEndian(BinaryReader binaryReader)
|
||||
{
|
||||
long n = binaryReader.ReadInt64();
|
||||
return BitConverter.IsLittleEndian ? n : Longs.ReverseBytes(n);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static ushort ReadUInt16BigEndian(BinaryReader binaryReader)
|
||||
{
|
||||
ushort n = binaryReader.ReadUInt16();
|
||||
return BitConverter.IsLittleEndian ? Shorts.ReverseBytes(n) : n;
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static ushort ReadUInt16LittleEndian(BinaryReader binaryReader)
|
||||
{
|
||||
ushort n = binaryReader.ReadUInt16();
|
||||
return BitConverter.IsLittleEndian ? n : Shorts.ReverseBytes(n);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static uint ReadUInt32BigEndian(BinaryReader binaryReader)
|
||||
{
|
||||
uint n = binaryReader.ReadUInt32();
|
||||
return BitConverter.IsLittleEndian ? Integers.ReverseBytes(n) : n;
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static uint ReadUInt32LittleEndian(BinaryReader binaryReader)
|
||||
{
|
||||
uint n = binaryReader.ReadUInt32();
|
||||
return BitConverter.IsLittleEndian ? n : Integers.ReverseBytes(n);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static ulong ReadUInt64BigEndian(BinaryReader binaryReader)
|
||||
{
|
||||
ulong n = binaryReader.ReadUInt64();
|
||||
return BitConverter.IsLittleEndian ? Longs.ReverseBytes(n) : n;
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static ulong ReadUInt64LittleEndian(BinaryReader binaryReader)
|
||||
{
|
||||
ulong n = binaryReader.ReadUInt64();
|
||||
return BitConverter.IsLittleEndian ? n : Longs.ReverseBytes(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BinaryReaders.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BinaryReaders.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fce3edadd1191454491f938ec31dd95c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
90
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BinaryWriters.cs
vendored
Normal file
90
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BinaryWriters.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;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
|
||||
{
|
||||
public static class BinaryWriters
|
||||
{
|
||||
public static void WriteInt16BigEndian(BinaryWriter binaryWriter, short n)
|
||||
{
|
||||
short bigEndian = BitConverter.IsLittleEndian ? Shorts.ReverseBytes(n) : n;
|
||||
binaryWriter.Write(bigEndian);
|
||||
}
|
||||
|
||||
public static void WriteInt16LittleEndian(BinaryWriter binaryWriter, short n)
|
||||
{
|
||||
short littleEndian = BitConverter.IsLittleEndian ? n : Shorts.ReverseBytes(n);
|
||||
binaryWriter.Write(littleEndian);
|
||||
}
|
||||
|
||||
public static void WriteInt32BigEndian(BinaryWriter binaryWriter, int n)
|
||||
{
|
||||
int bigEndian = BitConverter.IsLittleEndian ? Integers.ReverseBytes(n) : n;
|
||||
binaryWriter.Write(bigEndian);
|
||||
}
|
||||
|
||||
public static void WriteInt32LittleEndian(BinaryWriter binaryWriter, int n)
|
||||
{
|
||||
int littleEndian = BitConverter.IsLittleEndian ? n : Integers.ReverseBytes(n);
|
||||
binaryWriter.Write(littleEndian);
|
||||
}
|
||||
|
||||
public static void WriteInt64BigEndian(BinaryWriter binaryWriter, long n)
|
||||
{
|
||||
long bigEndian = BitConverter.IsLittleEndian ? Longs.ReverseBytes(n) : n;
|
||||
binaryWriter.Write(bigEndian);
|
||||
}
|
||||
|
||||
public static void WriteInt64LittleEndian(BinaryWriter binaryWriter, long n)
|
||||
{
|
||||
long littleEndian = BitConverter.IsLittleEndian ? n : Longs.ReverseBytes(n);
|
||||
binaryWriter.Write(littleEndian);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static void WriteUInt16BigEndian(BinaryWriter binaryWriter, ushort n)
|
||||
{
|
||||
ushort bigEndian = BitConverter.IsLittleEndian ? Shorts.ReverseBytes(n) : n;
|
||||
binaryWriter.Write(bigEndian);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static void WriteUInt16LittleEndian(BinaryWriter binaryWriter, ushort n)
|
||||
{
|
||||
ushort littleEndian = BitConverter.IsLittleEndian ? n : Shorts.ReverseBytes(n);
|
||||
binaryWriter.Write(littleEndian);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static void WriteUInt32BigEndian(BinaryWriter binaryWriter, uint n)
|
||||
{
|
||||
uint bigEndian = BitConverter.IsLittleEndian ? Integers.ReverseBytes(n) : n;
|
||||
binaryWriter.Write(bigEndian);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static void WriteUInt32LittleEndian(BinaryWriter binaryWriter, uint n)
|
||||
{
|
||||
uint littleEndian = BitConverter.IsLittleEndian ? n : Integers.ReverseBytes(n);
|
||||
binaryWriter.Write(littleEndian);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static void WriteUInt64BigEndian(BinaryWriter binaryWriter, ulong n)
|
||||
{
|
||||
ulong bigEndian = BitConverter.IsLittleEndian ? Longs.ReverseBytes(n) : n;
|
||||
binaryWriter.Write(bigEndian);
|
||||
}
|
||||
|
||||
[CLSCompliant(false)]
|
||||
public static void WriteUInt64LittleEndian(BinaryWriter binaryWriter, ulong n)
|
||||
{
|
||||
ulong littleEndian = BitConverter.IsLittleEndian ? n : Longs.ReverseBytes(n);
|
||||
binaryWriter.Write(littleEndian);
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BinaryWriters.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/BinaryWriters.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49d753068f0ab3840b50807d6fd9efbd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
100
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/FilterStream.cs
vendored
Normal file
100
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/FilterStream.cs
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
|
||||
{
|
||||
public class FilterStream
|
||||
: Stream
|
||||
{
|
||||
protected readonly Stream s;
|
||||
|
||||
public FilterStream(Stream s)
|
||||
{
|
||||
this.s = s ?? throw new ArgumentNullException(nameof(s));
|
||||
}
|
||||
public override bool CanRead
|
||||
{
|
||||
get { return s.CanRead; }
|
||||
}
|
||||
public override bool CanSeek
|
||||
{
|
||||
get { return s.CanSeek; }
|
||||
}
|
||||
public override bool CanWrite
|
||||
{
|
||||
get { return s.CanWrite; }
|
||||
}
|
||||
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER || (UNITY_2021_2_OR_NEWER && (NET_STANDARD_2_0 || NET_STANDARD_2_1))
|
||||
public override void CopyTo(Stream destination, int bufferSize)
|
||||
{
|
||||
s.CopyTo(destination, bufferSize);
|
||||
}
|
||||
#endif
|
||||
public override void Flush()
|
||||
{
|
||||
s.Flush();
|
||||
}
|
||||
public override long Length
|
||||
{
|
||||
get { return s.Length; }
|
||||
}
|
||||
public override long Position
|
||||
{
|
||||
get { return s.Position; }
|
||||
set { s.Position = value; }
|
||||
}
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
return s.Read(buffer, offset, count);
|
||||
}
|
||||
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
|
||||
public override int Read(Span<byte> buffer)
|
||||
{
|
||||
return s.Read(buffer);
|
||||
}
|
||||
#endif
|
||||
public override int ReadByte()
|
||||
{
|
||||
return s.ReadByte();
|
||||
}
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
return s.Seek(offset, origin);
|
||||
}
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
s.SetLength(value);
|
||||
}
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
s.Write(buffer, offset, count);
|
||||
}
|
||||
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
|
||||
public override void Write(ReadOnlySpan<byte> buffer)
|
||||
{
|
||||
s.Write(buffer);
|
||||
}
|
||||
#endif
|
||||
public override void WriteByte(byte value)
|
||||
{
|
||||
s.WriteByte(value);
|
||||
}
|
||||
protected void Detach(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
s.Dispose();
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/FilterStream.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/FilterStream.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed3b3b33e3d5f8341af1407e24495b36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
60
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/LimitedInputStream.cs
vendored
Normal file
60
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/LimitedInputStream.cs
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.Zlib;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
|
||||
{
|
||||
internal class LimitedInputStream
|
||||
: BaseInputStream
|
||||
{
|
||||
private readonly Stream m_stream;
|
||||
private long m_limit;
|
||||
|
||||
internal LimitedInputStream(Stream stream, long limit)
|
||||
{
|
||||
this.m_stream = stream;
|
||||
this.m_limit = limit;
|
||||
}
|
||||
|
||||
internal long CurrentLimit => m_limit;
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
int numRead = m_stream.Read(buffer, offset, count);
|
||||
if (numRead > 0)
|
||||
{
|
||||
if ((m_limit -= numRead) < 0)
|
||||
throw new StreamOverflowException("Data Overflow");
|
||||
}
|
||||
return numRead;
|
||||
}
|
||||
|
||||
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
|
||||
public override int Read(Span<byte> buffer)
|
||||
{
|
||||
int numRead = m_stream.Read(buffer);
|
||||
if (numRead > 0)
|
||||
{
|
||||
if ((m_limit -= numRead) < 0)
|
||||
throw new StreamOverflowException("Data Overflow");
|
||||
}
|
||||
return numRead;
|
||||
}
|
||||
#endif
|
||||
|
||||
public override int ReadByte()
|
||||
{
|
||||
int b = m_stream.ReadByte();
|
||||
if (b >= 0)
|
||||
{
|
||||
if (--m_limit < 0)
|
||||
throw new StreamOverflowException("Data Overflow");
|
||||
}
|
||||
return b;
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/LimitedInputStream.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/LimitedInputStream.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b259dfe1ec7b794982f204a725915cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/MemoryInputStream.cs
vendored
Normal file
23
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/MemoryInputStream.cs
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
|
||||
{
|
||||
public class MemoryInputStream
|
||||
: MemoryStream
|
||||
{
|
||||
public MemoryInputStream(byte[] buffer)
|
||||
: base(buffer, false)
|
||||
{
|
||||
}
|
||||
|
||||
public sealed override bool CanWrite
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/MemoryInputStream.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/MemoryInputStream.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93486c9465c55d544b217d49d89e769f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
18
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/MemoryOutputStream.cs
vendored
Normal file
18
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/MemoryOutputStream.cs
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
|
||||
{
|
||||
public class MemoryOutputStream
|
||||
: MemoryStream
|
||||
{
|
||||
public sealed override bool CanRead
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/MemoryOutputStream.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/MemoryOutputStream.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c8434b188ea1394f9eea7856c6d502f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
87
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/PushbackStream.cs
vendored
Normal file
87
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/PushbackStream.cs
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
|
||||
{
|
||||
public class PushbackStream
|
||||
: FilterStream
|
||||
{
|
||||
private int m_buf = -1;
|
||||
|
||||
public PushbackStream(Stream s)
|
||||
: base(s)
|
||||
{
|
||||
}
|
||||
|
||||
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER || (UNITY_2021_2_OR_NEWER && (NET_STANDARD_2_0 || NET_STANDARD_2_1))
|
||||
public override void CopyTo(Stream destination, int bufferSize)
|
||||
{
|
||||
if (m_buf != -1)
|
||||
{
|
||||
destination.WriteByte((byte)m_buf);
|
||||
m_buf = -1;
|
||||
}
|
||||
|
||||
s.CopyTo(destination, bufferSize);
|
||||
}
|
||||
#endif
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
Streams.ValidateBufferArguments(buffer, offset, count);
|
||||
|
||||
if (m_buf != -1)
|
||||
{
|
||||
if (count < 1)
|
||||
return 0;
|
||||
|
||||
buffer[offset] = (byte)m_buf;
|
||||
m_buf = -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return s.Read(buffer, offset, count);
|
||||
}
|
||||
|
||||
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
|
||||
public override int Read(Span<byte> buffer)
|
||||
{
|
||||
if (m_buf != -1)
|
||||
{
|
||||
if (buffer.IsEmpty)
|
||||
return 0;
|
||||
|
||||
buffer[0] = (byte)m_buf;
|
||||
m_buf = -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return s.Read(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
public override int ReadByte()
|
||||
{
|
||||
if (m_buf != -1)
|
||||
{
|
||||
int tmp = m_buf;
|
||||
m_buf = -1;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
return base.ReadByte();
|
||||
}
|
||||
|
||||
public virtual void Unread(int b)
|
||||
{
|
||||
if (m_buf != -1)
|
||||
throw new InvalidOperationException("Can only push back one byte");
|
||||
|
||||
m_buf = b & 0xFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/PushbackStream.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/PushbackStream.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f19db2f73dd28f4fb543d28d35a6034
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/StreamOverflowException.cs
vendored
Normal file
35
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/StreamOverflowException.cs
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
|
||||
{
|
||||
[Serializable]
|
||||
public class StreamOverflowException
|
||||
: IOException
|
||||
{
|
||||
public StreamOverflowException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public StreamOverflowException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public StreamOverflowException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
protected StreamOverflowException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 279bdd2eefacecb4287bfa1cdb0dd4eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
140
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/Streams.cs
vendored
Normal file
140
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/Streams.cs
vendored
Normal file
@@ -0,0 +1,140 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
|
||||
{
|
||||
public static class Streams
|
||||
{
|
||||
private const int BufferSize = 4096;
|
||||
|
||||
public static void Drain(Stream inStr)
|
||||
{
|
||||
inStr.CopyTo(Stream.Null, BufferSize);
|
||||
}
|
||||
|
||||
/// <summary>Write the full contents of inStr to the destination stream outStr.</summary>
|
||||
/// <param name="inStr">Source stream.</param>
|
||||
/// <param name="outStr">Destination stream.</param>
|
||||
/// <exception cref="IOException">In case of IO failure.</exception>
|
||||
public static void PipeAll(Stream inStr, Stream outStr)
|
||||
{
|
||||
inStr.CopyTo(outStr, BufferSize);
|
||||
}
|
||||
|
||||
/// <summary>Write the full contents of inStr to the destination stream outStr.</summary>
|
||||
/// <param name="inStr">Source stream.</param>
|
||||
/// <param name="outStr">Destination stream.</param>
|
||||
/// <param name="bufferSize">The size of temporary buffer to use.</param>
|
||||
/// <exception cref="IOException">In case of IO failure.</exception>
|
||||
public static void PipeAll(Stream inStr, Stream outStr, int bufferSize)
|
||||
{
|
||||
inStr.CopyTo(outStr, bufferSize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pipe all bytes from <c>inStr</c> to <c>outStr</c>, throwing <c>StreamFlowException</c> if greater
|
||||
/// than <c>limit</c> bytes in <c>inStr</c>.
|
||||
/// </summary>
|
||||
/// <param name="inStr">
|
||||
/// A <see cref="Stream"/>
|
||||
/// </param>
|
||||
/// <param name="limit">
|
||||
/// A <see cref="System.Int64"/>
|
||||
/// </param>
|
||||
/// <param name="outStr">
|
||||
/// A <see cref="Stream"/>
|
||||
/// </param>
|
||||
/// <returns>The number of bytes actually transferred, if not greater than <c>limit</c></returns>
|
||||
/// <exception cref="IOException"></exception>
|
||||
public static long PipeAllLimited(Stream inStr, long limit, Stream outStr)
|
||||
{
|
||||
var limited = new LimitedInputStream(inStr, limit);
|
||||
limited.CopyTo(outStr, BufferSize);
|
||||
return limit - limited.CurrentLimit;
|
||||
}
|
||||
|
||||
public static byte[] ReadAll(Stream inStr)
|
||||
{
|
||||
MemoryStream buf = new MemoryStream();
|
||||
PipeAll(inStr, buf);
|
||||
return buf.ToArray();
|
||||
}
|
||||
|
||||
public static byte[] ReadAll(MemoryStream inStr)
|
||||
{
|
||||
return inStr.ToArray();
|
||||
}
|
||||
|
||||
public static byte[] ReadAllLimited(Stream inStr, int limit)
|
||||
{
|
||||
MemoryStream buf = new MemoryStream();
|
||||
PipeAllLimited(inStr, limit, buf);
|
||||
return buf.ToArray();
|
||||
}
|
||||
|
||||
public static int ReadFully(Stream inStr, byte[] buf)
|
||||
{
|
||||
return ReadFully(inStr, buf, 0, buf.Length);
|
||||
}
|
||||
|
||||
public static int ReadFully(Stream inStr, byte[] buf, int off, int len)
|
||||
{
|
||||
int totalRead = 0;
|
||||
while (totalRead < len)
|
||||
{
|
||||
int numRead = inStr.Read(buf, off + totalRead, len - totalRead);
|
||||
if (numRead < 1)
|
||||
break;
|
||||
totalRead += numRead;
|
||||
}
|
||||
return totalRead;
|
||||
}
|
||||
|
||||
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
|
||||
public static int ReadFully(Stream inStr, Span<byte> buffer)
|
||||
{
|
||||
int totalRead = 0;
|
||||
while (totalRead < buffer.Length)
|
||||
{
|
||||
int numRead = inStr.Read(buffer[totalRead..]);
|
||||
if (numRead < 1)
|
||||
break;
|
||||
totalRead += numRead;
|
||||
}
|
||||
return totalRead;
|
||||
}
|
||||
#endif
|
||||
|
||||
public static void ValidateBufferArguments(byte[] buffer, int offset, int count)
|
||||
{
|
||||
if (buffer == null)
|
||||
throw new ArgumentNullException("buffer");
|
||||
int available = buffer.Length - offset;
|
||||
if ((offset | available) < 0)
|
||||
throw new ArgumentOutOfRangeException("offset");
|
||||
int remaining = available - count;
|
||||
if ((count | remaining) < 0)
|
||||
throw new ArgumentOutOfRangeException("count");
|
||||
}
|
||||
|
||||
/// <exception cref="IOException"></exception>
|
||||
public static int WriteBufTo(MemoryStream buf, byte[] output, int offset)
|
||||
{
|
||||
#if NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
|
||||
if (buf.TryGetBuffer(out var buffer))
|
||||
{
|
||||
buffer.CopyTo(output, offset);
|
||||
return buffer.Count;
|
||||
}
|
||||
#endif
|
||||
|
||||
int size = Convert.ToInt32(buf.Length);
|
||||
buf.WriteTo(new MemoryStream(output, offset, size));
|
||||
return size;
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/Streams.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/Streams.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7089ea257ba29894db3af5eb53489c91
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
73
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/TeeInputStream.cs
vendored
Normal file
73
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/TeeInputStream.cs
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
|
||||
{
|
||||
public class TeeInputStream
|
||||
: BaseInputStream
|
||||
{
|
||||
private readonly Stream input, tee;
|
||||
|
||||
public TeeInputStream(Stream input, Stream tee)
|
||||
{
|
||||
Debug.Assert(input.CanRead);
|
||||
Debug.Assert(tee.CanWrite);
|
||||
|
||||
this.input = input;
|
||||
this.tee = tee;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
input.Dispose();
|
||||
tee.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
int i = input.Read(buffer, offset, count);
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
tee.Write(buffer, offset, i);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
|
||||
public override int Read(Span<byte> buffer)
|
||||
{
|
||||
int i = input.Read(buffer);
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
tee.Write(buffer[..i]);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
#endif
|
||||
|
||||
public override int ReadByte()
|
||||
{
|
||||
int i = input.ReadByte();
|
||||
|
||||
if (i >= 0)
|
||||
{
|
||||
tee.WriteByte((byte)i);
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/TeeInputStream.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/TeeInputStream.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78f1188bec8f1ac42a3c7d91c1a30268
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
55
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/TeeOutputStream.cs
vendored
Normal file
55
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/TeeOutputStream.cs
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO
|
||||
{
|
||||
public class TeeOutputStream
|
||||
: BaseOutputStream
|
||||
{
|
||||
private readonly Stream output, tee;
|
||||
|
||||
public TeeOutputStream(Stream output, Stream tee)
|
||||
{
|
||||
Debug.Assert(output.CanWrite);
|
||||
Debug.Assert(tee.CanWrite);
|
||||
|
||||
this.output = output;
|
||||
this.tee = tee;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
output.Dispose();
|
||||
tee.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
output.Write(buffer, offset, count);
|
||||
tee.Write(buffer, offset, count);
|
||||
}
|
||||
|
||||
#if NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || UNITY_2021_2_OR_NEWER
|
||||
public override void Write(ReadOnlySpan<byte> buffer)
|
||||
{
|
||||
output.Write(buffer);
|
||||
tee.Write(buffer);
|
||||
}
|
||||
#endif
|
||||
|
||||
public override void WriteByte(byte value)
|
||||
{
|
||||
output.WriteByte(value);
|
||||
tee.WriteByte(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/TeeOutputStream.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/TeeOutputStream.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee01e6fa38384014894902dca90d9f07
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/compression.meta
vendored
Normal file
8
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/compression.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e481329737ea54c449534183e8a444cb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/compression/Bzip2.cs
vendored
Normal file
25
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/compression/Bzip2.cs
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO.Compression
|
||||
{
|
||||
using Impl = Utilities.Bzip2;
|
||||
|
||||
internal static class Bzip2
|
||||
{
|
||||
internal static Stream CompressOutput(Stream stream, bool leaveOpen = false)
|
||||
{
|
||||
return leaveOpen
|
||||
? new Impl.CBZip2OutputStreamLeaveOpen(stream)
|
||||
: new Impl.CBZip2OutputStream(stream);
|
||||
}
|
||||
|
||||
internal static Stream DecompressInput(Stream stream)
|
||||
{
|
||||
return new Impl.CBZip2InputStream(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/compression/Bzip2.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/compression/Bzip2.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d04b453ee61d0b549821205ed981a483
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/compression/ZLib.cs
vendored
Normal file
50
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/compression/ZLib.cs
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System.IO;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using System.IO.Compression;
|
||||
#else
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.Zlib;
|
||||
#endif
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO.Compression
|
||||
{
|
||||
internal static class ZLib
|
||||
{
|
||||
internal static Stream CompressOutput(Stream stream, int zlibCompressionLevel, bool leaveOpen = false)
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return new ZLibStream(stream, GetCompressionLevel(zlibCompressionLevel), leaveOpen);
|
||||
#else
|
||||
return leaveOpen
|
||||
? new ZOutputStreamLeaveOpen(stream, zlibCompressionLevel, false)
|
||||
: new ZOutputStream(stream, zlibCompressionLevel, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
internal static Stream DecompressInput(Stream stream)
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return new ZLibStream(stream, CompressionMode.Decompress, leaveOpen: false);
|
||||
#else
|
||||
return new ZInputStream(stream);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
internal static CompressionLevel GetCompressionLevel(int zlibCompressionLevel)
|
||||
{
|
||||
return zlibCompressionLevel switch
|
||||
{
|
||||
0 => CompressionLevel.NoCompression,
|
||||
1 or 2 or 3 => CompressionLevel.Fastest,
|
||||
7 or 8 or 9 => CompressionLevel.SmallestSize,
|
||||
_ => CompressionLevel.Optimal,
|
||||
};
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/compression/ZLib.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/compression/ZLib.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0af16ed78741a14c88aa3b66f6d4b2f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
37
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/compression/Zip.cs
vendored
Normal file
37
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/compression/Zip.cs
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System.IO;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
using System.IO.Compression;
|
||||
#else
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.Zlib;
|
||||
#endif
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO.Compression
|
||||
{
|
||||
internal static class Zip
|
||||
{
|
||||
internal static Stream CompressOutput(Stream stream, int zlibCompressionLevel, bool leaveOpen = false)
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return new DeflateStream(stream, ZLib.GetCompressionLevel(zlibCompressionLevel), leaveOpen);
|
||||
#else
|
||||
return leaveOpen
|
||||
? new ZOutputStreamLeaveOpen(stream, zlibCompressionLevel, true)
|
||||
: new ZOutputStream(stream, zlibCompressionLevel, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
internal static Stream DecompressInput(Stream stream)
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return new DeflateStream(stream, CompressionMode.Decompress, leaveOpen: false);
|
||||
#else
|
||||
return new ZInputStream(stream, true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/compression/Zip.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/compression/Zip.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 398602b3dbbd7f1458ca04870a4452ed
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem.meta
vendored
Normal file
8
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52264ae1689071e4b86aff6fadb9d9a2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO.Pem
|
||||
{
|
||||
[Serializable]
|
||||
public class PemGenerationException
|
||||
: Exception
|
||||
{
|
||||
public PemGenerationException()
|
||||
: base()
|
||||
{
|
||||
}
|
||||
|
||||
public PemGenerationException(string message)
|
||||
: base(message)
|
||||
{
|
||||
}
|
||||
|
||||
public PemGenerationException(string message, Exception innerException)
|
||||
: base(message, innerException)
|
||||
{
|
||||
}
|
||||
|
||||
protected PemGenerationException(SerializationInfo info, StreamingContext context)
|
||||
: base(info, context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54711797ae622c84188cfbb9a5cae97a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
64
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemHeader.cs
vendored
Normal file
64
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemHeader.cs
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO.Pem
|
||||
{
|
||||
public class PemHeader
|
||||
{
|
||||
private string name;
|
||||
private string val;
|
||||
|
||||
public PemHeader(string name, string val)
|
||||
{
|
||||
this.name = name;
|
||||
this.val = val;
|
||||
}
|
||||
|
||||
public virtual string Name
|
||||
{
|
||||
get { return name; }
|
||||
}
|
||||
|
||||
public virtual string Value
|
||||
{
|
||||
get { return val; }
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return GetHashCode(this.name) + 31 * GetHashCode(this.val);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == this)
|
||||
return true;
|
||||
|
||||
if (!(obj is PemHeader))
|
||||
return false;
|
||||
|
||||
PemHeader other = (PemHeader)obj;
|
||||
|
||||
return Org.BouncyCastle.Utilities.Platform.Equals(this.name, other.name)
|
||||
&& Org.BouncyCastle.Utilities.Platform.Equals(this.val, other.val);
|
||||
}
|
||||
|
||||
private int GetHashCode(string s)
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return s.GetHashCode();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return name + ":" + val;
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemHeader.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemHeader.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b892c40614a572f45af1714e78837483
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
49
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemObject.cs
vendored
Normal file
49
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemObject.cs
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO.Pem
|
||||
{
|
||||
public class PemObject
|
||||
: PemObjectGenerator
|
||||
{
|
||||
private string type;
|
||||
private IList<PemHeader> headers;
|
||||
private byte[] content;
|
||||
|
||||
public PemObject(string type, byte[] content)
|
||||
: this(type, new List<PemHeader>(), content)
|
||||
{
|
||||
}
|
||||
|
||||
public PemObject(string type, IList<PemHeader> headers, byte[] content)
|
||||
{
|
||||
this.type = type;
|
||||
this.headers = new List<PemHeader>(headers);
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public string Type
|
||||
{
|
||||
get { return type; }
|
||||
}
|
||||
|
||||
public IList<PemHeader> Headers
|
||||
{
|
||||
get { return headers; }
|
||||
}
|
||||
|
||||
public byte[] Content
|
||||
{
|
||||
get { return content; }
|
||||
}
|
||||
|
||||
public PemObject Generate()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemObject.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemObject.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4bce1d1ba4bf69e488437b0eb0f8e357
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemObjectGenerator.cs
vendored
Normal file
17
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemObjectGenerator.cs
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO.Pem
|
||||
{
|
||||
public interface PemObjectGenerator
|
||||
{
|
||||
/// <returns>
|
||||
/// A <see cref="PemObject"/>
|
||||
/// </returns>
|
||||
/// <exception cref="PemGenerationException"></exception>
|
||||
PemObject Generate();
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e16ccade6df2b64db6108492c8f51cb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemObjectParser.cs
vendored
Normal file
21
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemObjectParser.cs
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO.Pem
|
||||
{
|
||||
public interface PemObjectParser
|
||||
{
|
||||
/// <param name="obj">
|
||||
/// A <see cref="PemObject"/>
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// An <see cref="object"/>
|
||||
/// </returns>
|
||||
/// <exception cref="IOException"></exception>
|
||||
object ParseObject(PemObject obj);
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemObjectParser.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemObjectParser.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d60aad74ea940284c9e74e43ba83c881
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
377
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemReader.cs
vendored
Normal file
377
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemReader.cs
vendored
Normal file
@@ -0,0 +1,377 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.Encoders;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO.Pem
|
||||
{
|
||||
public class PemReader
|
||||
: IDisposable
|
||||
{
|
||||
private readonly TextReader reader;
|
||||
private readonly MemoryStream buffer;
|
||||
private readonly StreamWriter textBuffer;
|
||||
private readonly List<int> pushback = new List<int>();
|
||||
int c = 0;
|
||||
|
||||
public PemReader(TextReader reader)
|
||||
{
|
||||
this.reader = reader ?? throw new ArgumentNullException(nameof(reader));
|
||||
this.buffer = new MemoryStream();
|
||||
this.textBuffer = new StreamWriter(buffer);
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
reader.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public TextReader Reader
|
||||
{
|
||||
get { return reader; }
|
||||
}
|
||||
|
||||
|
||||
/// <returns>
|
||||
/// A <see cref="PemObject"/>
|
||||
/// </returns>
|
||||
/// <exception cref="IOException"></exception>
|
||||
public PemObject ReadPemObject()
|
||||
{
|
||||
|
||||
//
|
||||
// Look for BEGIN
|
||||
//
|
||||
|
||||
for (;;)
|
||||
{
|
||||
|
||||
// Seek a leading dash, ignore anything up to that point.
|
||||
if (!seekDash())
|
||||
{
|
||||
// There are no pem objects here.
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// consume dash [-----]BEGIN ...
|
||||
if (!consumeDash())
|
||||
{
|
||||
throw new IOException("no data after consuming leading dashes");
|
||||
}
|
||||
|
||||
|
||||
skipWhiteSpace();
|
||||
|
||||
|
||||
if (!expect("BEGIN"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
skipWhiteSpace();
|
||||
|
||||
//
|
||||
// Consume type, accepting whitespace
|
||||
//
|
||||
|
||||
if (!bufferUntilStopChar('-',false) )
|
||||
{
|
||||
throw new IOException("ran out of data before consuming type");
|
||||
}
|
||||
|
||||
string type = bufferedString().Trim();
|
||||
|
||||
|
||||
// Consume dashes after type.
|
||||
|
||||
if (!consumeDash())
|
||||
{
|
||||
throw new IOException("ran out of data consuming header");
|
||||
}
|
||||
|
||||
skipWhiteSpace();
|
||||
|
||||
|
||||
//
|
||||
// Read ahead looking for headers.
|
||||
// Look for a colon for up to 64 characters, as an indication there might be a header.
|
||||
//
|
||||
|
||||
var headers = new List<PemHeader>();
|
||||
|
||||
while (seekColon(64))
|
||||
{
|
||||
|
||||
if (!bufferUntilStopChar(':',false))
|
||||
{
|
||||
throw new IOException("ran out of data reading header key value");
|
||||
}
|
||||
|
||||
string key = bufferedString().Trim();
|
||||
|
||||
|
||||
c = Read();
|
||||
if (c != ':')
|
||||
{
|
||||
throw new IOException("expected colon");
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// We are going to look for well formed headers, if they do not end with a "LF" we cannot
|
||||
// discern where they end.
|
||||
//
|
||||
|
||||
if (!bufferUntilStopChar('\n', false)) // Now read to the end of the line.
|
||||
{
|
||||
throw new IOException("ran out of data before consuming header value");
|
||||
}
|
||||
|
||||
skipWhiteSpace();
|
||||
|
||||
string value = bufferedString().Trim();
|
||||
headers.Add(new PemHeader(key,value));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Consume payload, ignoring all white space until we encounter a '-'
|
||||
//
|
||||
|
||||
skipWhiteSpace();
|
||||
|
||||
if (!bufferUntilStopChar('-',true))
|
||||
{
|
||||
throw new IOException("ran out of data before consuming payload");
|
||||
}
|
||||
|
||||
string payload = bufferedString();
|
||||
|
||||
// Seek the start of the end.
|
||||
if (!seekDash())
|
||||
{
|
||||
throw new IOException("did not find leading '-'");
|
||||
}
|
||||
|
||||
if (!consumeDash())
|
||||
{
|
||||
throw new IOException("no data after consuming trailing dashes");
|
||||
}
|
||||
|
||||
if (!expect("END "+type))
|
||||
{
|
||||
throw new IOException("END "+type+" was not found.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!seekDash())
|
||||
{
|
||||
throw new IOException("did not find ending '-'");
|
||||
}
|
||||
|
||||
|
||||
// consume trailing dashes.
|
||||
consumeDash();
|
||||
|
||||
|
||||
return new PemObject(type, headers, Base64.Decode(payload));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private string bufferedString()
|
||||
{
|
||||
textBuffer.Flush();
|
||||
string value = Strings.FromUtf8ByteArray(buffer.ToArray());
|
||||
buffer.Position = 0;
|
||||
buffer.SetLength(0);
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
private bool seekDash()
|
||||
{
|
||||
c = 0;
|
||||
while((c = Read()) >=0)
|
||||
{
|
||||
if (c == '-')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PushBack(c);
|
||||
|
||||
return c == '-';
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Seek ':" up to the limit.
|
||||
/// </summary>
|
||||
/// <param name="upTo"></param>
|
||||
/// <returns></returns>
|
||||
private bool seekColon(int upTo)
|
||||
{
|
||||
c = 0;
|
||||
bool colonFound = false;
|
||||
var read = new List<int>();
|
||||
|
||||
for (; upTo>=0 && c >=0; upTo--)
|
||||
{
|
||||
c = Read();
|
||||
read.Add(c);
|
||||
if (c == ':')
|
||||
{
|
||||
colonFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while(read.Count>0)
|
||||
{
|
||||
PushBack((int)read[read.Count-1]);
|
||||
read.RemoveAt(read.Count-1);
|
||||
}
|
||||
|
||||
return colonFound;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Consume the dashes
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool consumeDash()
|
||||
{
|
||||
c = 0;
|
||||
while ((c = Read()) >= 0)
|
||||
{
|
||||
if (c != '-')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
PushBack(c);
|
||||
|
||||
return c != -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Skip white space leave char in stream.
|
||||
/// </summary>
|
||||
private void skipWhiteSpace()
|
||||
{
|
||||
while ((c = Read()) >= 0)
|
||||
{
|
||||
if (c > ' ')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
PushBack(c);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read forward consuming the expected string.
|
||||
/// </summary>
|
||||
/// <param name="value">expected string</param>
|
||||
/// <returns>false if not consumed</returns>
|
||||
|
||||
private bool expect(string value)
|
||||
{
|
||||
for (int t=0; t<value.Length; t++)
|
||||
{
|
||||
c = Read();
|
||||
if (c == value[t])
|
||||
{
|
||||
continue;
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Consume until dash.
|
||||
/// </summary>
|
||||
/// <returns>true if stream end not met</returns>
|
||||
private bool bufferUntilStopChar(char stopChar, bool skipWhiteSpace)
|
||||
{
|
||||
while ((c = Read()) >= 0)
|
||||
{
|
||||
if (skipWhiteSpace && c <=' ')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (c != stopChar)
|
||||
{
|
||||
textBuffer.Write((char)c);
|
||||
textBuffer.Flush();
|
||||
|
||||
} else
|
||||
{
|
||||
PushBack(c);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return c > -1;
|
||||
}
|
||||
|
||||
private void PushBack(int value)
|
||||
{
|
||||
if (pushback.Count == 0)
|
||||
{
|
||||
pushback.Add(value);
|
||||
} else
|
||||
{
|
||||
pushback.Insert(0, value);
|
||||
}
|
||||
}
|
||||
|
||||
private int Read()
|
||||
{
|
||||
if (pushback.Count > 0)
|
||||
{
|
||||
int i = pushback[0];
|
||||
pushback.RemoveAt(0);
|
||||
return i;
|
||||
}
|
||||
|
||||
return reader.Read();
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemReader.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemReader.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 09f2d56aaf05d0c4583f2e055172290e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
139
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemWriter.cs
vendored
Normal file
139
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemWriter.cs
vendored
Normal file
@@ -0,0 +1,139 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.Encoders;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.IO.Pem
|
||||
{
|
||||
/**
|
||||
* A generic PEM writer, based on RFC 1421
|
||||
*/
|
||||
public class PemWriter
|
||||
: IDisposable
|
||||
{
|
||||
private const int LineLength = 64;
|
||||
|
||||
private readonly TextWriter writer;
|
||||
private readonly int nlLength;
|
||||
private char[] buf = new char[LineLength];
|
||||
|
||||
/**
|
||||
* Base constructor.
|
||||
*
|
||||
* @param out output stream to use.
|
||||
*/
|
||||
public PemWriter(TextWriter writer)
|
||||
{
|
||||
this.writer = writer ?? throw new ArgumentNullException(nameof(writer));
|
||||
this.nlLength = Environment.NewLine.Length;
|
||||
}
|
||||
|
||||
#region IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
writer.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public TextWriter Writer
|
||||
{
|
||||
get { return writer; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of bytes or characters required to contain the
|
||||
* passed in object if it is PEM encoded.
|
||||
*
|
||||
* @param obj pem object to be output
|
||||
* @return an estimate of the number of bytes
|
||||
*/
|
||||
public int GetOutputSize(PemObject obj)
|
||||
{
|
||||
// BEGIN and END boundaries.
|
||||
int size = (2 * (obj.Type.Length + 10 + nlLength)) + 6 + 4;
|
||||
|
||||
if (obj.Headers.Count > 0)
|
||||
{
|
||||
foreach (PemHeader header in obj.Headers)
|
||||
{
|
||||
size += header.Name.Length + ": ".Length + header.Value.Length + nlLength;
|
||||
}
|
||||
|
||||
size += nlLength;
|
||||
}
|
||||
|
||||
// base64 encoding
|
||||
int dataLen = ((obj.Content.Length + 2) / 3) * 4;
|
||||
|
||||
size += dataLen + (((dataLen + LineLength - 1) / LineLength) * nlLength);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
public void WriteObject(PemObjectGenerator objGen)
|
||||
{
|
||||
PemObject obj = objGen.Generate();
|
||||
|
||||
WritePreEncapsulationBoundary(obj.Type);
|
||||
|
||||
if (obj.Headers.Count > 0)
|
||||
{
|
||||
foreach (PemHeader header in obj.Headers)
|
||||
{
|
||||
writer.Write(header.Name);
|
||||
writer.Write(": ");
|
||||
writer.WriteLine(header.Value);
|
||||
}
|
||||
|
||||
writer.WriteLine();
|
||||
}
|
||||
|
||||
WriteEncoded(obj.Content);
|
||||
WritePostEncapsulationBoundary(obj.Type);
|
||||
}
|
||||
|
||||
private void WriteEncoded(byte[] bytes)
|
||||
{
|
||||
bytes = Base64.Encode(bytes);
|
||||
|
||||
for (int i = 0; i < bytes.Length; i += buf.Length)
|
||||
{
|
||||
int index = 0;
|
||||
while (index != buf.Length)
|
||||
{
|
||||
if ((i + index) >= bytes.Length)
|
||||
break;
|
||||
|
||||
buf[index] = (char)bytes[i + index];
|
||||
index++;
|
||||
}
|
||||
writer.WriteLine(buf, 0, index);
|
||||
}
|
||||
}
|
||||
|
||||
private void WritePreEncapsulationBoundary(string type)
|
||||
{
|
||||
writer.WriteLine("-----BEGIN " + type + "-----");
|
||||
}
|
||||
|
||||
private void WritePostEncapsulationBoundary(string type)
|
||||
{
|
||||
writer.WriteLine("-----END " + type + "-----");
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemWriter.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/util/io/pem/PemWriter.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bf98bac36d6fa7478399f9c8df01ab7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user