ModDetectionCodePacket.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.IO;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Bcpg
  6. {
  7. /// <remarks>Basic packet for a modification detection code packet.</remarks>
  8. public class ModDetectionCodePacket
  9. : ContainedPacket
  10. {
  11. private readonly byte[] digest;
  12. internal ModDetectionCodePacket(
  13. BcpgInputStream bcpgIn)
  14. {
  15. if (bcpgIn == null)
  16. throw new ArgumentNullException("bcpgIn");
  17. this.digest = new byte[20];
  18. bcpgIn.ReadFully(this.digest);
  19. }
  20. public ModDetectionCodePacket(
  21. byte[] digest)
  22. {
  23. if (digest == null)
  24. throw new ArgumentNullException("digest");
  25. this.digest = (byte[]) digest.Clone();
  26. }
  27. public byte[] GetDigest()
  28. {
  29. return (byte[]) digest.Clone();
  30. }
  31. public override void Encode(
  32. BcpgOutputStream bcpgOut)
  33. {
  34. bcpgOut.WritePacket(PacketTag.ModificationDetectionCode, digest, false);
  35. }
  36. }
  37. }
  38. #pragma warning restore
  39. #endif