add all
This commit is contained in:
121
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/asn1/sec/ECPrivateKeyStructure.cs
vendored
Normal file
121
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/asn1/sec/ECPrivateKeyStructure.cs
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Math;
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Sec
|
||||
{
|
||||
/**
|
||||
* the elliptic curve private key object from SEC 1
|
||||
*/
|
||||
public class ECPrivateKeyStructure
|
||||
: Asn1Encodable
|
||||
{
|
||||
private readonly Asn1Sequence m_seq;
|
||||
|
||||
public static ECPrivateKeyStructure GetInstance(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
if (obj is ECPrivateKeyStructure ecPrivateKeyStructure)
|
||||
return ecPrivateKeyStructure;
|
||||
return new ECPrivateKeyStructure(Asn1Sequence.GetInstance(obj));
|
||||
}
|
||||
|
||||
private ECPrivateKeyStructure(Asn1Sequence seq)
|
||||
{
|
||||
m_seq = seq ?? throw new ArgumentNullException(nameof(seq));
|
||||
}
|
||||
|
||||
public ECPrivateKeyStructure(
|
||||
int orderBitLength,
|
||||
BigInteger key)
|
||||
: this(orderBitLength, key, null)
|
||||
{
|
||||
}
|
||||
|
||||
public ECPrivateKeyStructure(
|
||||
int orderBitLength,
|
||||
BigInteger key,
|
||||
Asn1Encodable parameters)
|
||||
: this(orderBitLength, key, null, parameters)
|
||||
{
|
||||
}
|
||||
|
||||
public ECPrivateKeyStructure(
|
||||
int orderBitLength,
|
||||
BigInteger key,
|
||||
DerBitString publicKey,
|
||||
Asn1Encodable parameters)
|
||||
{
|
||||
if (key == null)
|
||||
throw new ArgumentNullException(nameof(key));
|
||||
if (orderBitLength < key.BitLength)
|
||||
throw new ArgumentException("must be >= key bitlength", nameof(orderBitLength));
|
||||
|
||||
byte[] bytes = BigIntegers.AsUnsignedByteArray((orderBitLength + 7) / 8, key);
|
||||
|
||||
Asn1EncodableVector v = new Asn1EncodableVector(
|
||||
new DerInteger(1),
|
||||
new DerOctetString(bytes));
|
||||
|
||||
v.AddOptionalTagged(true, 0, parameters);
|
||||
v.AddOptionalTagged(true, 1, publicKey);
|
||||
|
||||
m_seq = new DerSequence(v);
|
||||
}
|
||||
|
||||
public virtual BigInteger GetKey()
|
||||
{
|
||||
Asn1OctetString octs = (Asn1OctetString)m_seq[1];
|
||||
|
||||
return new BigInteger(1, octs.GetOctets());
|
||||
}
|
||||
|
||||
public virtual DerBitString GetPublicKey()
|
||||
{
|
||||
return (DerBitString)GetObjectInTag(1, Asn1Tags.BitString);
|
||||
}
|
||||
|
||||
public virtual Asn1Object GetParameters()
|
||||
{
|
||||
return GetObjectInTag(0, -1);
|
||||
}
|
||||
|
||||
private Asn1Object GetObjectInTag(int tagNo, int baseTagNo)
|
||||
{
|
||||
foreach (Asn1Encodable ae in m_seq)
|
||||
{
|
||||
Asn1Object obj = ae.ToAsn1Object();
|
||||
|
||||
if (obj is Asn1TaggedObject tag)
|
||||
{
|
||||
if (tag.HasContextTag(tagNo))
|
||||
{
|
||||
return baseTagNo < 0
|
||||
? tag.GetExplicitBaseObject().ToAsn1Object()
|
||||
: tag.GetBaseUniversal(true, baseTagNo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* ECPrivateKey ::= SEQUENCE {
|
||||
* version INTEGER { ecPrivkeyVer1(1) } (ecPrivkeyVer1),
|
||||
* privateKey OCTET STRING,
|
||||
* parameters [0] Parameters OPTIONAL,
|
||||
* publicKey [1] BIT STRING OPTIONAL }
|
||||
*/
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
return m_seq;
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d3d5786feccac3499d0f2fe7b812100
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
1278
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/asn1/sec/SECNamedCurves.cs
vendored
Normal file
1278
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/asn1/sec/SECNamedCurves.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/asn1/sec/SECNamedCurves.cs.meta
vendored
Normal file
11
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/asn1/sec/SECNamedCurves.cs.meta
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df576bb36e3e9f247a0482cd1a9971d9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
56
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/asn1/sec/SECObjectIdentifiers.cs
vendored
Normal file
56
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/asn1/sec/SECObjectIdentifiers.cs
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1;
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.X9;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1.Sec
|
||||
{
|
||||
public abstract class SecObjectIdentifiers
|
||||
{
|
||||
/**
|
||||
* EllipticCurve OBJECT IDENTIFIER ::= {
|
||||
* iso(1) identified-organization(3) certicom(132) curve(0)
|
||||
* }
|
||||
*/
|
||||
public static readonly DerObjectIdentifier EllipticCurve = new DerObjectIdentifier("1.3.132.0");
|
||||
|
||||
public static readonly DerObjectIdentifier SecT163k1 = new DerObjectIdentifier(EllipticCurve + ".1");
|
||||
public static readonly DerObjectIdentifier SecT163r1 = new DerObjectIdentifier(EllipticCurve + ".2");
|
||||
public static readonly DerObjectIdentifier SecT239k1 = new DerObjectIdentifier(EllipticCurve + ".3");
|
||||
public static readonly DerObjectIdentifier SecT113r1 = new DerObjectIdentifier(EllipticCurve + ".4");
|
||||
public static readonly DerObjectIdentifier SecT113r2 = new DerObjectIdentifier(EllipticCurve + ".5");
|
||||
public static readonly DerObjectIdentifier SecP112r1 = new DerObjectIdentifier(EllipticCurve + ".6");
|
||||
public static readonly DerObjectIdentifier SecP112r2 = new DerObjectIdentifier(EllipticCurve + ".7");
|
||||
public static readonly DerObjectIdentifier SecP160r1 = new DerObjectIdentifier(EllipticCurve + ".8");
|
||||
public static readonly DerObjectIdentifier SecP160k1 = new DerObjectIdentifier(EllipticCurve + ".9");
|
||||
public static readonly DerObjectIdentifier SecP256k1 = new DerObjectIdentifier(EllipticCurve + ".10");
|
||||
public static readonly DerObjectIdentifier SecT163r2 = new DerObjectIdentifier(EllipticCurve + ".15");
|
||||
public static readonly DerObjectIdentifier SecT283k1 = new DerObjectIdentifier(EllipticCurve + ".16");
|
||||
public static readonly DerObjectIdentifier SecT283r1 = new DerObjectIdentifier(EllipticCurve + ".17");
|
||||
public static readonly DerObjectIdentifier SecT131r1 = new DerObjectIdentifier(EllipticCurve + ".22");
|
||||
public static readonly DerObjectIdentifier SecT131r2 = new DerObjectIdentifier(EllipticCurve + ".23");
|
||||
public static readonly DerObjectIdentifier SecT193r1 = new DerObjectIdentifier(EllipticCurve + ".24");
|
||||
public static readonly DerObjectIdentifier SecT193r2 = new DerObjectIdentifier(EllipticCurve + ".25");
|
||||
public static readonly DerObjectIdentifier SecT233k1 = new DerObjectIdentifier(EllipticCurve + ".26");
|
||||
public static readonly DerObjectIdentifier SecT233r1 = new DerObjectIdentifier(EllipticCurve + ".27");
|
||||
public static readonly DerObjectIdentifier SecP128r1 = new DerObjectIdentifier(EllipticCurve + ".28");
|
||||
public static readonly DerObjectIdentifier SecP128r2 = new DerObjectIdentifier(EllipticCurve + ".29");
|
||||
public static readonly DerObjectIdentifier SecP160r2 = new DerObjectIdentifier(EllipticCurve + ".30");
|
||||
public static readonly DerObjectIdentifier SecP192k1 = new DerObjectIdentifier(EllipticCurve + ".31");
|
||||
public static readonly DerObjectIdentifier SecP224k1 = new DerObjectIdentifier(EllipticCurve + ".32");
|
||||
public static readonly DerObjectIdentifier SecP224r1 = new DerObjectIdentifier(EllipticCurve + ".33");
|
||||
public static readonly DerObjectIdentifier SecP384r1 = new DerObjectIdentifier(EllipticCurve + ".34");
|
||||
public static readonly DerObjectIdentifier SecP521r1 = new DerObjectIdentifier(EllipticCurve + ".35");
|
||||
public static readonly DerObjectIdentifier SecT409k1 = new DerObjectIdentifier(EllipticCurve + ".36");
|
||||
public static readonly DerObjectIdentifier SecT409r1 = new DerObjectIdentifier(EllipticCurve + ".37");
|
||||
public static readonly DerObjectIdentifier SecT571k1 = new DerObjectIdentifier(EllipticCurve + ".38");
|
||||
public static readonly DerObjectIdentifier SecT571r1 = new DerObjectIdentifier(EllipticCurve + ".39");
|
||||
|
||||
public static readonly DerObjectIdentifier SecP192r1 = X9ObjectIdentifiers.Prime192v1;
|
||||
public static readonly DerObjectIdentifier SecP256r1 = X9ObjectIdentifiers.Prime256v1;
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f1b3aedfec42bd43856c0cd99dd1523
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user