- Initial commit

This commit is contained in:
Timur Kozanov
2026-07-03 05:02:26 +03:00
commit 374ff1e689
4080 changed files with 388870 additions and 0 deletions

View File

@ -0,0 +1,107 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
using System;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Nist
{
/// <summary>
/// KMACwithSHAKE128-params ::= SEQUENCE {
/// kMACOutputLength INTEGER DEFAULT 256, -- Output length in bits
/// customizationString OCTET STRING DEFAULT ''H
/// }
/// </summary>
public class KMacWithShake128Params : Asn1Encodable
{
private static readonly byte[] EMPTY_STRING = new byte[0];
private static readonly int DEF_LENGTH = 256;
private readonly int outputLength;
private readonly byte[] customizationString;
public KMacWithShake128Params(int outputLength)
{
this.outputLength = outputLength;
this.customizationString = EMPTY_STRING;
}
public KMacWithShake128Params(int outputLength, byte[] customizationString)
{
this.outputLength = outputLength;
this.customizationString = Arrays.Clone(customizationString);
}
public static KMacWithShake128Params GetInstance(object o)
{
if (o is KMacWithShake128Params)
{
return (KMacWithShake128Params)o;
}
else if (o != null)
{
return new KMacWithShake128Params(Asn1Sequence.GetInstance(o));
}
return null;
}
private KMacWithShake128Params(Asn1Sequence seq)
{
if (seq.Count > 2)
throw new InvalidOperationException("sequence size greater than 2");
if (seq.Count == 2)
{
this.outputLength = DerInteger.GetInstance(seq[0]).IntValueExact;
this.customizationString = Arrays.Clone(Asn1OctetString.GetInstance(seq[1]).GetOctets());
}
else if (seq.Count == 1)
{
if (seq[0] is DerInteger)
{
this.outputLength = DerInteger.GetInstance(seq[0]).IntValueExact;
this.customizationString = EMPTY_STRING;
}
else
{
this.outputLength = DEF_LENGTH;
this.customizationString = Arrays.Clone(Asn1OctetString.GetInstance(seq[0]).GetOctets());
}
}
else
{
this.outputLength = DEF_LENGTH;
this.customizationString = EMPTY_STRING;
}
}
public int OutputLength
{
get { return outputLength; }
}
public byte[] CustomizationString
{
get { return Arrays.Clone(customizationString); }
}
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector();
if (outputLength != DEF_LENGTH)
{
v.Add(new DerInteger(outputLength));
}
if (customizationString.Length != 0)
{
v.Add(new DerOctetString(CustomizationString));
}
return new DerSequence(v);
}
}
}
#pragma warning restore
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: a24c9896b5be4c04caafa46c3e526a34
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 267636
packageName: Best HTTP
packageVersion: 3.0.17
assetPath: Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/asn1/nist/KMACwithSHAKE128_params.cs
uploadId: 783279

View File

