You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.9 KiB
79 lines
1.9 KiB
1 year ago
|
#if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
|
||
|
#pragma warning disable
|
||
|
using System;
|
||
|
|
||
|
using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
|
||
|
|
||
|
namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs
|
||
|
{
|
||
|
public class SafeBag
|
||
|
: Asn1Encodable
|
||
|
{
|
||
|
public static SafeBag GetInstance(object obj)
|
||
|
{
|
||
|
if (obj is SafeBag)
|
||
|
return (SafeBag)obj;
|
||
|
if (obj == null)
|
||
|
return null;
|
||
|
return new SafeBag(Asn1Sequence.GetInstance(obj));
|
||
|
}
|
||
|
|
||
|
private readonly DerObjectIdentifier bagID;
|
||
|
private readonly Asn1Object bagValue;
|
||
|
private readonly Asn1Set bagAttributes;
|
||
|
|
||
|
public SafeBag(
|
||
|
DerObjectIdentifier oid,
|
||
|
Asn1Object obj)
|
||
|
{
|
||
|
this.bagID = oid;
|
||
|
this.bagValue = obj;
|
||
|
this.bagAttributes = null;
|
||
|
}
|
||
|
|
||
|
public SafeBag(
|
||
|
DerObjectIdentifier oid,
|
||
|
Asn1Object obj,
|
||
|
Asn1Set bagAttributes)
|
||
|
{
|
||
|
this.bagID = oid;
|
||
|
this.bagValue = obj;
|
||
|
this.bagAttributes = bagAttributes;
|
||
|
}
|
||
|
|
||
|
private SafeBag(Asn1Sequence seq)
|
||
|
{
|
||
|
this.bagID = (DerObjectIdentifier)seq[0];
|
||
|
this.bagValue = ((DerTaggedObject)seq[1]).GetObject();
|
||
|
if (seq.Count == 3)
|
||
|
{
|
||
|
this.bagAttributes = (Asn1Set)seq[2];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public DerObjectIdentifier BagID
|
||
|
{
|
||
|
get { return bagID; }
|
||
|
}
|
||
|
|
||
|
public Asn1Object BagValue
|
||
|
{
|
||
|
get { return bagValue; }
|
||
|
}
|
||
|
|
||
|
public Asn1Set BagAttributes
|
||
|
{
|
||
|
get { return bagAttributes; }
|
||
|
}
|
||
|
|
||
|
public override Asn1Object ToAsn1Object()
|
||
|
{
|
||
|
Asn1EncodableVector v = new Asn1EncodableVector(bagID, new DerTaggedObject(0, bagValue));
|
||
|
v.AddOptional(bagAttributes);
|
||
|
return new DerSequence(v);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
#pragma warning restore
|
||
|
#endif
|