Convert MonoGenericContainer/Param accessor macros to inline functions
[mono.git] / mcs / class / Mono.Security / Mono.Security.Interface / MonoSslStream.cs
1 //
2 // MonoSslStream.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 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 abstract class MonoSslStream : IDisposable
40         {
41                 public abstract void AuthenticateAsClient (string targetHost);
42
43                 public abstract void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
44
45                 public abstract IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState);
46
47                 public abstract IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
48
49                 public abstract void EndAuthenticateAsClient (IAsyncResult asyncResult);
50
51                 public abstract void AuthenticateAsServer (X509Certificate serverCertificate);
52
53                 public abstract void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
54
55                 public abstract IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState);
56
57                 public abstract IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
58
59                 public abstract void EndAuthenticateAsServer (IAsyncResult asyncResult);
60
61                 public abstract Task AuthenticateAsClientAsync (string targetHost);
62
63                 public abstract Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
64
65                 public abstract Task AuthenticateAsServerAsync (X509Certificate serverCertificate);
66
67                 public abstract Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
68
69                 public abstract void Flush ();
70
71                 public abstract int Read (byte[] buffer, int offset, int count);
72
73                 public abstract void Write (byte[] buffer);
74
75                 public abstract void Write (byte[] buffer, int offset, int count);
76
77                 public abstract IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
78
79                 public abstract int EndRead (IAsyncResult asyncResult);
80
81                 public abstract IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
82
83                 public abstract void EndWrite (IAsyncResult asyncResult);
84
85                 public abstract TransportContext TransportContext {
86                         get;
87                 }
88
89                 public abstract bool IsAuthenticated {
90                         get;
91                 }
92
93                 public abstract bool IsMutuallyAuthenticated {
94                         get;
95                 }
96
97                 public abstract bool IsEncrypted {
98                         get;
99                 }
100
101                 public abstract bool IsSigned {
102                         get;
103                 }
104
105                 public abstract bool IsServer {
106                         get;
107                 }
108
109                 public abstract CipherAlgorithmType CipherAlgorithm {
110                         get;
111                 }
112
113                 public abstract int CipherStrength {
114                         get;
115                 }
116
117                 public abstract HashAlgorithmType HashAlgorithm {
118                         get;
119                 }
120
121                 public abstract int HashStrength {
122                         get;
123                 }
124
125                 public abstract ExchangeAlgorithmType KeyExchangeAlgorithm {
126                         get;
127                 }
128
129                 public abstract int KeyExchangeStrength {
130                         get;
131                 }
132
133                 public abstract bool CanRead {
134                         get;
135                 }
136
137                 public abstract bool CanTimeout {
138                         get;
139                 }
140
141                 public abstract bool CanWrite {
142                         get;
143                 }
144
145                 public abstract long Length {
146                         get;
147                 }
148
149                 public abstract long Position {
150                         get;
151                 }
152
153                 public abstract void SetLength (long value);
154
155                 public abstract AuthenticatedStream AuthenticatedStream {
156                         get;
157                 }
158
159                 public abstract int ReadTimeout {
160                         get; set;
161                 }
162
163                 public abstract int WriteTimeout {
164                         get; set;
165                 }
166
167                 public abstract bool CheckCertRevocationStatus {
168                         get;
169                 }
170
171                 public abstract X509Certificate InternalLocalCertificate {
172                         get;
173                 }
174
175                 public abstract X509Certificate LocalCertificate {
176                         get;
177                 }
178
179                 public abstract X509Certificate RemoteCertificate {
180                         get;
181                 }
182
183                 public abstract SslProtocols SslProtocol {
184                         get;
185                 }
186
187                 public void Dispose ()
188                 {
189                         Dispose (true);
190                         GC.SuppressFinalize (this);
191                 }
192
193                 protected virtual void Dispose (bool disposing)
194                 {
195                 }
196
197                 ~MonoSslStream ()
198                 {
199                         Dispose (false);
200                 }
201         }
202 }
203