PreferredAlgorithms.cs 1.4 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 signature creation time.
  8. */
  9. public class PreferredAlgorithms
  10. : SignatureSubpacket
  11. {
  12. private static byte[] IntToByteArray(
  13. int[] v)
  14. {
  15. byte[] data = new byte[v.Length];
  16. for (int i = 0; i != v.Length; i++)
  17. {
  18. data[i] = (byte)v[i];
  19. }
  20. return data;
  21. }
  22. public PreferredAlgorithms(
  23. SignatureSubpacketTag type,
  24. bool critical,
  25. bool isLongLength,
  26. byte[] data)
  27. : base(type, critical, isLongLength, data)
  28. {
  29. }
  30. public PreferredAlgorithms(
  31. SignatureSubpacketTag type,
  32. bool critical,
  33. int[] preferences)
  34. : base(type, critical, false, IntToByteArray(preferences))
  35. {
  36. }
  37. public int[] GetPreferences()
  38. {
  39. int[] v = new int[data.Length];
  40. for (int i = 0; i != v.Length; i++)
  41. {
  42. v[i] = data[i] & 0xff;
  43. }
  44. return v;
  45. }
  46. }
  47. }
  48. #pragma warning restore
  49. #endif