@ -0,0 +1,106 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
using System;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Nist
{
/// <summary>
/// KMACwithSHAKE256-params ::= SEQUENCE {
/// kMACOutputLength INTEGER DEFAULT 512, -- Output length in bits
/// customizationString OCTET STRING DEFAULT ''H
/// }
/// </summary>
public class KMacWithShake256Params : Asn1Encodable
{
private static readonly byte[] EMPTY_STRING = new byte[0];
private static readonly int DEF_LENGTH = 512;
private readonly int outputLength;
private readonly byte[] customizationString;
public KMacWithShake256Params(int outputLength)
{
this.outputLength = outputLength;
this.customizationString = EMPTY_STRING;
}
public KMacWithShake256Params(int outputLength, byte[] customizationString)
{
this.outputLength = outputLength;
this.customizationString = Arrays.Clone(customizationString);
}
public static KMacWithShake256Params GetInstance(object o)
{
if (o is KMacWithShake256Params)
{
return (KMacWithShake256Params)o;
}
else if (o != null)
{
return new KMacWithShake256Params(Asn1Sequence.GetInstance(o));
}
return null;
}
private KMacWithShake256Params(Asn1Sequence seq)
{
if (seq.Count > 2)
throw new InvalidOperationException("sequence size greater than 2");
if (seq.Count == 2)
{
this.outputLength = DerInteger.GetInstance(seq[0]).IntValueExact;
this.customizationString = Arrays.Clone(Asn1OctetString.GetInstance(seq[1]).GetOctets());
}
else if (seq.Count == 1)
{
if (seq[0] is DerInteger)
{
this.outputLength = DerInteger.GetInstance(seq[0]).IntValueExact;
this.customizationString = EMPTY_STRING;
}
else
{
this.outputLength = DEF_LENGTH;
this.customizationString = Arrays.Clone(Asn1OctetString.GetInstance(seq[0]).GetOctets());
}
}
else
{
this.outputLength = DEF_LENGTH;
this.customizationString = EMPTY_STRING;
}
}
public int OutputLength
{
get { return outputLength; }
}
public byte[] CustomizationString
{
get { return Arrays.Clone(customizationString); }
}
public override Asn1Object ToAsn1Object()
{
Asn1EncodableVector v = new Asn1EncodableVector();
if (outputLength != DEF_LENGTH)
{
v.Add(new DerInteger(outputLength));
}
if (customizationString.Length != 0)
{
v.Add(new DerOctetString(CustomizationString));
}
return new DerSequence(v);
}
}
}
#pragma warning restore
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 08f572fdeff008f4ca702197b266273f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 267636
packageName: Best HTTP
packageVersion: 3.0.17
assetPath: Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/asn1/nist/KMACwithSHAKE256_params.cs
uploadId: 783279

View File

