IDEACBCPar.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. v.AddOptional(iv);
  53. return new DerSequence(v);
  54. }
  55. }
  56. }
  57. #pragma warning restore
  58. #endif