SignatureExpirationTime.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Bcpg.Sig
  5. {
  6. /**
  7. * packet giving signature expiration time.
  8. */
  9. public class SignatureExpirationTime
  10. : SignatureSubpacket
  11. {
  12. protected static byte[] TimeToBytes(
  13. long t)
  14. {
  15. byte[] data = new byte[4];
  16. data[0] = (byte)(t >> 24);
  17. data[1] = (byte)(t >> 16);
  18. data[2] = (byte)(t >> 8);
  19. data[3] = (byte)t;
  20. return data;
  21. }
  22. public SignatureExpirationTime(
  23. bool critical,
  24. bool isLongLength,
  25. byte[] data)
  26. : base(SignatureSubpacketTag.ExpireTime, critical, isLongLength, data)
  27. {
  28. }
  29. public SignatureExpirationTime(
  30. bool critical,
  31. long seconds)
  32. : base(SignatureSubpacketTag.ExpireTime, critical, false, TimeToBytes(seconds))
  33. {
  34. }
  35. /**
  36. * return time in seconds before signature expires after creation time.
  37. */
  38. public long Time
  39. {
  40. get
  41. {
  42. long time = ((long)(data[0] & 0xff) << 24) | ((long)(data[1] & 0xff) << 16)
  43. | ((long)(data[2] & 0xff) << 8) | ((long)data[3] & 0xff);
  44. return time;
  45. }
  46. }
  47. }
  48. }
  49. #pragma warning restore
  50. #endif