@ -0,0 +1,112 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using System;
using System.Collections.Generic;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Sec;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X9;
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities.Collections;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Nist
{
/// <summary>Elliptic curve registry for NIST curves.</summary>
public static class NistNamedCurves
{
private static readonly Dictionary<string, DerObjectIdentifier> objIds =
new Dictionary<string, DerObjectIdentifier>(StringComparer.OrdinalIgnoreCase);
private static readonly Dictionary<DerObjectIdentifier, string> names =
new Dictionary<DerObjectIdentifier, string>();
private static void DefineCurveAlias(string name, DerObjectIdentifier oid)
{
if (SecNamedCurves.GetByOidLazy(oid) == null)
throw new InvalidOperationException();
objIds.Add(name, oid);
names.Add(oid, name);
}
static NistNamedCurves()
{
DefineCurveAlias("B-163", SecObjectIdentifiers.SecT163r2);
DefineCurveAlias("B-233", SecObjectIdentifiers.SecT233r1);
DefineCurveAlias("B-283", SecObjectIdentifiers.SecT283r1);
DefineCurveAlias("B-409", SecObjectIdentifiers.SecT409r1);
DefineCurveAlias("B-571", SecObjectIdentifiers.SecT571r1);
DefineCurveAlias("K-163", SecObjectIdentifiers.SecT163k1);
DefineCurveAlias("K-233", SecObjectIdentifiers.SecT233k1);
DefineCurveAlias("K-283", SecObjectIdentifiers.SecT283k1);
DefineCurveAlias("K-409", SecObjectIdentifiers.SecT409k1);
DefineCurveAlias("K-571", SecObjectIdentifiers.SecT571k1);
DefineCurveAlias("P-192", SecObjectIdentifiers.SecP192r1);
DefineCurveAlias("P-224", SecObjectIdentifiers.SecP224r1);
DefineCurveAlias("P-256", SecObjectIdentifiers.SecP256r1);
DefineCurveAlias("P-384", SecObjectIdentifiers.SecP384r1);
DefineCurveAlias("P-521", SecObjectIdentifiers.SecP521r1);
}
/// <summary>Look up the <see cref="X9ECParameters"/> for the curve with the given name.</summary>
/// <param name="name">The name of the curve.</param>
public static X9ECParameters GetByName(string name)
{
DerObjectIdentifier oid = GetOid(name);
return oid == null ? null : GetByOid(oid);
}
/// <summary>Look up an <see cref="X9ECParametersHolder"/> for the curve with the given name.</summary>
/// <remarks>
/// Allows accessing the <see cref="Math.EC.ECCurve">curve</see> without necessarily triggering the creation of
/// the full <see cref="X9ECParameters"/>.
/// </remarks>
/// <param name="name">The name of the curve.</param>
public static X9ECParametersHolder GetByNameLazy(string name)
{
DerObjectIdentifier oid = GetOid(name);
return oid == null ? null : GetByOidLazy(oid);
}
/// <summary>Look up the <see cref="X9ECParameters"/> for the curve with the given
/// <see cref="DerObjectIdentifier">OID</see>.</summary>
/// <param name="oid">The <see cref="DerObjectIdentifier">OID</see> for the curve.</param>
public static X9ECParameters GetByOid(DerObjectIdentifier oid)
{
return GetByOidLazy(oid)?.Parameters;
}
/// <summary>Look up an <see cref="X9ECParametersHolder"/> for the curve with the given
/// <see cref="DerObjectIdentifier">OID</see>.</summary>
/// <remarks>
/// Allows accessing the <see cref="Math.EC.ECCurve">curve</see> without necessarily triggering the creation of
/// the full <see cref="X9ECParameters"/>.
/// </remarks>
/// <param name="oid">The <see cref="DerObjectIdentifier">OID</see> for the curve.</param>
public static X9ECParametersHolder GetByOidLazy(DerObjectIdentifier oid)
{
return names.ContainsKey(oid) ? SecNamedCurves.GetByOidLazy(oid) : null;
}
/// <summary>Look up the name of the curve with the given <see cref="DerObjectIdentifier">OID</see>.</summary>
/// <param name="oid">The <see cref="DerObjectIdentifier">OID</see> for the curve.</param>
public static string GetName(DerObjectIdentifier oid)
{
return CollectionUtilities.GetValueOrNull(names, oid);
}
/// <summary>Look up the <see cref="DerObjectIdentifier">OID</see> of the curve with the given name.</summary>
/// <param name="name">The name of the curve.</param>
public static DerObjectIdentifier GetOid(string name)
{
return CollectionUtilities.GetValueOrNull(objIds, name);
}
/// <summary>Enumerate the available curve names in this registry.</summary>
public static IEnumerable<string> Names
{
get { return CollectionUtilities.Proxy(objIds.Keys); }
}
}
}
#pragma warning restore
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: b6f4d35ad37f26942a3e1fe948e58516
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 267636
packageName: Best HTTP
packageVersion: 3.0.17
assetPath: Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/asn1/nist/NISTNamedCurves.cs
uploadId: 783279

View File

