TlsPeer.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #if !BESTHTTP_DISABLE_ALTERNATE_SSL && (!UNITY_WEBGL || UNITY_EDITOR)
  2. #pragma warning disable
  3. using System;
  4. using System.IO;
  5. namespace BestHTTP.SecureProtocol.Org.BouncyCastle.Crypto.Tls
  6. {
  7. public interface TlsPeer
  8. {
  9. /// <summary>
  10. /// This implementation supports RFC 7627 and will always negotiate the extended_master_secret
  11. /// extension where possible.
  12. /// </summary>
  13. /// <remarks>
  14. /// When connecting to a peer that does not offer/accept this extension, it is recommended to
  15. /// abort the handshake. This option is provided for interoperability with legacy peers,
  16. /// although some TLS features will be disabled in that case (see RFC 7627 5.4).
  17. /// </remarks>
  18. /// <returns>
  19. /// <code>true</code> if the handshake should be aborted when the peer does not negotiate the
  20. /// extended_master_secret extension, or <code>false</code> to support legacy interoperability.
  21. /// </returns>
  22. bool RequiresExtendedMasterSecret();
  23. /// <summary>
  24. /// draft-mathewson-no-gmtunixtime-00 2. "If existing users of a TLS implementation may rely on
  25. /// gmt_unix_time containing the current time, we recommend that implementors MAY provide the
  26. /// ability to set gmt_unix_time as an option only, off by default."
  27. /// </summary>
  28. /// <returns>
  29. /// <code>true</code> if the current time should be used in the gmt_unix_time field of
  30. /// Random, or <code>false</code> if gmt_unix_time should contain a cryptographically
  31. /// random value.
  32. /// </returns>
  33. bool ShouldUseGmtUnixTime();
  34. /// <summary>
  35. /// Report whether the server supports secure renegotiation
  36. /// </summary>
  37. /// <remarks>
  38. /// The protocol handler automatically processes the relevant extensions
  39. /// </remarks>
  40. /// <param name="secureRenegotiation">
  41. /// A <see cref="System.Boolean"/>, true if the server supports secure renegotiation
  42. /// </param>
  43. /// <exception cref="IOException"></exception>
  44. void NotifySecureRenegotiation(bool secureRenegotiation);
  45. /// <summary>
  46. /// Return an implementation of <see cref="TlsCompression"/> to handle record compression.
  47. /// </summary>
  48. /// <returns>A <see cref="TlsCompression"/></returns>
  49. /// <exception cref="IOException"/>
  50. TlsCompression GetCompression();
  51. /// <summary>
  52. /// Return an implementation of <see cref="TlsCipher"/> to use for encryption/decryption.
  53. /// </summary>
  54. /// <returns>A <see cref="TlsCipher"/></returns>
  55. /// <exception cref="IOException"/>
  56. TlsCipher GetCipher();
  57. /// <summary>This method will be called when an alert is raised by the protocol.</summary>
  58. /// <param name="alertLevel"><see cref="AlertLevel"/></param>
  59. /// <param name="alertDescription"><see cref="AlertDescription"/></param>
  60. /// <param name="message">A human-readable message explaining what caused this alert. May be null.</param>
  61. /// <param name="cause">The <c>Exception</c> that caused this alert to be raised. May be null.</param>
  62. void NotifyAlertRaised(byte alertLevel, byte alertDescription, string message, Exception cause);
  63. /// <summary>This method will be called when an alert is received from the remote peer.</summary>
  64. /// <param name="alertLevel"><see cref="AlertLevel"/></param>
  65. /// <param name="alertDescription"><see cref="AlertDescription"/></param>
  66. void NotifyAlertReceived(byte alertLevel, byte alertDescription);
  67. /// <summary>Notifies the peer that the handshake has been successfully completed.</summary>
  68. /// <exception cref="IOException"></exception>
  69. void NotifyHandshakeComplete();
  70. }
  71. }
  72. #pragma warning restore
  73. #endif