add all
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
#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.X509;
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto;
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Security;
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Security.Certificates;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.X509.Extension
|
||||
{
|
||||
/// <remarks>A high level authority key identifier.</remarks>
|
||||
public class AuthorityKeyIdentifierStructure
|
||||
: AuthorityKeyIdentifier
|
||||
{
|
||||
/**
|
||||
* Constructor which will take the byte[] returned from getExtensionValue()
|
||||
*
|
||||
* @param encodedValue a DER octet encoded string with the extension structure in it.
|
||||
* @throws IOException on parsing errors.
|
||||
*/
|
||||
// TODO Add a functional constructor from byte[]?
|
||||
public AuthorityKeyIdentifierStructure(
|
||||
Asn1OctetString encodedValue)
|
||||
: base((Asn1Sequence) X509ExtensionUtilities.FromExtensionValue(encodedValue))
|
||||
{
|
||||
}
|
||||
|
||||
private static Asn1Sequence FromCertificate(
|
||||
X509Certificate certificate)
|
||||
{
|
||||
try
|
||||
{
|
||||
GeneralName genName = new GeneralName(
|
||||
PrincipalUtilities.GetIssuerX509Principal(certificate));
|
||||
|
||||
if (certificate.Version == 3)
|
||||
{
|
||||
Asn1OctetString ext = certificate.GetExtensionValue(X509Extensions.SubjectKeyIdentifier);
|
||||
|
||||
if (ext != null)
|
||||
{
|
||||
Asn1OctetString str = (Asn1OctetString) X509ExtensionUtilities.FromExtensionValue(ext);
|
||||
|
||||
return (Asn1Sequence) new AuthorityKeyIdentifier(
|
||||
str.GetOctets(), new GeneralNames(genName), certificate.SerialNumber).ToAsn1Object();
|
||||
}
|
||||
}
|
||||
|
||||
SubjectPublicKeyInfo info = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(
|
||||
certificate.GetPublicKey());
|
||||
|
||||
return (Asn1Sequence) new AuthorityKeyIdentifier(
|
||||
info, new GeneralNames(genName), certificate.SerialNumber).ToAsn1Object();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new CertificateParsingException("Exception extracting certificate details", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static Asn1Sequence FromKey(
|
||||
AsymmetricKeyParameter pubKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
SubjectPublicKeyInfo info = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(pubKey);
|
||||
|
||||
return (Asn1Sequence) new AuthorityKeyIdentifier(info).ToAsn1Object();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new InvalidKeyException("can't process key: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an AuthorityKeyIdentifier using the passed in certificate's public
|
||||
* key, issuer and serial number.
|
||||
*
|
||||
* @param certificate the certificate providing the information.
|
||||
* @throws CertificateParsingException if there is a problem processing the certificate
|
||||
*/
|
||||
public AuthorityKeyIdentifierStructure(
|
||||
X509Certificate certificate)
|
||||
: base(FromCertificate(certificate))
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an AuthorityKeyIdentifier using just the hash of the
|
||||
* public key.
|
||||
*
|
||||
* @param pubKey the key to generate the hash from.
|
||||
* @throws InvalidKeyException if there is a problem using the key.
|
||||
*/
|
||||
public AuthorityKeyIdentifierStructure(
|
||||
AsymmetricKeyParameter pubKey)
|
||||
: base(FromKey(pubKey))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af2f47f3c96c6ec44a641bd715f9bf4e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
#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.X509;
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto;
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Security.Certificates;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.X509.Extension
|
||||
{
|
||||
/**
|
||||
* A high level subject key identifier.
|
||||
*/
|
||||
public class SubjectKeyIdentifierStructure
|
||||
: SubjectKeyIdentifier
|
||||
{
|
||||
/**
|
||||
* Constructor which will take the byte[] returned from getExtensionValue()
|
||||
*
|
||||
* @param encodedValue a DER octet encoded string with the extension structure in it.
|
||||
* @throws IOException on parsing errors.
|
||||
*/
|
||||
public SubjectKeyIdentifierStructure(
|
||||
Asn1OctetString encodedValue)
|
||||
: base((Asn1OctetString) X509ExtensionUtilities.FromExtensionValue(encodedValue))
|
||||
{
|
||||
}
|
||||
|
||||
private static Asn1OctetString FromPublicKey(
|
||||
AsymmetricKeyParameter pubKey)
|
||||
{
|
||||
try
|
||||
{
|
||||
SubjectPublicKeyInfo info = SubjectPublicKeyInfoFactory.CreateSubjectPublicKeyInfo(pubKey);
|
||||
|
||||
return (Asn1OctetString) new SubjectKeyIdentifier(info).ToAsn1Object();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new CertificateParsingException("Exception extracting certificate details: " + e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public SubjectKeyIdentifierStructure(
|
||||
AsymmetricKeyParameter pubKey)
|
||||
: base(FromPublicKey(pubKey))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 951acd8cb11bc624c9d28b402ada43e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
31
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/x509/extension/X509ExtensionUtil.cs
vendored
Normal file
31
Packages/com.tivadar.best.http/Runtime/3rdParty/BouncyCastle/x509/extension/X509ExtensionUtil.cs
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
#pragma warning disable
|
||||
using System;
|
||||
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Asn1;
|
||||
|
||||
namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.X509.Extension
|
||||
{
|
||||
public class X509ExtensionUtilities
|
||||
{
|
||||
public static Asn1Object FromExtensionValue(Asn1OctetString extensionValue)
|
||||
{
|
||||
return Asn1Object.FromByteArray(extensionValue.GetOctets());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extract the value of the given extension, if it exists.
|
||||
/// </summary>
|
||||
/// <param name="extensions">The extensions object.</param>
|
||||
/// <param name="oid">The object identifier to obtain.</param>
|
||||
/// <returns>Asn1Object</returns>
|
||||
/// <exception cref="Exception">if the extension cannot be read.</exception>
|
||||
public static Asn1Object FromExtensionValue(IX509Extension extensions, DerObjectIdentifier oid)
|
||||
{
|
||||
Asn1OctetString extensionValue = extensions.GetExtensionValue(oid);
|
||||
return extensionValue == null ? null : FromExtensionValue(extensionValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 87bd1393b2d90394d99cb837720ca8b8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user