Automatic optimization bug bisector.
[mono.git] / mcs / class / System / Mono.Net.Security / IMonoSslStream.cs
1 //
2 // IMonoSslStream.cs
3 //
4 // Author:
5 //       Martin Baulig <martin.baulig@xamarin.com>
6 //
7 // Copyright (c) 2015 Xamarin, Inc.
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
15 //
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
18 //
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 // THE SOFTWARE.
26
27 #if SECURITY_DEP && MONO_X509_ALIAS
28 extern alias PrebuiltSystem;
29 using X509CertificateCollection = PrebuiltSystem::System.Security.Cryptography.X509Certificates.X509CertificateCollection;
30 #endif
31
32 using System;
33 using System.IO;
34 using System.Net;
35 using System.Net.Security;
36 using System.Threading.Tasks;
37 using System.Security.Authentication;
38 using System.Security.Cryptography.X509Certificates;
39 using System.Security.Principal;
40 using System.Security.Cryptography;
41
42 namespace Mono.Net.Security
43 {
44         interface IMonoSslStream : IDisposable
45         {
46                 AuthenticatedStream AuthenticatedStream {
47                         get;
48                 }
49
50                 void AuthenticateAsClient (string targetHost);
51
52                 void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
53
54                 IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState);
55
56                 IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates,
57                                                         SslProtocols enabledSslProtocols, bool checkCertificateRevocation,
58                                                         AsyncCallback asyncCallback, object asyncState);
59
60                 void EndAuthenticateAsClient (IAsyncResult asyncResult);
61
62                 void AuthenticateAsServer (X509Certificate serverCertificate);
63
64                 void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired,
65                                           SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
66
67                 IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState);
68
69                 IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired,
70                                                         SslProtocols enabledSslProtocols, bool checkCertificateRevocation,
71                                                         AsyncCallback asyncCallback,
72                                                         object asyncState);
73
74                 void EndAuthenticateAsServer (IAsyncResult asyncResult);
75
76                 TransportContext TransportContext {
77                         get;
78                 }
79
80                 Task AuthenticateAsClientAsync (string targetHost);
81
82                 Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
83
84                 Task AuthenticateAsServerAsync (X509Certificate serverCertificate);
85
86                 Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
87
88                 //
89                 //
90                 // Base class properties
91                 //
92                 bool IsAuthenticated {
93                         get;
94                 }
95
96                 bool IsMutuallyAuthenticated {
97                         get;
98                 }
99
100                 bool IsEncrypted {
101                         get;
102                 }
103
104                 bool IsSigned {
105                         get;
106                 }
107
108                 bool IsServer {
109                         get;
110                 }
111
112                 //
113                 //
114                 //SSL specific properties
115                 //
116                 //
117                 SslProtocols SslProtocol {
118                         get;
119                 }
120
121                 bool CheckCertRevocationStatus {
122                         get;
123                 }
124
125                 X509Certificate InternalLocalCertificate {
126                         get;
127                 }
128
129                 X509Certificate LocalCertificate {
130                         get;
131                 }
132
133                 X509Certificate RemoteCertificate {
134                         get;
135                 }
136
137                 //
138                 // More informational properties
139                 //
140                 CipherAlgorithmType CipherAlgorithm {
141                         get;
142                 }
143
144                 int CipherStrength {
145                         get;
146                 }
147
148                 HashAlgorithmType HashAlgorithm {
149                         get;
150                 }
151
152                 int HashStrength {
153                         get;
154                 }
155
156                 ExchangeAlgorithmType KeyExchangeAlgorithm {
157                         get;
158                 }
159
160                 int KeyExchangeStrength {
161                         get;
162                 }
163
164                 //
165                 //
166                 // Stream contract implementation
167                 //
168                 //
169                 //
170                 bool CanRead {
171                         get;
172                 }
173
174                 bool CanTimeout {
175                         get;
176                 }
177
178                 bool CanWrite {
179                         get;
180                 }
181
182                 int ReadTimeout {
183                         get;
184                         set;
185                 }
186
187                 int WriteTimeout {
188                         get;
189                         set;
190                 }
191
192                 long Length {
193                         get;
194                 }
195
196                 long Position {
197                         get;
198                 }
199
200                 void SetLength (long value);
201
202                 void Flush ();
203
204                 int Read (byte[] buffer, int offset, int count);
205
206                 void Write (byte[] buffer);
207
208                 void Write (byte[] buffer, int offset, int count);
209
210                 IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
211
212                 int EndRead (IAsyncResult asyncResult);
213
214                 IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
215
216                 void EndWrite (IAsyncResult asyncResult);
217         }
218 }
219