add all
This commit is contained in:
15
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/ECEndomorphism.cs
vendored
Normal file
15
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/ECEndomorphism.cs
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Endo
|
||||
{
|
||||
public interface ECEndomorphism
|
||||
{
|
||||
ECPointMap PointMap { get; }
|
||||
|
||||
bool HasEfficientPointMap { get; }
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/ECEndomorphism.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/ECEndomorphism.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93385e29ae2625345826e81ec706ef3d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/EndoPreCompInfo.cs
vendored
Normal file
30
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/EndoPreCompInfo.cs
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Multiplier;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Endo
|
||||
{
|
||||
public class EndoPreCompInfo
|
||||
: PreCompInfo
|
||||
{
|
||||
protected ECEndomorphism m_endomorphism;
|
||||
|
||||
protected ECPoint m_mappedPoint;
|
||||
|
||||
public virtual ECEndomorphism Endomorphism
|
||||
{
|
||||
get { return m_endomorphism; }
|
||||
set { this.m_endomorphism = value; }
|
||||
}
|
||||
|
||||
public virtual ECPoint MappedPoint
|
||||
{
|
||||
get { return m_mappedPoint; }
|
||||
set { this.m_mappedPoint = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce9bd5de28dc93c4c998e2e785e856cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
83
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/EndoUtilities.cs
vendored
Normal file
83
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/EndoUtilities.cs
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Multiplier;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Endo
|
||||
{
|
||||
public abstract class EndoUtilities
|
||||
{
|
||||
public static readonly string PRECOMP_NAME = "bc_endo";
|
||||
|
||||
public static BigInteger[] DecomposeScalar(ScalarSplitParameters p, BigInteger k)
|
||||
{
|
||||
int bits = p.Bits;
|
||||
BigInteger b1 = CalculateB(k, p.G1, bits);
|
||||
BigInteger b2 = CalculateB(k, p.G2, bits);
|
||||
|
||||
BigInteger a = k.Subtract((b1.Multiply(p.V1A)).Add(b2.Multiply(p.V2A)));
|
||||
BigInteger b = (b1.Multiply(p.V1B)).Add(b2.Multiply(p.V2B)).Negate();
|
||||
|
||||
return new BigInteger[]{ a, b };
|
||||
}
|
||||
|
||||
public static ECPoint MapPoint(ECEndomorphism endomorphism, ECPoint p)
|
||||
{
|
||||
EndoPreCompInfo precomp = (EndoPreCompInfo)p.Curve.Precompute(p, PRECOMP_NAME,
|
||||
new MapPointCallback(endomorphism, p));
|
||||
return precomp.MappedPoint;
|
||||
}
|
||||
|
||||
private static BigInteger CalculateB(BigInteger k, BigInteger g, int t)
|
||||
{
|
||||
bool negative = (g.SignValue < 0);
|
||||
BigInteger b = k.Multiply(g.Abs());
|
||||
bool extra = b.TestBit(t - 1);
|
||||
b = b.ShiftRight(t);
|
||||
if (extra)
|
||||
{
|
||||
b = b.Add(BigInteger.One);
|
||||
}
|
||||
return negative ? b.Negate() : b;
|
||||
}
|
||||
|
||||
private class MapPointCallback
|
||||
: IPreCompCallback
|
||||
{
|
||||
private readonly ECEndomorphism m_endomorphism;
|
||||
private readonly ECPoint m_point;
|
||||
|
||||
internal MapPointCallback(ECEndomorphism endomorphism, ECPoint point)
|
||||
{
|
||||
this.m_endomorphism = endomorphism;
|
||||
this.m_point = point;
|
||||
}
|
||||
|
||||
public PreCompInfo Precompute(PreCompInfo existing)
|
||||
{
|
||||
EndoPreCompInfo existingEndo = existing as EndoPreCompInfo;
|
||||
|
||||
if (CheckExisting(existingEndo, m_endomorphism))
|
||||
return existingEndo;
|
||||
|
||||
ECPoint mappedPoint = m_endomorphism.PointMap.Map(m_point);
|
||||
|
||||
EndoPreCompInfo result = new EndoPreCompInfo();
|
||||
result.Endomorphism = m_endomorphism;
|
||||
result.MappedPoint = mappedPoint;
|
||||
return result;
|
||||
}
|
||||
|
||||
private bool CheckExisting(EndoPreCompInfo existingEndo, ECEndomorphism endomorphism)
|
||||
{
|
||||
return null != existingEndo
|
||||
&& existingEndo.Endomorphism == endomorphism
|
||||
&& existingEndo.MappedPoint != null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/EndoUtilities.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/EndoUtilities.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6838274c3fe2c5f43af09b73c6568e3a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/GlvEndomorphism.cs
vendored
Normal file
14
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/GlvEndomorphism.cs
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Endo
|
||||
{
|
||||
public interface GlvEndomorphism
|
||||
: ECEndomorphism
|
||||
{
|
||||
BigInteger[] DecomposeScalar(BigInteger k);
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36ab51057b17c4e4e9a32abcfb8009c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Endo
|
||||
{
|
||||
public class GlvTypeAEndomorphism
|
||||
: GlvEndomorphism
|
||||
{
|
||||
protected readonly GlvTypeAParameters m_parameters;
|
||||
protected readonly ECPointMap m_pointMap;
|
||||
|
||||
public GlvTypeAEndomorphism(ECCurve curve, GlvTypeAParameters parameters)
|
||||
{
|
||||
/*
|
||||
* NOTE: 'curve' MUST only be used to create a suitable ECFieldElement. Due to the way
|
||||
* ECCurve configuration works, 'curve' will not be the actual instance of ECCurve that the
|
||||
* endomorphism is being used with.
|
||||
*/
|
||||
|
||||
this.m_parameters = parameters;
|
||||
this.m_pointMap = new ScaleYNegateXPointMap(curve.FromBigInteger(parameters.I));
|
||||
}
|
||||
|
||||
public virtual BigInteger[] DecomposeScalar(BigInteger k)
|
||||
{
|
||||
return EndoUtilities.DecomposeScalar(m_parameters.SplitParams, k);
|
||||
}
|
||||
|
||||
public virtual ECPointMap PointMap
|
||||
{
|
||||
get { return m_pointMap; }
|
||||
}
|
||||
|
||||
public virtual bool HasEfficientPointMap
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f7c44c25321a4d469d593742da9e625
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/GlvTypeAParameters.cs
vendored
Normal file
36
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/GlvTypeAParameters.cs
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Endo
|
||||
{
|
||||
public class GlvTypeAParameters
|
||||
{
|
||||
protected readonly BigInteger m_i, m_lambda;
|
||||
protected readonly ScalarSplitParameters m_splitParams;
|
||||
|
||||
public GlvTypeAParameters(BigInteger i, BigInteger lambda, ScalarSplitParameters splitParams)
|
||||
{
|
||||
this.m_i = i;
|
||||
this.m_lambda = lambda;
|
||||
this.m_splitParams = splitParams;
|
||||
}
|
||||
|
||||
public virtual BigInteger I
|
||||
{
|
||||
get { return m_i; }
|
||||
}
|
||||
|
||||
public virtual BigInteger Lambda
|
||||
{
|
||||
get { return m_lambda; }
|
||||
}
|
||||
|
||||
public virtual ScalarSplitParameters SplitParams
|
||||
{
|
||||
get { return m_splitParams; }
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2849c73ad905e649946a22820b89322
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Endo
|
||||
{
|
||||
public class GlvTypeBEndomorphism
|
||||
: GlvEndomorphism
|
||||
{
|
||||
protected readonly GlvTypeBParameters m_parameters;
|
||||
protected readonly ECPointMap m_pointMap;
|
||||
|
||||
public GlvTypeBEndomorphism(ECCurve curve, GlvTypeBParameters parameters)
|
||||
{
|
||||
/*
|
||||
* NOTE: 'curve' MUST only be used to create a suitable ECFieldElement. Due to the way
|
||||
* ECCurve configuration works, 'curve' will not be the actual instance of ECCurve that the
|
||||
* endomorphism is being used with.
|
||||
*/
|
||||
|
||||
this.m_parameters = parameters;
|
||||
this.m_pointMap = new ScaleXPointMap(curve.FromBigInteger(parameters.Beta));
|
||||
}
|
||||
|
||||
public virtual BigInteger[] DecomposeScalar(BigInteger k)
|
||||
{
|
||||
return EndoUtilities.DecomposeScalar(m_parameters.SplitParams, k);
|
||||
}
|
||||
|
||||
public virtual ECPointMap PointMap
|
||||
{
|
||||
get { return m_pointMap; }
|
||||
}
|
||||
|
||||
public virtual bool HasEfficientPointMap
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae30f7f5f4ea222479a1f46ea5e50d9e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
36
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/GlvTypeBParameters.cs
vendored
Normal file
36
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/math/ec/endo/GlvTypeBParameters.cs
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Endo
|
||||
{
|
||||
public class GlvTypeBParameters
|
||||
{
|
||||
protected readonly BigInteger m_beta, m_lambda;
|
||||
protected readonly ScalarSplitParameters m_splitParams;
|
||||
|
||||
public GlvTypeBParameters(BigInteger beta, BigInteger lambda, ScalarSplitParameters splitParams)
|
||||
{
|
||||
this.m_beta = beta;
|
||||
this.m_lambda = lambda;
|
||||
this.m_splitParams = splitParams;
|
||||
}
|
||||
|
||||
public virtual BigInteger Beta
|
||||
{
|
||||
get { return m_beta; }
|
||||
}
|
||||
|
||||
public virtual BigInteger Lambda
|
||||
{
|
||||
get { return m_lambda; }
|
||||
}
|
||||
|
||||
public virtual ScalarSplitParameters SplitParams
|
||||
{
|
||||
get { return m_splitParams; }
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b10576d8dc860dc4f9cabc458774a32d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Math;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Math.EC.Endo
|
||||
{
|
||||
public class ScalarSplitParameters
|
||||
{
|
||||
private static void CheckVector(BigInteger[] v, string name)
|
||||
{
|
||||
if (v == null || v.Length != 2 || v[0] == null || v[1] == null)
|
||||
throw new ArgumentException("Must consist of exactly 2 (non-null) values", name);
|
||||
}
|
||||
|
||||
protected readonly BigInteger m_v1A, m_v1B, m_v2A, m_v2B;
|
||||
protected readonly BigInteger m_g1, m_g2;
|
||||
protected readonly int m_bits;
|
||||
|
||||
public ScalarSplitParameters(BigInteger[] v1, BigInteger[] v2, BigInteger g1,
|
||||
BigInteger g2, int bits)
|
||||
{
|
||||
CheckVector(v1, "v1");
|
||||
CheckVector(v2, "v2");
|
||||
|
||||
this.m_v1A = v1[0];
|
||||
this.m_v1B = v1[1];
|
||||
this.m_v2A = v2[0];
|
||||
this.m_v2B = v2[1];
|
||||
this.m_g1 = g1;
|
||||
this.m_g2 = g2;
|
||||
this.m_bits = bits;
|
||||
}
|
||||
|
||||
public virtual BigInteger V1A
|
||||
{
|
||||
get { return m_v1A; }
|
||||
}
|
||||
|
||||
public virtual BigInteger V1B
|
||||
{
|
||||
get { return m_v1B; }
|
||||
}
|
||||
|
||||
public virtual BigInteger V2A
|
||||
{
|
||||
get { return m_v2A; }
|
||||
}
|
||||
|
||||
public virtual BigInteger V2B
|
||||
{
|
||||
get { return m_v2B; }
|
||||
}
|
||||
|
||||
public virtual BigInteger G1
|
||||
{
|
||||
get { return m_g1; }
|
||||
}
|
||||
|
||||
public virtual BigInteger G2
|
||||
{
|
||||
get { return m_g2; }
|
||||
}
|
||||
|
||||
public virtual int Bits
|
||||
{
|
||||
get { return m_bits; }
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a14dfe81c3b33ca42847862950b4785c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user