KeyExpirationTime.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Crypto.Utilities;
  4. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Bcpg.Sig
  5. {
  6. /**
  7. * packet giving time after creation at which the key expires.
  8. */
  9. public class KeyExpirationTime
  10. : SignatureSubpacket
  11. {
  12. protected static byte[] TimeToBytes(long t)
  13. {
  14. return Pack.UInt32_To_BE((uint)t);
  15. }
  16. public KeyExpirationTime(
  17. bool critical,
  18. bool isLongLength,
  19. byte[] data)
  20. : base(SignatureSubpacketTag.KeyExpireTime, critical, isLongLength, data)
  21. {
  22. }
  23. public KeyExpirationTime(
  24. bool critical,
  25. long seconds)
  26. : base(SignatureSubpacketTag.KeyExpireTime, critical, false, TimeToBytes(seconds))
  27. {
  28. }
  29. /**
  30. * Return the number of seconds after creation time a key is valid for.
  31. *
  32. * @return second count for key validity.
  33. */
  34. public long Time => (long)Pack.BE_To_UInt32(data);
  35. }
  36. }
  37. #pragma warning restore
  38. #endif