@ -0,0 +1,112 @@
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
#pragma warning disable
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1;
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Nist
{
public sealed class NistObjectIdentifiers
{
private NistObjectIdentifiers()
{
}
//
// NIST
// iso/itu(2) joint-assign(16) us(840) organization(1) gov(101) csor(3)
//
// nistalgorithms(4)
//
public static readonly DerObjectIdentifier NistAlgorithm = new DerObjectIdentifier("2.16.840.1.101.3.4");
public static readonly DerObjectIdentifier HashAlgs = NistAlgorithm.Branch("2");
public static readonly DerObjectIdentifier IdSha256 = HashAlgs.Branch("1");
public static readonly DerObjectIdentifier IdSha384 = HashAlgs.Branch("2");
public static readonly DerObjectIdentifier IdSha512 = HashAlgs.Branch("3");
public static readonly DerObjectIdentifier IdSha224 = HashAlgs.Branch("4");
public static readonly DerObjectIdentifier IdSha512_224 = HashAlgs.Branch("5");
public static readonly DerObjectIdentifier IdSha512_256 = HashAlgs.Branch("6");
public static readonly DerObjectIdentifier IdSha3_224 = HashAlgs.Branch("7");
public static readonly DerObjectIdentifier IdSha3_256 = HashAlgs.Branch("8");
public static readonly DerObjectIdentifier IdSha3_384 = HashAlgs.Branch("9");
public static readonly DerObjectIdentifier IdSha3_512 = HashAlgs.Branch("10");
public static readonly DerObjectIdentifier IdShake128 = HashAlgs.Branch("11");
public static readonly DerObjectIdentifier IdShake256 = HashAlgs.Branch("12");
public static readonly DerObjectIdentifier IdHMacWithSha3_224 = HashAlgs.Branch("13");
public static readonly DerObjectIdentifier IdHMacWithSha3_256 = HashAlgs.Branch("14");
public static readonly DerObjectIdentifier IdHMacWithSha3_384 = HashAlgs.Branch("15");
public static readonly DerObjectIdentifier IdHMacWithSha3_512 = HashAlgs.Branch("16");
public static readonly DerObjectIdentifier IdShake128Len = HashAlgs.Branch("17");
public static readonly DerObjectIdentifier IdShake256Len = HashAlgs.Branch("18");
public static readonly DerObjectIdentifier IdKmacWithShake128 = HashAlgs.Branch("19");
public static readonly DerObjectIdentifier IdKmacWithShake256 = HashAlgs.Branch("20");
public static readonly DerObjectIdentifier Aes = new DerObjectIdentifier(NistAlgorithm + ".1");
public static readonly DerObjectIdentifier IdAes128Ecb = new DerObjectIdentifier(Aes + ".1");
public static readonly DerObjectIdentifier IdAes128Cbc = new DerObjectIdentifier(Aes + ".2");
public static readonly DerObjectIdentifier IdAes128Ofb = new DerObjectIdentifier(Aes + ".3");
public static readonly DerObjectIdentifier IdAes128Cfb = new DerObjectIdentifier(Aes + ".4");
public static readonly DerObjectIdentifier IdAes128Wrap = new DerObjectIdentifier(Aes + ".5");
public static readonly DerObjectIdentifier IdAes128Gcm = new DerObjectIdentifier(Aes + ".6");
public static readonly DerObjectIdentifier IdAes128Ccm = new DerObjectIdentifier(Aes + ".7");
public static readonly DerObjectIdentifier IdAes192Ecb = new DerObjectIdentifier(Aes + ".21");
public static readonly DerObjectIdentifier IdAes192Cbc = new DerObjectIdentifier(Aes + ".22");
public static readonly DerObjectIdentifier IdAes192Ofb = new DerObjectIdentifier(Aes + ".23");
public static readonly DerObjectIdentifier IdAes192Cfb = new DerObjectIdentifier(Aes + ".24");
public static readonly DerObjectIdentifier IdAes192Wrap = new DerObjectIdentifier(Aes + ".25");
public static readonly DerObjectIdentifier IdAes192Gcm = new DerObjectIdentifier(Aes + ".26");
public static readonly DerObjectIdentifier IdAes192Ccm = new DerObjectIdentifier(Aes + ".27");
public static readonly DerObjectIdentifier IdAes256Ecb = new DerObjectIdentifier(Aes + ".41");
public static readonly DerObjectIdentifier IdAes256Cbc = new DerObjectIdentifier(Aes + ".42");
public static readonly DerObjectIdentifier IdAes256Ofb = new DerObjectIdentifier(Aes + ".43");
public static readonly DerObjectIdentifier IdAes256Cfb = new DerObjectIdentifier(Aes + ".44");
public static readonly DerObjectIdentifier IdAes256Wrap = new DerObjectIdentifier(Aes + ".45");
public static readonly DerObjectIdentifier IdAes256Gcm = new DerObjectIdentifier(Aes + ".46");
public static readonly DerObjectIdentifier IdAes256Ccm = new DerObjectIdentifier(Aes + ".47");
//
// signatures
//
public static readonly DerObjectIdentifier IdDsaWithSha2 = new DerObjectIdentifier(NistAlgorithm + ".3");
public static readonly DerObjectIdentifier DsaWithSha224 = new DerObjectIdentifier(IdDsaWithSha2 + ".1");
public static readonly DerObjectIdentifier DsaWithSha256 = new DerObjectIdentifier(IdDsaWithSha2 + ".2");
public static readonly DerObjectIdentifier DsaWithSha384 = new DerObjectIdentifier(IdDsaWithSha2 + ".3");
public static readonly DerObjectIdentifier DsaWithSha512 = new DerObjectIdentifier(IdDsaWithSha2 + ".4");
/** 2.16.840.1.101.3.4.3.5 */
public static readonly DerObjectIdentifier IdDsaWithSha3_224 = new DerObjectIdentifier(IdDsaWithSha2 + ".5");
/** 2.16.840.1.101.3.4.3.6 */
public static readonly DerObjectIdentifier IdDsaWithSha3_256 = new DerObjectIdentifier(IdDsaWithSha2 + ".6");
/** 2.16.840.1.101.3.4.3.7 */
public static readonly DerObjectIdentifier IdDsaWithSha3_384 = new DerObjectIdentifier(IdDsaWithSha2 + ".7");
/** 2.16.840.1.101.3.4.3.8 */
public static readonly DerObjectIdentifier IdDsaWithSha3_512 = new DerObjectIdentifier(IdDsaWithSha2 + ".8");
// ECDSA with SHA-3
/** 2.16.840.1.101.3.4.3.9 */
public static readonly DerObjectIdentifier IdEcdsaWithSha3_224 = new DerObjectIdentifier(IdDsaWithSha2 + ".9");
/** 2.16.840.1.101.3.4.3.10 */
public static readonly DerObjectIdentifier IdEcdsaWithSha3_256 = new DerObjectIdentifier(IdDsaWithSha2 + ".10");
/** 2.16.840.1.101.3.4.3.11 */
public static readonly DerObjectIdentifier IdEcdsaWithSha3_384 = new DerObjectIdentifier(IdDsaWithSha2 + ".11");
/** 2.16.840.1.101.3.4.3.12 */
public static readonly DerObjectIdentifier IdEcdsaWithSha3_512 = new DerObjectIdentifier(IdDsaWithSha2 + ".12");
// RSA PKCS #1 v1.5 Signature with SHA-3 family.
/** 2.16.840.1.101.3.4.3.9 */
public static readonly DerObjectIdentifier IdRsassaPkcs1V15WithSha3_224 = new DerObjectIdentifier(IdDsaWithSha2 + ".13");
/** 2.16.840.1.101.3.4.3.10 */
public static readonly DerObjectIdentifier IdRsassaPkcs1V15WithSha3_256 = new DerObjectIdentifier(IdDsaWithSha2 + ".14");
/** 2.16.840.1.101.3.4.3.11 */
public static readonly DerObjectIdentifier IdRsassaPkcs1V15WithSha3_384 = new DerObjectIdentifier(IdDsaWithSha2 + ".15");
/** 2.16.840.1.101.3.4.3.12 */
public static readonly DerObjectIdentifier IdRsassaPkcs1V15WithSha3_512 = new DerObjectIdentifier(IdDsaWithSha2 + ".16");
}
}
#pragma warning restore
#endif

View File

@ -0,0 +1,18 @@
fileFormatVersion: 2
guid: 6056fa0387de90644b8ed0dc77361e4d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 267636
packageName: Best HTTP
packageVersion: 3.0.17
assetPath: Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/asn1/nist/NISTObjectIdentifiers.cs
uploadId: 783279