IDEACBCPar.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Asn1.Misc
  6. {
  7. public class IdeaCbcPar
  8. : Asn1Encodable
  9. {
  10. internal Asn1OctetString iv;
  11. public static IdeaCbcPar GetInstance(
  12. object o)
  13. {
  14. if (o is IdeaCbcPar)
  15. {
  16. return (IdeaCbcPar) o;
  17. }
  18. if (o is Asn1Sequence)
  19. {
  20. return new IdeaCbcPar((Asn1Sequence) o);
  21. }
  22. throw new ArgumentException("unknown object in IDEACBCPar factory");
  23. }
  24. public IdeaCbcPar(
  25. byte[] iv)
  26. {
  27. this.iv = new DerOctetString(iv);
  28. }
  29. private IdeaCbcPar(
  30. Asn1Sequence seq)
  31. {
  32. if (seq.Count == 1)
  33. {
  34. iv = (Asn1OctetString) seq[0];
  35. }
  36. }
  37. public byte[] GetIV()
  38. {
  39. return iv == null ? null : iv.GetOctets();
  40. }
  41. /**
  42. * Produce an object suitable for an Asn1OutputStream.
  43. * <pre>
  44. * IDEA-CBCPar ::= Sequence {
  45. * iv OCTET STRING OPTIONAL -- exactly 8 octets
  46. * }
  47. * </pre>
  48. */
  49. public override Asn1Object ToAsn1Object()
  50. {
  51. Asn1EncodableVector v = new Asn1EncodableVector();
  52. if (iv != null)
  53. {
  54. v.Add(iv);
  55. }
  56. return new DerSequence(v);
  57. }
  58. }
  59. }
  60. #pragma warning restore
  61. #endif