summary refs log tree commit diff
path: root/Crypto/src/crypto/tls/TlsClient.cs
blob: eceaa3cd3532e23d5644bc976a85589b87afc4a1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
using System;
using System.Collections;
using System.IO;

namespace Org.BouncyCastle.Crypto.Tls
{
	public interface TlsClient
	{
		/// <summary>
		/// Called at the start of a new TLS session, before any other methods.
		/// </summary>
		/// <param name="context">
		/// A <see cref="TlsProtocolHandler"/>
		/// </param>
		void Init(TlsClientContext context);

		/// <summary>
		/// Get the list of cipher suites that this client supports.
		/// </summary>
		/// <returns>
        /// An array of <see cref="CipherSuite"/>, each specifying a supported cipher suite.
		/// </returns>
		CipherSuite[] GetCipherSuites();

        /// <summary>
        /// Get the list of compression methods that this client supports.
        /// </summary>
        /// <returns>
        /// An array of <see cref="CompressionMethod"/>, each specifying a supported compression method.
        /// </returns>
        CompressionMethod[] GetCompressionMethods();

		/// <summary>
		/// Get the (optional) table of client extensions to be included in (extended) client hello.
		/// </summary>
		/// <returns>
        /// A <see cref="IDictionary"/> (<see cref="ExtensionType"/> -> byte[]). May be null.
		/// </returns>
		/// <exception cref="IOException"></exception>
		IDictionary GetClientExtensions();

		/// <summary>
		/// Reports the session ID once it has been determined.
		/// </summary>
		/// <param name="sessionID">
		/// A <see cref="System.Byte"/>
		/// </param>
		void NotifySessionID(byte[] sessionID);

		/// <summary>
		/// Report the cipher suite that was selected by the server.
		/// </summary>
		/// <remarks>
		/// The protocol handler validates this value against the offered cipher suites
		/// <seealso cref="GetCipherSuites"/>
		/// </remarks>
		/// <param name="selectedCipherSuite">
		/// A <see cref="CipherSuite"/>
		/// </param>
		void NotifySelectedCipherSuite(CipherSuite selectedCipherSuite);

        /// <summary>
        /// Report the compression method that was selected by the server.
        /// </summary>
        /// <remarks>
        /// The protocol handler validates this value against the offered compression methods
        /// <seealso cref="GetCompressionMethods"/>
        /// </remarks>
        /// <param name="selectedCompressionMethod">
        /// A <see cref="CompressionMethod"/>
        /// </param>
        void NotifySelectedCompressionMethod(CompressionMethod selectedCompressionMethod);

		/// <summary>
		/// Report whether the server supports secure renegotiation
		/// </summary>
		/// <remarks>
		/// The protocol handler automatically processes the relevant extensions
		/// </remarks>
		/// <param name="secureRenegotiation">
		/// A <see cref="System.Boolean"/>, true if the server supports secure renegotiation
		/// </param>
		/// <exception cref="IOException"></exception>
		void NotifySecureRenegotiation(bool secureRenegotiation);

		/// <summary>
		/// Report the extensions from an extended server hello.
		/// </summary>
		/// <remarks>
		/// Will only be called if we returned a non-null result from <see cref="GetClientExtensions"/>.
		/// </remarks>
		/// <param name="serverExtensions">
        /// A <see cref="IDictionary"/>  (<see cref="ExtensionType"/> -> byte[])
		/// </param>
		void ProcessServerExtensions(IDictionary serverExtensions);

		/// <summary>
		/// Return an implementation of <see cref="TlsKeyExchange"/> to negotiate the key exchange
		/// part of the protocol.
		/// </summary>
		/// <returns>
		/// A <see cref="TlsKeyExchange"/>
		/// </returns>
		/// <exception cref="IOException"/>
		TlsKeyExchange GetKeyExchange();

		/// <summary>
		/// Return an implementation of <see cref="TlsAuthentication"/> to handle authentication
		/// part of the protocol.
		/// </summary>
		/// <exception cref="IOException"/>
		TlsAuthentication GetAuthentication();

		/// <summary>
		/// Return an implementation of <see cref="TlsCompression"/> to handle record compression.
		/// </summary>
		/// <exception cref="IOException"/>
		TlsCompression GetCompression();

		/// <summary>
		/// Return an implementation of <see cref="TlsCipher"/> to use for encryption/decryption.
		/// </summary>
		/// <returns>
		/// A <see cref="TlsCipher"/>
		/// </returns>
		/// <exception cref="IOException"/>
		TlsCipher GetCipher();
	}
}