SafeBag.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Pkcs
  5. {
  6. public class SafeBag
  7. : Asn1Encodable
  8. {
  9. private readonly DerObjectIdentifier bagID;
  10. private readonly Asn1Object bagValue;
  11. private readonly Asn1Set bagAttributes;
  12. public SafeBag(
  13. DerObjectIdentifier oid,
  14. Asn1Object obj)
  15. {
  16. this.bagID = oid;
  17. this.bagValue = obj;
  18. this.bagAttributes = null;
  19. }
  20. public SafeBag(
  21. DerObjectIdentifier oid,
  22. Asn1Object obj,
  23. Asn1Set bagAttributes)
  24. {
  25. this.bagID = oid;
  26. this.bagValue = obj;
  27. this.bagAttributes = bagAttributes;
  28. }
  29. public SafeBag(
  30. Asn1Sequence seq)
  31. {
  32. this.bagID = (DerObjectIdentifier) seq[0];
  33. this.bagValue = ((DerTaggedObject) seq[1]).GetObject();
  34. if (seq.Count == 3)
  35. {
  36. this.bagAttributes = (Asn1Set) seq[2];
  37. }
  38. }
  39. public DerObjectIdentifier BagID
  40. {
  41. get { return bagID; }
  42. }
  43. public Asn1Object BagValue
  44. {
  45. get { return bagValue; }
  46. }
  47. public Asn1Set BagAttributes
  48. {
  49. get { return bagAttributes; }
  50. }
  51. public override Asn1Object ToAsn1Object()
  52. {
  53. Asn1EncodableVector v = new Asn1EncodableVector(
  54. bagID, new DerTaggedObject(0, bagValue));
  55. if (bagAttributes != null)
  56. {
  57. v.Add(bagAttributes);
  58. }
  59. return new DerSequence(v);
  60. }
  61. }
  62. }
  63. #pragma warning restore
  64. #endif