PrfAlgorithm.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Tls
  5. {
  6. /// <summary>RFC 5246</summary>
  7. /// <remarks>
  8. /// Note that the values here are implementation-specific and arbitrary. It is recommended not to depend on the
  9. /// particular values (e.g. serialization).
  10. /// </remarks>
  11. public abstract class PrfAlgorithm
  12. {
  13. public const int ssl_prf_legacy = 0;
  14. public const int tls_prf_legacy = 1;
  15. public const int tls_prf_sha256 = 2;
  16. public const int tls_prf_sha384 = 3;
  17. public const int tls13_hkdf_sha256 = 4;
  18. public const int tls13_hkdf_sha384 = 5;
  19. //public const int tls13_hkdf_sha512 = 6;
  20. public const int tls13_hkdf_sm3 = 7;
  21. public static string GetName(int prfAlgorithm)
  22. {
  23. switch (prfAlgorithm)
  24. {
  25. case ssl_prf_legacy:
  26. return "ssl_prf_legacy";
  27. case tls_prf_legacy:
  28. return "tls_prf_legacy";
  29. case tls_prf_sha256:
  30. return "tls_prf_sha256";
  31. case tls_prf_sha384:
  32. return "tls_prf_sha384";
  33. case tls13_hkdf_sha256:
  34. return "tls13_hkdf_sha256";
  35. case tls13_hkdf_sha384:
  36. return "tls13_hkdf_sha384";
  37. case tls13_hkdf_sm3:
  38. return "tls13_hkdf_sm3";
  39. default:
  40. return "UNKNOWN";
  41. }
  42. }
  43. public static string GetText(int prfAlgorithm)
  44. {
  45. return GetName(prfAlgorithm) + "(" + prfAlgorithm + ")";
  46. }
  47. }
  48. }
  49. #pragma warning restore
  50. #endif