PrimaryUserId.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 whether or not the signature is signed using the primary user ID for the key.
  8. */
  9. public class PrimaryUserId
  10. : SignatureSubpacket
  11. {
  12. private static byte[] BooleanToByteArray(
  13. bool val)
  14. {
  15. byte[] data = new byte[1];
  16. if (val)
  17. {
  18. data[0] = 1;
  19. return data;
  20. }
  21. else
  22. {
  23. return data;
  24. }
  25. }
  26. public PrimaryUserId(
  27. bool critical,
  28. bool isLongLength,
  29. byte[] data)
  30. : base(SignatureSubpacketTag.PrimaryUserId, critical, isLongLength, data)
  31. {
  32. }
  33. public PrimaryUserId(
  34. bool critical,
  35. bool isPrimaryUserId)
  36. : base(SignatureSubpacketTag.PrimaryUserId, critical, false, BooleanToByteArray(isPrimaryUserId))
  37. {
  38. }
  39. public bool IsPrimaryUserId()
  40. {
  41. return data[0] != 0;
  42. }
  43. }
  44. }
  45. #pragma warning restore
  46. #endif