Merge pull request #2223 from lobrien/master
[mono.git] / mcs / class / Mono.Security / Mono.Security.Interface / 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 using System;
27 using System.IO;
28 using System.Net;
29 using System.Net.Security;
30 using System.Threading.Tasks;
31 using SSA = System.Security.Authentication;
32 using System.Security.Cryptography.X509Certificates;
33 using System.Security.Principal;
34 using System.Security.Cryptography;
35 using Mono.Net.Security;
36
37 namespace Mono.Security.Interface
38 {
39         public interface IMonoSslStream : IDisposable
40         {
41                 void AuthenticateAsClient (string targetHost);
42
43                 void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
44
45                 IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState);
46
47                 IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
48
49                 void EndAuthenticateAsClient (IAsyncResult asyncResult);
50
51                 void AuthenticateAsServer (X509Certificate serverCertificate);
52
53                 void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
54
55                 IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState);
56
57                 IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
58
59                 void EndAuthenticateAsServer (IAsyncResult asyncResult);
60
61                 Task AuthenticateAsClientAsync (string targetHost);
62
63                 Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
64
65                 Task AuthenticateAsServerAsync (X509Certificate serverCertificate);
66
67                 Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
68
69                 void Flush ();
70
71                 int Read (byte[] buffer, int offset, int count);
72
73                 void Write (byte[] buffer);
74
75                 void Write (byte[] buffer, int offset, int count);
76
77                 IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
78
79                 int EndRead (IAsyncResult asyncResult);
80
81                 IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
82
83                 void EndWrite (IAsyncResult asyncResult);
84
85                 TransportContext TransportContext {
86                         get;
87                 }
88
89                 bool IsAuthenticated {
90                         get;
91                 }
92
93                 bool IsMutuallyAuthenticated {
94                         get;
95                 }
96
97                 bool IsEncrypted {
98                         get;
99                 }
100
101                 bool IsSigned {
102                         get;
103                 }
104
105                 bool IsServer {
106                         get;
107                 }
108
109                 SSA.CipherAlgorithmType CipherAlgorithm {
110                         get;
111                 }
112
113                 int CipherStrength {
114                         get;
115                 }
116
117                 SSA.HashAlgorithmType HashAlgorithm {
118                         get;
119                 }
120
121                 int HashStrength {
122                         get;
123                 }
124
125                 SSA.ExchangeAlgorithmType KeyExchangeAlgorithm {
126                         get;
127                 }
128
129                 int KeyExchangeStrength {
130                         get;
131                 }
132
133                 bool CanRead {
134                         get;
135                 }
136
137                 bool CanTimeout {
138                         get;
139                 }
140
141                 bool CanWrite {
142                         get;
143                 }
144
145                 long Length {
146                         get;
147                 }
148
149                 long Position {
150                         get;
151                 }
152
153                 void SetLength (long value);
154
155                 AuthenticatedStream AuthenticatedStream {
156                         get;
157                 }
158
159                 int ReadTimeout {
160                         get; set;
161                 }
162
163                 int WriteTimeout {
164                         get; set;
165                 }
166
167                 bool CheckCertRevocationStatus {
168                         get;
169                 }
170
171                 X509Certificate InternalLocalCertificate {
172                         get;
173                 }
174
175                 X509Certificate LocalCertificate {
176                         get;
177                 }
178
179                 X509Certificate RemoteCertificate {
180                         get;
181                 }
182
183                 SSA.SslProtocols SslProtocol {
184                         get;
185                 }
186         }
187 }
188