Features.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  5. namespace BestHTTP.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. byte[] data = new byte[1];
  24. data[0] = feature;
  25. return data;
  26. }
  27. public Features(
  28. bool critical,
  29. bool isLongLength,
  30. byte[] data): base(SignatureSubpacketTag.Features, critical, isLongLength, data)
  31. {
  32. }
  33. public Features(bool critical, byte features): this(critical, false, featureToByteArray(features))
  34. {
  35. }
  36. public Features(bool critical, int features): this(critical, false, featureToByteArray((byte)features))
  37. {
  38. }
  39. /**
  40. * Returns if modification detection is supported.
  41. */
  42. public bool SupportsModificationDetection
  43. {
  44. get { return SupportsFeature(FEATURE_MODIFICATION_DETECTION); }
  45. }
  46. /**
  47. * Returns if a particular feature is supported.
  48. */
  49. public bool SupportsFeature(byte feature)
  50. {
  51. return (data[0] & feature) != 0;
  52. }
  53. }
  54. }
  55. #pragma warning restore
  56. #endif