up
This commit is contained in:
77
Assets/BestHTTP/SecureProtocol/asn1/pkcs/ContentInfo.cs
Normal file
77
Assets/BestHTTP/SecureProtocol/asn1/pkcs/ContentInfo.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using Org.BouncyCastle.Asn1;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Pkcs
|
||||
{
|
||||
public class ContentInfo
|
||||
: Asn1Encodable
|
||||
{
|
||||
private readonly DerObjectIdentifier contentType;
|
||||
private readonly Asn1Encodable content;
|
||||
|
||||
public static ContentInfo GetInstance(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
ContentInfo existing = obj as ContentInfo;
|
||||
if (existing != null)
|
||||
return existing;
|
||||
return new ContentInfo(Asn1Sequence.GetInstance(obj));
|
||||
}
|
||||
|
||||
private ContentInfo(
|
||||
Asn1Sequence seq)
|
||||
{
|
||||
contentType = (DerObjectIdentifier) seq[0];
|
||||
|
||||
if (seq.Count > 1)
|
||||
{
|
||||
content = ((Asn1TaggedObject) seq[1]).GetObject();
|
||||
}
|
||||
}
|
||||
|
||||
public ContentInfo(
|
||||
DerObjectIdentifier contentType,
|
||||
Asn1Encodable content)
|
||||
{
|
||||
this.contentType = contentType;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public DerObjectIdentifier ContentType
|
||||
{
|
||||
get { return contentType; }
|
||||
}
|
||||
|
||||
public Asn1Encodable Content
|
||||
{
|
||||
get { return content; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce an object suitable for an Asn1OutputStream.
|
||||
* <pre>
|
||||
* ContentInfo ::= Sequence {
|
||||
* contentType ContentType,
|
||||
* content
|
||||
* [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL }
|
||||
* </pre>
|
||||
*/
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector v = new Asn1EncodableVector(contentType);
|
||||
|
||||
if (content != null)
|
||||
{
|
||||
v.Add(new BerTaggedObject(0, content));
|
||||
}
|
||||
|
||||
return new BerSequence(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/asn1/pkcs/ContentInfo.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/asn1/pkcs/ContentInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11bfdd5c1ca044c04813c2e54cf17854
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
75
Assets/BestHTTP/SecureProtocol/asn1/pkcs/DHParameter.cs
Normal file
75
Assets/BestHTTP/SecureProtocol/asn1/pkcs/DHParameter.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
using Org.BouncyCastle.Asn1;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using Org.BouncyCastle.Math;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Pkcs
|
||||
{
|
||||
public class DHParameter
|
||||
: Asn1Encodable
|
||||
{
|
||||
internal DerInteger p, g, l;
|
||||
|
||||
public DHParameter(
|
||||
BigInteger p,
|
||||
BigInteger g,
|
||||
int l)
|
||||
{
|
||||
this.p = new DerInteger(p);
|
||||
this.g = new DerInteger(g);
|
||||
|
||||
if (l != 0)
|
||||
{
|
||||
this.l = new DerInteger(l);
|
||||
}
|
||||
}
|
||||
|
||||
public DHParameter(
|
||||
Asn1Sequence seq)
|
||||
{
|
||||
IEnumerator e = seq.GetEnumerator();
|
||||
|
||||
e.MoveNext();
|
||||
p = (DerInteger)e.Current;
|
||||
|
||||
e.MoveNext();
|
||||
g = (DerInteger)e.Current;
|
||||
|
||||
if (e.MoveNext())
|
||||
{
|
||||
l = (DerInteger) e.Current;
|
||||
}
|
||||
}
|
||||
|
||||
public BigInteger P
|
||||
{
|
||||
get { return p.PositiveValue; }
|
||||
}
|
||||
|
||||
public BigInteger G
|
||||
{
|
||||
get { return g.PositiveValue; }
|
||||
}
|
||||
|
||||
public BigInteger L
|
||||
{
|
||||
get { return l == null ? null : l.PositiveValue; }
|
||||
}
|
||||
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector v = new Asn1EncodableVector(p, g);
|
||||
|
||||
if (this.l != null)
|
||||
{
|
||||
v.Add(l);
|
||||
}
|
||||
|
||||
return new DerSequence(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/asn1/pkcs/DHParameter.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/asn1/pkcs/DHParameter.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71d85cd9c565246d2a4b7827c777b3c2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,276 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
using System;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Pkcs
|
||||
{
|
||||
public abstract class PkcsObjectIdentifiers
|
||||
{
|
||||
//
|
||||
// pkcs-1 OBJECT IDENTIFIER ::= {
|
||||
// iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 1 }
|
||||
//
|
||||
public const string Pkcs1 = "1.2.840.113549.1.1";
|
||||
|
||||
public static readonly DerObjectIdentifier RsaEncryption = new DerObjectIdentifier(Pkcs1 + ".1");
|
||||
public static readonly DerObjectIdentifier MD2WithRsaEncryption = new DerObjectIdentifier(Pkcs1 + ".2");
|
||||
public static readonly DerObjectIdentifier MD4WithRsaEncryption = new DerObjectIdentifier(Pkcs1 + ".3");
|
||||
public static readonly DerObjectIdentifier MD5WithRsaEncryption = new DerObjectIdentifier(Pkcs1 + ".4");
|
||||
public static readonly DerObjectIdentifier Sha1WithRsaEncryption = new DerObjectIdentifier(Pkcs1 + ".5");
|
||||
public static readonly DerObjectIdentifier SrsaOaepEncryptionSet = new DerObjectIdentifier(Pkcs1 + ".6");
|
||||
public static readonly DerObjectIdentifier IdRsaesOaep = new DerObjectIdentifier(Pkcs1 + ".7");
|
||||
public static readonly DerObjectIdentifier IdMgf1 = new DerObjectIdentifier(Pkcs1 + ".8");
|
||||
public static readonly DerObjectIdentifier IdPSpecified = new DerObjectIdentifier(Pkcs1 + ".9");
|
||||
public static readonly DerObjectIdentifier IdRsassaPss = new DerObjectIdentifier(Pkcs1 + ".10");
|
||||
public static readonly DerObjectIdentifier Sha256WithRsaEncryption = new DerObjectIdentifier(Pkcs1 + ".11");
|
||||
public static readonly DerObjectIdentifier Sha384WithRsaEncryption = new DerObjectIdentifier(Pkcs1 + ".12");
|
||||
public static readonly DerObjectIdentifier Sha512WithRsaEncryption = new DerObjectIdentifier(Pkcs1 + ".13");
|
||||
public static readonly DerObjectIdentifier Sha224WithRsaEncryption = new DerObjectIdentifier(Pkcs1 + ".14");
|
||||
|
||||
//
|
||||
// pkcs-3 OBJECT IDENTIFIER ::= {
|
||||
// iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 3 }
|
||||
//
|
||||
public const string Pkcs3 = "1.2.840.113549.1.3";
|
||||
|
||||
public static readonly DerObjectIdentifier DhKeyAgreement = new DerObjectIdentifier(Pkcs3 + ".1");
|
||||
|
||||
//
|
||||
// pkcs-5 OBJECT IDENTIFIER ::= {
|
||||
// iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 5 }
|
||||
//
|
||||
public const string Pkcs5 = "1.2.840.113549.1.5";
|
||||
|
||||
public static readonly DerObjectIdentifier PbeWithMD2AndDesCbc = new DerObjectIdentifier(Pkcs5 + ".1");
|
||||
public static readonly DerObjectIdentifier PbeWithMD2AndRC2Cbc = new DerObjectIdentifier(Pkcs5 + ".4");
|
||||
public static readonly DerObjectIdentifier PbeWithMD5AndDesCbc = new DerObjectIdentifier(Pkcs5 + ".3");
|
||||
public static readonly DerObjectIdentifier PbeWithMD5AndRC2Cbc = new DerObjectIdentifier(Pkcs5 + ".6");
|
||||
public static readonly DerObjectIdentifier PbeWithSha1AndDesCbc = new DerObjectIdentifier(Pkcs5 + ".10");
|
||||
public static readonly DerObjectIdentifier PbeWithSha1AndRC2Cbc = new DerObjectIdentifier(Pkcs5 + ".11");
|
||||
|
||||
public static readonly DerObjectIdentifier IdPbeS2 = new DerObjectIdentifier(Pkcs5 + ".13");
|
||||
public static readonly DerObjectIdentifier IdPbkdf2 = new DerObjectIdentifier(Pkcs5 + ".12");
|
||||
|
||||
//
|
||||
// encryptionAlgorithm OBJECT IDENTIFIER ::= {
|
||||
// iso(1) member-body(2) us(840) rsadsi(113549) 3 }
|
||||
//
|
||||
public const string EncryptionAlgorithm = "1.2.840.113549.3";
|
||||
|
||||
public static readonly DerObjectIdentifier DesEde3Cbc = new DerObjectIdentifier(EncryptionAlgorithm + ".7");
|
||||
public static readonly DerObjectIdentifier RC2Cbc = new DerObjectIdentifier(EncryptionAlgorithm + ".2");
|
||||
|
||||
//
|
||||
// object identifiers for digests
|
||||
//
|
||||
public const string DigestAlgorithm = "1.2.840.113549.2";
|
||||
|
||||
//
|
||||
// md2 OBJECT IDENTIFIER ::=
|
||||
// {iso(1) member-body(2) US(840) rsadsi(113549) DigestAlgorithm(2) 2}
|
||||
//
|
||||
public static readonly DerObjectIdentifier MD2 = new DerObjectIdentifier(DigestAlgorithm + ".2");
|
||||
|
||||
//
|
||||
// md4 OBJECT IDENTIFIER ::=
|
||||
// {iso(1) member-body(2) US(840) rsadsi(113549) DigestAlgorithm(2) 4}
|
||||
//
|
||||
public static readonly DerObjectIdentifier MD4 = new DerObjectIdentifier(DigestAlgorithm + ".4");
|
||||
|
||||
//
|
||||
// md5 OBJECT IDENTIFIER ::=
|
||||
// {iso(1) member-body(2) US(840) rsadsi(113549) DigestAlgorithm(2) 5}
|
||||
//
|
||||
public static readonly DerObjectIdentifier MD5 = new DerObjectIdentifier(DigestAlgorithm + ".5");
|
||||
|
||||
public static readonly DerObjectIdentifier IdHmacWithSha1 = new DerObjectIdentifier(DigestAlgorithm + ".7");
|
||||
public static readonly DerObjectIdentifier IdHmacWithSha224 = new DerObjectIdentifier(DigestAlgorithm + ".8");
|
||||
public static readonly DerObjectIdentifier IdHmacWithSha256 = new DerObjectIdentifier(DigestAlgorithm + ".9");
|
||||
public static readonly DerObjectIdentifier IdHmacWithSha384 = new DerObjectIdentifier(DigestAlgorithm + ".10");
|
||||
public static readonly DerObjectIdentifier IdHmacWithSha512 = new DerObjectIdentifier(DigestAlgorithm + ".11");
|
||||
|
||||
//
|
||||
// pkcs-7 OBJECT IDENTIFIER ::= {
|
||||
// iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 7 }
|
||||
//
|
||||
public const string Pkcs7 = "1.2.840.113549.1.7";
|
||||
|
||||
public static readonly DerObjectIdentifier Data = new DerObjectIdentifier(Pkcs7 + ".1");
|
||||
public static readonly DerObjectIdentifier SignedData = new DerObjectIdentifier(Pkcs7 + ".2");
|
||||
public static readonly DerObjectIdentifier EnvelopedData = new DerObjectIdentifier(Pkcs7 + ".3");
|
||||
public static readonly DerObjectIdentifier SignedAndEnvelopedData = new DerObjectIdentifier(Pkcs7 + ".4");
|
||||
public static readonly DerObjectIdentifier DigestedData = new DerObjectIdentifier(Pkcs7 + ".5");
|
||||
public static readonly DerObjectIdentifier EncryptedData = new DerObjectIdentifier(Pkcs7 + ".6");
|
||||
|
||||
//
|
||||
// pkcs-9 OBJECT IDENTIFIER ::= {
|
||||
// iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 9 }
|
||||
//
|
||||
public const string Pkcs9 = "1.2.840.113549.1.9";
|
||||
|
||||
public static readonly DerObjectIdentifier Pkcs9AtEmailAddress = new DerObjectIdentifier(Pkcs9 + ".1");
|
||||
public static readonly DerObjectIdentifier Pkcs9AtUnstructuredName = new DerObjectIdentifier(Pkcs9 + ".2");
|
||||
public static readonly DerObjectIdentifier Pkcs9AtContentType = new DerObjectIdentifier(Pkcs9 + ".3");
|
||||
public static readonly DerObjectIdentifier Pkcs9AtMessageDigest = new DerObjectIdentifier(Pkcs9 + ".4");
|
||||
public static readonly DerObjectIdentifier Pkcs9AtSigningTime = new DerObjectIdentifier(Pkcs9 + ".5");
|
||||
public static readonly DerObjectIdentifier Pkcs9AtCounterSignature = new DerObjectIdentifier(Pkcs9 + ".6");
|
||||
public static readonly DerObjectIdentifier Pkcs9AtChallengePassword = new DerObjectIdentifier(Pkcs9 + ".7");
|
||||
public static readonly DerObjectIdentifier Pkcs9AtUnstructuredAddress = new DerObjectIdentifier(Pkcs9 + ".8");
|
||||
public static readonly DerObjectIdentifier Pkcs9AtExtendedCertificateAttributes = new DerObjectIdentifier(Pkcs9 + ".9");
|
||||
public static readonly DerObjectIdentifier Pkcs9AtSigningDescription = new DerObjectIdentifier(Pkcs9 + ".13");
|
||||
public static readonly DerObjectIdentifier Pkcs9AtExtensionRequest = new DerObjectIdentifier(Pkcs9 + ".14");
|
||||
public static readonly DerObjectIdentifier Pkcs9AtSmimeCapabilities = new DerObjectIdentifier(Pkcs9 + ".15");
|
||||
public static readonly DerObjectIdentifier IdSmime = new DerObjectIdentifier(Pkcs9 + ".16");
|
||||
|
||||
public static readonly DerObjectIdentifier Pkcs9AtFriendlyName = new DerObjectIdentifier(Pkcs9 + ".20");
|
||||
public static readonly DerObjectIdentifier Pkcs9AtLocalKeyID = new DerObjectIdentifier(Pkcs9 + ".21");
|
||||
|
||||
[Obsolete("Use X509Certificate instead")]
|
||||
public static readonly DerObjectIdentifier X509CertType = new DerObjectIdentifier(Pkcs9 + ".22.1");
|
||||
|
||||
public const string CertTypes = Pkcs9 + ".22";
|
||||
public static readonly DerObjectIdentifier X509Certificate = new DerObjectIdentifier(CertTypes + ".1");
|
||||
public static readonly DerObjectIdentifier SdsiCertificate = new DerObjectIdentifier(CertTypes + ".2");
|
||||
|
||||
public const string CrlTypes = Pkcs9 + ".23";
|
||||
public static readonly DerObjectIdentifier X509Crl = new DerObjectIdentifier(CrlTypes + ".1");
|
||||
|
||||
public static readonly DerObjectIdentifier IdAlg = IdSmime.Branch("3");
|
||||
|
||||
public static readonly DerObjectIdentifier IdAlgEsdh = IdAlg.Branch("5");
|
||||
public static readonly DerObjectIdentifier IdAlgCms3DesWrap = IdAlg.Branch("6");
|
||||
public static readonly DerObjectIdentifier IdAlgCmsRC2Wrap = IdAlg.Branch("7");
|
||||
public static readonly DerObjectIdentifier IdAlgPwriKek = IdAlg.Branch("9");
|
||||
public static readonly DerObjectIdentifier IdAlgSsdh = IdAlg.Branch("10");
|
||||
|
||||
/*
|
||||
* <pre>
|
||||
* -- RSA-KEM Key Transport Algorithm
|
||||
*
|
||||
* id-rsa-kem OID ::= {
|
||||
* iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1)
|
||||
* pkcs-9(9) smime(16) alg(3) 14
|
||||
* }
|
||||
* </pre>
|
||||
*/
|
||||
public static readonly DerObjectIdentifier IdRsaKem = IdAlg.Branch("14");
|
||||
|
||||
//
|
||||
// SMIME capability sub oids.
|
||||
//
|
||||
public static readonly DerObjectIdentifier PreferSignedData = Pkcs9AtSmimeCapabilities.Branch("1");
|
||||
public static readonly DerObjectIdentifier CannotDecryptAny = Pkcs9AtSmimeCapabilities.Branch("2");
|
||||
public static readonly DerObjectIdentifier SmimeCapabilitiesVersions = Pkcs9AtSmimeCapabilities.Branch("3");
|
||||
|
||||
//
|
||||
// other SMIME attributes
|
||||
//
|
||||
public static readonly DerObjectIdentifier IdAAReceiptRequest = IdSmime.Branch("2.1");
|
||||
|
||||
//
|
||||
// id-ct OBJECT IDENTIFIER ::= {iso(1) member-body(2) usa(840)
|
||||
// rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) ct(1)}
|
||||
//
|
||||
public const string IdCT = "1.2.840.113549.1.9.16.1";
|
||||
|
||||
public static readonly DerObjectIdentifier IdCTAuthData = new DerObjectIdentifier(IdCT + ".2");
|
||||
public static readonly DerObjectIdentifier IdCTTstInfo = new DerObjectIdentifier(IdCT + ".4");
|
||||
public static readonly DerObjectIdentifier IdCTCompressedData = new DerObjectIdentifier(IdCT + ".9");
|
||||
public static readonly DerObjectIdentifier IdCTAuthEnvelopedData = new DerObjectIdentifier(IdCT + ".23");
|
||||
public static readonly DerObjectIdentifier IdCTTimestampedData = new DerObjectIdentifier(IdCT + ".31");
|
||||
|
||||
//
|
||||
// id-cti OBJECT IDENTIFIER ::= {iso(1) member-body(2) usa(840)
|
||||
// rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) cti(6)}
|
||||
//
|
||||
public const string IdCti = "1.2.840.113549.1.9.16.6";
|
||||
|
||||
public static readonly DerObjectIdentifier IdCtiEtsProofOfOrigin = new DerObjectIdentifier(IdCti + ".1");
|
||||
public static readonly DerObjectIdentifier IdCtiEtsProofOfReceipt = new DerObjectIdentifier(IdCti + ".2");
|
||||
public static readonly DerObjectIdentifier IdCtiEtsProofOfDelivery = new DerObjectIdentifier(IdCti + ".3");
|
||||
public static readonly DerObjectIdentifier IdCtiEtsProofOfSender = new DerObjectIdentifier(IdCti + ".4");
|
||||
public static readonly DerObjectIdentifier IdCtiEtsProofOfApproval = new DerObjectIdentifier(IdCti + ".5");
|
||||
public static readonly DerObjectIdentifier IdCtiEtsProofOfCreation = new DerObjectIdentifier(IdCti + ".6");
|
||||
|
||||
//
|
||||
// id-aa OBJECT IDENTIFIER ::= {iso(1) member-body(2) usa(840)
|
||||
// rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) attributes(2)}
|
||||
//
|
||||
public const string IdAA = "1.2.840.113549.1.9.16.2";
|
||||
|
||||
public static readonly DerObjectIdentifier IdAAContentHint = new DerObjectIdentifier(IdAA + ".4"); // See RFC 2634
|
||||
public static readonly DerObjectIdentifier IdAAMsgSigDigest = new DerObjectIdentifier(IdAA + ".5");
|
||||
public static readonly DerObjectIdentifier IdAAContentReference = new DerObjectIdentifier(IdAA + ".10");
|
||||
|
||||
/*
|
||||
* id-aa-encrypKeyPref OBJECT IDENTIFIER ::= {id-aa 11}
|
||||
*
|
||||
*/
|
||||
public static readonly DerObjectIdentifier IdAAEncrypKeyPref = new DerObjectIdentifier(IdAA + ".11");
|
||||
public static readonly DerObjectIdentifier IdAASigningCertificate = new DerObjectIdentifier(IdAA + ".12");
|
||||
public static readonly DerObjectIdentifier IdAASigningCertificateV2 = new DerObjectIdentifier(IdAA + ".47");
|
||||
|
||||
public static readonly DerObjectIdentifier IdAAContentIdentifier = new DerObjectIdentifier(IdAA + ".7"); // See RFC 2634
|
||||
|
||||
/*
|
||||
* RFC 3126
|
||||
*/
|
||||
public static readonly DerObjectIdentifier IdAASignatureTimeStampToken = new DerObjectIdentifier(IdAA + ".14");
|
||||
|
||||
public static readonly DerObjectIdentifier IdAAEtsSigPolicyID = new DerObjectIdentifier(IdAA + ".15");
|
||||
public static readonly DerObjectIdentifier IdAAEtsCommitmentType = new DerObjectIdentifier(IdAA + ".16");
|
||||
public static readonly DerObjectIdentifier IdAAEtsSignerLocation = new DerObjectIdentifier(IdAA + ".17");
|
||||
public static readonly DerObjectIdentifier IdAAEtsSignerAttr = new DerObjectIdentifier(IdAA + ".18");
|
||||
public static readonly DerObjectIdentifier IdAAEtsOtherSigCert = new DerObjectIdentifier(IdAA + ".19");
|
||||
public static readonly DerObjectIdentifier IdAAEtsContentTimestamp = new DerObjectIdentifier(IdAA + ".20");
|
||||
public static readonly DerObjectIdentifier IdAAEtsCertificateRefs = new DerObjectIdentifier(IdAA + ".21");
|
||||
public static readonly DerObjectIdentifier IdAAEtsRevocationRefs = new DerObjectIdentifier(IdAA + ".22");
|
||||
public static readonly DerObjectIdentifier IdAAEtsCertValues = new DerObjectIdentifier(IdAA + ".23");
|
||||
public static readonly DerObjectIdentifier IdAAEtsRevocationValues = new DerObjectIdentifier(IdAA + ".24");
|
||||
public static readonly DerObjectIdentifier IdAAEtsEscTimeStamp = new DerObjectIdentifier(IdAA + ".25");
|
||||
public static readonly DerObjectIdentifier IdAAEtsCertCrlTimestamp = new DerObjectIdentifier(IdAA + ".26");
|
||||
public static readonly DerObjectIdentifier IdAAEtsArchiveTimestamp = new DerObjectIdentifier(IdAA + ".27");
|
||||
|
||||
[Obsolete("Use 'IdAAEtsSigPolicyID' instead")]
|
||||
public static readonly DerObjectIdentifier IdAASigPolicyID = IdAAEtsSigPolicyID;
|
||||
[Obsolete("Use 'IdAAEtsCommitmentType' instead")]
|
||||
public static readonly DerObjectIdentifier IdAACommitmentType = IdAAEtsCommitmentType;
|
||||
[Obsolete("Use 'IdAAEtsSignerLocation' instead")]
|
||||
public static readonly DerObjectIdentifier IdAASignerLocation = IdAAEtsSignerLocation;
|
||||
[Obsolete("Use 'IdAAEtsOtherSigCert' instead")]
|
||||
public static readonly DerObjectIdentifier IdAAOtherSigCert = IdAAEtsOtherSigCert;
|
||||
|
||||
//
|
||||
// id-spq OBJECT IDENTIFIER ::= {iso(1) member-body(2) usa(840)
|
||||
// rsadsi(113549) pkcs(1) pkcs-9(9) smime(16) id-spq(5)}
|
||||
//
|
||||
public const string IdSpq = "1.2.840.113549.1.9.16.5";
|
||||
|
||||
public static readonly DerObjectIdentifier IdSpqEtsUri = new DerObjectIdentifier(IdSpq + ".1");
|
||||
public static readonly DerObjectIdentifier IdSpqEtsUNotice = new DerObjectIdentifier(IdSpq + ".2");
|
||||
|
||||
//
|
||||
// pkcs-12 OBJECT IDENTIFIER ::= {
|
||||
// iso(1) member-body(2) us(840) rsadsi(113549) pkcs(1) 12 }
|
||||
//
|
||||
public const string Pkcs12 = "1.2.840.113549.1.12";
|
||||
public const string BagTypes = Pkcs12 + ".10.1";
|
||||
|
||||
public static readonly DerObjectIdentifier KeyBag = new DerObjectIdentifier(BagTypes + ".1");
|
||||
public static readonly DerObjectIdentifier Pkcs8ShroudedKeyBag = new DerObjectIdentifier(BagTypes + ".2");
|
||||
public static readonly DerObjectIdentifier CertBag = new DerObjectIdentifier(BagTypes + ".3");
|
||||
public static readonly DerObjectIdentifier CrlBag = new DerObjectIdentifier(BagTypes + ".4");
|
||||
public static readonly DerObjectIdentifier SecretBag = new DerObjectIdentifier(BagTypes + ".5");
|
||||
public static readonly DerObjectIdentifier SafeContentsBag = new DerObjectIdentifier(BagTypes + ".6");
|
||||
|
||||
public const string Pkcs12PbeIds = Pkcs12 + ".1";
|
||||
|
||||
public static readonly DerObjectIdentifier PbeWithShaAnd128BitRC4 = new DerObjectIdentifier(Pkcs12PbeIds + ".1");
|
||||
public static readonly DerObjectIdentifier PbeWithShaAnd40BitRC4 = new DerObjectIdentifier(Pkcs12PbeIds + ".2");
|
||||
public static readonly DerObjectIdentifier PbeWithShaAnd3KeyTripleDesCbc = new DerObjectIdentifier(Pkcs12PbeIds + ".3");
|
||||
public static readonly DerObjectIdentifier PbeWithShaAnd2KeyTripleDesCbc = new DerObjectIdentifier(Pkcs12PbeIds + ".4");
|
||||
public static readonly DerObjectIdentifier PbeWithShaAnd128BitRC2Cbc = new DerObjectIdentifier(Pkcs12PbeIds + ".5");
|
||||
public static readonly DerObjectIdentifier PbewithShaAnd40BitRC2Cbc = new DerObjectIdentifier(Pkcs12PbeIds + ".6");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 658bcbf9ee0a8499e9259a993f79f365
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
169
Assets/BestHTTP/SecureProtocol/asn1/pkcs/RSASSAPSSparams.cs
Normal file
169
Assets/BestHTTP/SecureProtocol/asn1/pkcs/RSASSAPSSparams.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
using System;
|
||||
|
||||
using Org.BouncyCastle.Asn1.Oiw;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Org.BouncyCastle.Utilities;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Pkcs
|
||||
{
|
||||
public class RsassaPssParameters
|
||||
: Asn1Encodable
|
||||
{
|
||||
private AlgorithmIdentifier hashAlgorithm;
|
||||
private AlgorithmIdentifier maskGenAlgorithm;
|
||||
private DerInteger saltLength;
|
||||
private DerInteger trailerField;
|
||||
|
||||
public readonly static AlgorithmIdentifier DefaultHashAlgorithm = new AlgorithmIdentifier(OiwObjectIdentifiers.IdSha1, DerNull.Instance);
|
||||
public readonly static AlgorithmIdentifier DefaultMaskGenFunction = new AlgorithmIdentifier(PkcsObjectIdentifiers.IdMgf1, DefaultHashAlgorithm);
|
||||
public readonly static DerInteger DefaultSaltLength = new DerInteger(20);
|
||||
public readonly static DerInteger DefaultTrailerField = new DerInteger(1);
|
||||
|
||||
public static RsassaPssParameters GetInstance(
|
||||
object obj)
|
||||
{
|
||||
if (obj == null || obj is RsassaPssParameters)
|
||||
{
|
||||
return (RsassaPssParameters)obj;
|
||||
}
|
||||
|
||||
if (obj is Asn1Sequence)
|
||||
{
|
||||
return new RsassaPssParameters((Asn1Sequence)obj);
|
||||
}
|
||||
|
||||
throw new ArgumentException("Unknown object in factory: " + Platform.GetTypeName(obj), "obj");
|
||||
}
|
||||
|
||||
/**
|
||||
* The default version
|
||||
*/
|
||||
public RsassaPssParameters()
|
||||
{
|
||||
hashAlgorithm = DefaultHashAlgorithm;
|
||||
maskGenAlgorithm = DefaultMaskGenFunction;
|
||||
saltLength = DefaultSaltLength;
|
||||
trailerField = DefaultTrailerField;
|
||||
}
|
||||
|
||||
public RsassaPssParameters(
|
||||
AlgorithmIdentifier hashAlgorithm,
|
||||
AlgorithmIdentifier maskGenAlgorithm,
|
||||
DerInteger saltLength,
|
||||
DerInteger trailerField)
|
||||
{
|
||||
this.hashAlgorithm = hashAlgorithm;
|
||||
this.maskGenAlgorithm = maskGenAlgorithm;
|
||||
this.saltLength = saltLength;
|
||||
this.trailerField = trailerField;
|
||||
}
|
||||
|
||||
public RsassaPssParameters(
|
||||
Asn1Sequence seq)
|
||||
{
|
||||
hashAlgorithm = DefaultHashAlgorithm;
|
||||
maskGenAlgorithm = DefaultMaskGenFunction;
|
||||
saltLength = DefaultSaltLength;
|
||||
trailerField = DefaultTrailerField;
|
||||
|
||||
for (int i = 0; i != seq.Count; i++)
|
||||
{
|
||||
Asn1TaggedObject o = (Asn1TaggedObject)seq[i];
|
||||
|
||||
switch (o.TagNo)
|
||||
{
|
||||
case 0:
|
||||
hashAlgorithm = AlgorithmIdentifier.GetInstance(o, true);
|
||||
break;
|
||||
case 1:
|
||||
maskGenAlgorithm = AlgorithmIdentifier.GetInstance(o, true);
|
||||
break;
|
||||
case 2:
|
||||
saltLength = DerInteger.GetInstance(o, true);
|
||||
break;
|
||||
case 3:
|
||||
trailerField = DerInteger.GetInstance(o, true);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("unknown tag");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public AlgorithmIdentifier HashAlgorithm
|
||||
{
|
||||
get { return hashAlgorithm; }
|
||||
}
|
||||
|
||||
public AlgorithmIdentifier MaskGenAlgorithm
|
||||
{
|
||||
get { return maskGenAlgorithm; }
|
||||
}
|
||||
|
||||
public DerInteger SaltLength
|
||||
{
|
||||
get { return saltLength; }
|
||||
}
|
||||
|
||||
public DerInteger TrailerField
|
||||
{
|
||||
get { return trailerField; }
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* RSASSA-PSS-params ::= SEQUENCE {
|
||||
* hashAlgorithm [0] OAEP-PSSDigestAlgorithms DEFAULT sha1,
|
||||
* maskGenAlgorithm [1] PKCS1MGFAlgorithms DEFAULT mgf1SHA1,
|
||||
* saltLength [2] INTEGER DEFAULT 20,
|
||||
* trailerField [3] TrailerField DEFAULT trailerFieldBC
|
||||
* }
|
||||
*
|
||||
* OAEP-PSSDigestAlgorithms ALGORITHM-IDENTIFIER ::= {
|
||||
* { OID id-sha1 PARAMETERS NULL }|
|
||||
* { OID id-sha256 PARAMETERS NULL }|
|
||||
* { OID id-sha384 PARAMETERS NULL }|
|
||||
* { OID id-sha512 PARAMETERS NULL },
|
||||
* ... -- Allows for future expansion --
|
||||
* }
|
||||
*
|
||||
* PKCS1MGFAlgorithms ALGORITHM-IDENTIFIER ::= {
|
||||
* { OID id-mgf1 PARAMETERS OAEP-PSSDigestAlgorithms },
|
||||
* ... -- Allows for future expansion --
|
||||
* }
|
||||
*
|
||||
* TrailerField ::= INTEGER { trailerFieldBC(1) }
|
||||
* </pre>
|
||||
* @return the asn1 primitive representing the parameters.
|
||||
*/
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector v = new Asn1EncodableVector();
|
||||
|
||||
if (!hashAlgorithm.Equals(DefaultHashAlgorithm))
|
||||
{
|
||||
v.Add(new DerTaggedObject(true, 0, hashAlgorithm));
|
||||
}
|
||||
|
||||
if (!maskGenAlgorithm.Equals(DefaultMaskGenFunction))
|
||||
{
|
||||
v.Add(new DerTaggedObject(true, 1, maskGenAlgorithm));
|
||||
}
|
||||
|
||||
if (!saltLength.Equals(DefaultSaltLength))
|
||||
{
|
||||
v.Add(new DerTaggedObject(true, 2, saltLength));
|
||||
}
|
||||
|
||||
if (!trailerField.Equals(DefaultTrailerField))
|
||||
{
|
||||
v.Add(new DerTaggedObject(true, 3, trailerField));
|
||||
}
|
||||
|
||||
return new DerSequence(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 096c5948fd48f41bbbf99d91a34b66ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
160
Assets/BestHTTP/SecureProtocol/asn1/pkcs/SignedData.cs
Normal file
160
Assets/BestHTTP/SecureProtocol/asn1/pkcs/SignedData.cs
Normal file
@@ -0,0 +1,160 @@
|
||||
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
using Org.BouncyCastle.Asn1;
|
||||
|
||||
namespace Org.BouncyCastle.Asn1.Pkcs
|
||||
{
|
||||
/**
|
||||
* a Pkcs#7 signed data object.
|
||||
*/
|
||||
public class SignedData
|
||||
: Asn1Encodable
|
||||
{
|
||||
private readonly DerInteger version;
|
||||
private readonly Asn1Set digestAlgorithms;
|
||||
private readonly ContentInfo contentInfo;
|
||||
private readonly Asn1Set certificates;
|
||||
private readonly Asn1Set crls;
|
||||
private readonly Asn1Set signerInfos;
|
||||
|
||||
public static SignedData GetInstance(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return null;
|
||||
SignedData existing = obj as SignedData;
|
||||
if (existing != null)
|
||||
return existing;
|
||||
return new SignedData(Asn1Sequence.GetInstance(obj));
|
||||
}
|
||||
|
||||
public SignedData(
|
||||
DerInteger _version,
|
||||
Asn1Set _digestAlgorithms,
|
||||
ContentInfo _contentInfo,
|
||||
Asn1Set _certificates,
|
||||
Asn1Set _crls,
|
||||
Asn1Set _signerInfos)
|
||||
{
|
||||
version = _version;
|
||||
digestAlgorithms = _digestAlgorithms;
|
||||
contentInfo = _contentInfo;
|
||||
certificates = _certificates;
|
||||
crls = _crls;
|
||||
signerInfos = _signerInfos;
|
||||
}
|
||||
|
||||
private SignedData(
|
||||
Asn1Sequence seq)
|
||||
{
|
||||
IEnumerator e = seq.GetEnumerator();
|
||||
|
||||
e.MoveNext();
|
||||
version = (DerInteger) e.Current;
|
||||
|
||||
e.MoveNext();
|
||||
digestAlgorithms = (Asn1Set) e.Current;
|
||||
|
||||
e.MoveNext();
|
||||
contentInfo = ContentInfo.GetInstance(e.Current);
|
||||
|
||||
while (e.MoveNext())
|
||||
{
|
||||
Asn1Object o = (Asn1Object) e.Current;
|
||||
|
||||
//
|
||||
// an interesting feature of SignedData is that there appear to be varying implementations...
|
||||
// for the moment we ignore anything which doesn't fit.
|
||||
//
|
||||
if (o is DerTaggedObject)
|
||||
{
|
||||
DerTaggedObject tagged = (DerTaggedObject) o;
|
||||
|
||||
switch (tagged.TagNo)
|
||||
{
|
||||
case 0:
|
||||
certificates = Asn1Set.GetInstance(tagged, false);
|
||||
break;
|
||||
case 1:
|
||||
crls = Asn1Set.GetInstance(tagged, false);
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentException("unknown tag value " + tagged.TagNo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
signerInfos = (Asn1Set) o;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DerInteger Version
|
||||
{
|
||||
get { return version; }
|
||||
}
|
||||
|
||||
public Asn1Set DigestAlgorithms
|
||||
{
|
||||
get { return digestAlgorithms; }
|
||||
}
|
||||
|
||||
public ContentInfo ContentInfo
|
||||
{
|
||||
get { return contentInfo; }
|
||||
}
|
||||
|
||||
public Asn1Set Certificates
|
||||
{
|
||||
get { return certificates; }
|
||||
}
|
||||
|
||||
public Asn1Set Crls
|
||||
{
|
||||
get { return crls; }
|
||||
}
|
||||
|
||||
public Asn1Set SignerInfos
|
||||
{
|
||||
get { return signerInfos; }
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce an object suitable for an Asn1OutputStream.
|
||||
* <pre>
|
||||
* SignedData ::= Sequence {
|
||||
* version Version,
|
||||
* digestAlgorithms DigestAlgorithmIdentifiers,
|
||||
* contentInfo ContentInfo,
|
||||
* certificates
|
||||
* [0] IMPLICIT ExtendedCertificatesAndCertificates
|
||||
* OPTIONAL,
|
||||
* crls
|
||||
* [1] IMPLICIT CertificateRevocationLists OPTIONAL,
|
||||
* signerInfos SignerInfos }
|
||||
* </pre>
|
||||
*/
|
||||
public override Asn1Object ToAsn1Object()
|
||||
{
|
||||
Asn1EncodableVector v = new Asn1EncodableVector(
|
||||
version, digestAlgorithms, contentInfo);
|
||||
|
||||
if (certificates != null)
|
||||
{
|
||||
v.Add(new DerTaggedObject(false, 0, certificates));
|
||||
}
|
||||
|
||||
if (crls != null)
|
||||
{
|
||||
v.Add(new DerTaggedObject(false, 1, crls));
|
||||
}
|
||||
|
||||
v.Add(signerInfos);
|
||||
|
||||
return new BerSequence(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
11
Assets/BestHTTP/SecureProtocol/asn1/pkcs/SignedData.cs.meta
Normal file
11
Assets/BestHTTP/SecureProtocol/asn1/pkcs/SignedData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26ad84b97e3584c99a9ab6f7fb744564
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user