Features.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using Best.HTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  5. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Bcpg.Sig
  6. {
  7. /**
  8. * packet giving signature expiration time.
  9. */
  10. public class Features
  11. : SignatureSubpacket
  12. {
  13. /** Identifier for the Modification Detection (packets 18 and 19) */
  14. public static readonly byte FEATURE_MODIFICATION_DETECTION = 0x01;
  15. /** Identifier for the AEAD Encrypted Data Packet (packet 20) and version 5
  16. Symmetric-Key Encrypted Session Key Packets (packet 3) */
  17. public static readonly byte FEATURE_AEAD_ENCRYPTED_DATA = 0x02;
  18. /** Identifier for the Version 5 Public-Key Packet format and corresponding new
  19. fingerprint format */
  20. public static readonly byte FEATURE_VERSION_5_PUBLIC_KEY = 0x04;
  21. private static byte[] FeatureToByteArray(byte feature)
  22. {
  23. return new byte[1]{ feature };
  24. }
  25. public Features(
  26. bool critical,
  27. bool isLongLength,
  28. byte[] data)
  29. : base(SignatureSubpacketTag.Features, critical, isLongLength, data)
  30. {
  31. }
  32. public Features(bool critical, byte features): this(critical, false, FeatureToByteArray(features))
  33. {
  34. }
  35. public Features(bool critical, int features): this(critical, false, FeatureToByteArray((byte)features))
  36. {
  37. }
  38. /**
  39. * Returns if modification detection is supported.
  40. */
  41. public bool SupportsModificationDetection
  42. {
  43. get { return SupportsFeature(FEATURE_MODIFICATION_DETECTION); }
  44. }
  45. /**
  46. * Returns if a particular feature is supported.
  47. */
  48. public bool SupportsFeature(byte feature)
  49. {
  50. return (data[0] & feature) != 0;
  51. }
  52. }
  53. }
  54. #pragma warning restore
  55. #endif