SignerUserId.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 the User ID of the signer.
  8. */
  9. public class SignerUserId
  10. : SignatureSubpacket
  11. {
  12. private static byte[] UserIdToBytes(
  13. string id)
  14. {
  15. byte[] idData = new byte[id.Length];
  16. for (int i = 0; i != id.Length; i++)
  17. {
  18. idData[i] = (byte)id[i];
  19. }
  20. return idData;
  21. }
  22. public SignerUserId(
  23. bool critical,
  24. bool isLongLength,
  25. byte[] data)
  26. : base(SignatureSubpacketTag.SignerUserId, critical, isLongLength, data)
  27. {
  28. }
  29. public SignerUserId(
  30. bool critical,
  31. string userId)
  32. : base(SignatureSubpacketTag.SignerUserId, critical, false, UserIdToBytes(userId))
  33. {
  34. }
  35. public string GetId()
  36. {
  37. char[] chars = new char[data.Length];
  38. for (int i = 0; i != chars.Length; i++)
  39. {
  40. chars[i] = (char)(data[i] & 0xff);
  41. }
  42. return new string(chars);
  43. }
  44. }
  45. }
  46. #pragma warning restore
  47. #endif