SignerUserId.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. namespace Best.HTTP.SecureProtocol.Org.BouncyCastle.Bcpg.Sig
  4. {
  5. /**
  6. * packet giving the User ID of the signer.
  7. */
  8. public class SignerUserId
  9. : SignatureSubpacket
  10. {
  11. private static byte[] UserIdToBytes(
  12. string id)
  13. {
  14. byte[] idData = new byte[id.Length];
  15. for (int i = 0; i != id.Length; i++)
  16. {
  17. idData[i] = (byte)id[i];
  18. }
  19. return idData;
  20. }
  21. public SignerUserId(
  22. bool critical,
  23. bool isLongLength,
  24. byte[] data)
  25. : base(SignatureSubpacketTag.SignerUserId, critical, isLongLength, data)
  26. {
  27. }
  28. public SignerUserId(
  29. bool critical,
  30. string userId)
  31. : base(SignatureSubpacketTag.SignerUserId, critical, false, UserIdToBytes(userId))
  32. {
  33. }
  34. public string GetId()
  35. {
  36. char[] chars = new char[data.Length];
  37. for (int i = 0; i != chars.Length; i++)
  38. {
  39. chars[i] = (char)(data[i] & 0xff);
  40. }
  41. return new string(chars);
  42. }
  43. }
  44. }
  45. #pragma warning restore
  46. #endif