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.
67 lines
1.6 KiB
67 lines
1.6 KiB
#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 AuthenticatedSafe |
|
: Asn1Encodable |
|
{ |
|
private static ContentInfo[] Copy(ContentInfo[] info) |
|
{ |
|
return (ContentInfo[])info.Clone(); |
|
} |
|
|
|
public static AuthenticatedSafe GetInstance(object obj) |
|
{ |
|
if (obj is AuthenticatedSafe) |
|
return (AuthenticatedSafe)obj; |
|
if (obj == null) |
|
return null; |
|
return new AuthenticatedSafe(Asn1Sequence.GetInstance(obj)); |
|
} |
|
|
|
private readonly ContentInfo[] info; |
|
private readonly bool isBer; |
|
|
|
private AuthenticatedSafe(Asn1Sequence seq) |
|
{ |
|
info = new ContentInfo[seq.Count]; |
|
|
|
for (int i = 0; i != info.Length; i++) |
|
{ |
|
info[i] = ContentInfo.GetInstance(seq[i]); |
|
} |
|
|
|
isBer = seq is BerSequence; |
|
} |
|
|
|
public AuthenticatedSafe( |
|
ContentInfo[] info) |
|
{ |
|
this.info = Copy(info); |
|
this.isBer = true; |
|
} |
|
|
|
public ContentInfo[] GetContentInfo() |
|
{ |
|
return Copy(info); |
|
} |
|
|
|
public override Asn1Object ToAsn1Object() |
|
{ |
|
if (isBer) |
|
{ |
|
return new BerSequence(info); |
|
} |
|
|
|
// TODO bc-java uses DL sequence |
|
//return new DLSequence(info); |
|
return new DerSequence(info); |
|
} |
|
} |
|
} |
|
#pragma warning restore |
|
#endif
|
|
|