SecurityParameters.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using BestHTTP.SecureProtocol.Org.BouncyCastle.Utilities;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Tls
  6. {
  7. public class SecurityParameters
  8. {
  9. internal int entity = -1;
  10. internal int cipherSuite = -1;
  11. internal byte compressionAlgorithm = CompressionMethod.cls_null;
  12. internal int prfAlgorithm = -1;
  13. internal int verifyDataLength = -1;
  14. internal byte[] masterSecret = null;
  15. internal byte[] clientRandom = null;
  16. internal byte[] serverRandom = null;
  17. internal byte[] sessionHash = null;
  18. internal byte[] pskIdentity = null;
  19. internal byte[] srpIdentity = null;
  20. // TODO Keep these internal, since it's maybe not the ideal place for them
  21. internal short maxFragmentLength = -1;
  22. internal bool truncatedHMac = false;
  23. internal bool encryptThenMac = false;
  24. internal bool extendedMasterSecret = false;
  25. internal virtual void Clear()
  26. {
  27. if (this.masterSecret != null)
  28. {
  29. Arrays.Fill(this.masterSecret, (byte)0);
  30. this.masterSecret = null;
  31. }
  32. }
  33. /**
  34. * @return {@link ConnectionEnd}
  35. */
  36. public virtual int Entity
  37. {
  38. get { return entity; }
  39. }
  40. /**
  41. * @return {@link CipherSuite}
  42. */
  43. public virtual int CipherSuite
  44. {
  45. get { return cipherSuite; }
  46. }
  47. /**
  48. * @return {@link CompressionMethod}
  49. */
  50. public virtual byte CompressionAlgorithm
  51. {
  52. get { return compressionAlgorithm; }
  53. }
  54. /**
  55. * @return {@link PRFAlgorithm}
  56. */
  57. public virtual int PrfAlgorithm
  58. {
  59. get { return prfAlgorithm; }
  60. }
  61. public virtual int VerifyDataLength
  62. {
  63. get { return verifyDataLength; }
  64. }
  65. public virtual byte[] MasterSecret
  66. {
  67. get { return masterSecret; }
  68. }
  69. public virtual byte[] ClientRandom
  70. {
  71. get { return clientRandom; }
  72. }
  73. public virtual byte[] ServerRandom
  74. {
  75. get { return serverRandom; }
  76. }
  77. public virtual byte[] SessionHash
  78. {
  79. get { return sessionHash; }
  80. }
  81. public virtual byte[] PskIdentity
  82. {
  83. get { return pskIdentity; }
  84. }
  85. public virtual byte[] SrpIdentity
  86. {
  87. get { return srpIdentity; }
  88. }
  89. public virtual bool IsExtendedMasterSecret
  90. {
  91. get { return extendedMasterSecret; }
  92. }
  93. }
  94. }
  95. #pragma warning restore
  96. #endif