[System]: Fully stub-out SslStream on platforms where it's not supported (#4802)
[mono.git] / mcs / class / System / System.Net.Security / SslStream.cs
1 //
2 // SslStream.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
28
29 #if MONO_SECURITY_ALIAS
30 extern alias MonoSecurity;
31 #endif
32
33 #if MONO_SECURITY_ALIAS
34 using MonoSecurity::Mono.Security.Interface;
35 #else
36 using Mono.Security.Interface;
37 #endif
38
39 using CipherAlgorithmType = System.Security.Authentication.CipherAlgorithmType;
40 using HashAlgorithmType = System.Security.Authentication.HashAlgorithmType;
41 using ExchangeAlgorithmType = System.Security.Authentication.ExchangeAlgorithmType;
42 #endif
43
44 using System.IO;
45 using System.Net;
46 using System.Net.Security;
47 using System.Security.Authentication;
48 using System.Security.Cryptography.X509Certificates;
49 using System.Security.Permissions;
50 using System.Security.Principal;
51 using System.Security.Cryptography;
52 using System.Threading.Tasks;
53
54 using MNS = Mono.Net.Security;
55
56 namespace System.Net.Security
57 {
58         /*
59          * These two are defined by the referencesource; add them heere to make
60          * it easy to switch between the two implementations.
61          */
62
63         internal delegate bool RemoteCertValidationCallback (
64                 string host,
65                 X509Certificate certificate,
66                 X509Chain chain,
67                 SslPolicyErrors sslPolicyErrors);
68
69         internal delegate X509Certificate LocalCertSelectionCallback (
70                 string targetHost,
71                 X509CertificateCollection localCertificates,
72                 X509Certificate remoteCertificate,
73                 string[] acceptableIssuers);
74
75         public class SslStream : AuthenticatedStream
76         {
77 #if SECURITY_DEP
78                 MonoTlsProvider provider;
79                 IMonoSslStream impl;
80
81                 internal IMonoSslStream Impl {
82                         get {
83                                 CheckDisposed ();
84                                 return impl;
85                         }
86                 }
87
88                 internal MonoTlsProvider Provider {
89                         get {
90                                 CheckDisposed ();
91                                 return provider;
92                         }
93                 }
94
95                 static MonoTlsProvider GetProvider ()
96                 {
97                         return MonoTlsProviderFactory.GetProvider ();
98                 }
99
100                 public SslStream (Stream innerStream)
101                         : this (innerStream, false)
102                 {
103                 }
104
105                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen)
106                         : base (innerStream, leaveInnerStreamOpen)
107                 {
108                         provider = GetProvider ();
109                         impl = provider.CreateSslStreamInternal (this, innerStream, leaveInnerStreamOpen, null);
110                 }
111
112                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback)
113                         : this (innerStream, leaveInnerStreamOpen, userCertificateValidationCallback, null)
114                 {
115                 }
116
117                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback)
118                         : base (innerStream, leaveInnerStreamOpen)
119                 {
120                         provider = GetProvider ();
121                         var settings = MonoTlsSettings.CopyDefaultSettings ();
122                         settings.RemoteCertificateValidationCallback = MNS.Private.CallbackHelpers.PublicToMono (userCertificateValidationCallback);
123                         settings.ClientCertificateSelectionCallback = MNS.Private.CallbackHelpers.PublicToMono (userCertificateSelectionCallback);
124                         impl = provider.CreateSslStream (innerStream, leaveInnerStreamOpen, settings);
125                 }
126
127                 [MonoLimitation ("encryptionPolicy is ignored")]
128                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback, EncryptionPolicy encryptionPolicy)
129                 : this (innerStream, leaveInnerStreamOpen, userCertificateValidationCallback, userCertificateSelectionCallback)
130                 {
131                 }
132
133                 SslStream (Stream innerStream, bool leaveInnerStreamOpen, MonoTlsProvider provider, MonoTlsSettings settings)
134                         : base (innerStream, leaveInnerStreamOpen)
135                 {
136                         this.provider = provider;
137                         impl = provider.CreateSslStreamInternal (this, innerStream, leaveInnerStreamOpen, settings);
138                 }
139
140                 internal static IMonoSslStream CreateMonoSslStream (Stream innerStream, bool leaveInnerStreamOpen, MonoTlsProvider provider, MonoTlsSettings settings)
141                 {
142                         var sslStream = new SslStream (innerStream, leaveInnerStreamOpen, provider, settings);
143                         return sslStream.Impl;
144                 }
145
146                 public virtual void AuthenticateAsClient (string targetHost)
147                 {
148                         Impl.AuthenticateAsClient (targetHost);
149                 }
150
151                 public virtual void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
152                 {
153                         Impl.AuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
154                 }
155
156                 // [HostProtection (ExternalThreading=true)]
157                 public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
158                 {
159                         return Impl.BeginAuthenticateAsClient (targetHost, asyncCallback, asyncState);
160                 }
161
162                 // [HostProtection (ExternalThreading=true)]
163                 public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
164                 {
165                         return Impl.BeginAuthenticateAsClient (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
166                 }
167
168                 public virtual void EndAuthenticateAsClient (IAsyncResult asyncResult)
169                 {
170                         Impl.EndAuthenticateAsClient (asyncResult);
171                 }
172
173                 public virtual void AuthenticateAsServer (X509Certificate serverCertificate)
174                 {
175                         Impl.AuthenticateAsServer (serverCertificate);
176                 }
177
178                 public virtual void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
179                 {
180                         Impl.AuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
181                 }
182
183                 // [HostProtection (ExternalThreading=true)]
184                 public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
185                 {
186                         return Impl.BeginAuthenticateAsServer (serverCertificate, asyncCallback, asyncState);
187                 }
188
189                 public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
190                 {
191                         return Impl.BeginAuthenticateAsServer (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation, asyncCallback, asyncState);
192                 }
193
194                 public virtual void EndAuthenticateAsServer (IAsyncResult asyncResult)
195                 {
196                         Impl.EndAuthenticateAsServer (asyncResult);
197                 }
198
199                 public TransportContext TransportContext {
200                         get {
201                                 throw new NotSupportedException();
202                         }
203                 }
204
205                 // [HostProtection (ExternalThreading=true)]
206                 public virtual Task AuthenticateAsClientAsync (string targetHost)
207                 {
208                         return Impl.AuthenticateAsClientAsync (targetHost);
209                 }
210
211                 public virtual Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
212                 {
213                         return Impl.AuthenticateAsClientAsync (targetHost, clientCertificates, enabledSslProtocols, checkCertificateRevocation);
214                 }
215
216                 public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
217                 {
218                         return Impl.AuthenticateAsServerAsync (serverCertificate);
219                 }
220
221                 public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
222                 {
223                         return Impl.AuthenticateAsServerAsync (serverCertificate, clientCertificateRequired, enabledSslProtocols, checkCertificateRevocation);
224                 }
225
226                 public override bool IsAuthenticated {
227                         get { return Impl.IsAuthenticated; }
228                 }
229
230                 public override bool IsMutuallyAuthenticated {
231                         get { return Impl.IsMutuallyAuthenticated; }
232                 }
233
234                 public override bool IsEncrypted {
235                         get { return Impl.IsEncrypted; }
236                 }
237
238                 public override bool IsSigned {
239                         get { return Impl.IsSigned; }
240                 }
241
242                 public override bool IsServer {
243                         get { return Impl.IsServer; }
244                 }
245
246                 public virtual SslProtocols SslProtocol {
247                         get { return (SslProtocols)Impl.SslProtocol; }
248                 }
249
250                 public virtual bool CheckCertRevocationStatus {
251                         get { return Impl.CheckCertRevocationStatus; }
252                 }
253
254                 public virtual X509Certificate LocalCertificate {
255                         get { return Impl.LocalCertificate; }
256                 }
257
258                 public virtual X509Certificate RemoteCertificate {
259                         get { return Impl.RemoteCertificate; }
260                 }
261
262                 public virtual CipherAlgorithmType CipherAlgorithm {
263                         get { return (CipherAlgorithmType)Impl.CipherAlgorithm; }
264                 }
265
266                 public virtual int CipherStrength {
267                         get { return Impl.CipherStrength; }
268                 }
269
270                 public virtual HashAlgorithmType HashAlgorithm {
271                         get { return (HashAlgorithmType)Impl.HashAlgorithm; }
272                 }
273
274                 public virtual int HashStrength {
275                         get { return Impl.HashStrength; }
276                 }
277
278                 public virtual ExchangeAlgorithmType KeyExchangeAlgorithm {
279                         get { return (ExchangeAlgorithmType)Impl.KeyExchangeAlgorithm; }
280                 }
281
282                 public virtual int KeyExchangeStrength {
283                         get { return Impl.KeyExchangeStrength; }
284                 }
285
286                 public override bool CanSeek {
287                         get { return false; }
288                 }
289
290                 public override bool CanRead {
291                         get { return Impl.CanRead; }
292                 }
293
294                 public override bool CanTimeout {
295                         get { return Impl.CanTimeout; }
296                 }
297
298                 public override bool CanWrite {
299                         get { return Impl.CanWrite; }
300                 }
301
302                 public override int ReadTimeout {
303                         get { return Impl.ReadTimeout; }
304                         set { Impl.ReadTimeout = value; }
305                 }
306
307                 public override int WriteTimeout {
308                         get { return Impl.WriteTimeout; }
309                         set { Impl.WriteTimeout = value; }
310                 }
311
312                 public override long Length {
313                         get { return Impl.Length; }
314                 }
315
316                 public override long Position {
317                         get { return Impl.Position; }
318                         set {
319                                 throw new NotSupportedException (SR.GetString (SR.net_noseek));
320                         }
321                 }
322
323                 public override void SetLength (long value)
324                 {
325                         Impl.SetLength (value);
326                 }
327
328                 public override long Seek (long offset, SeekOrigin origin)
329                 {
330                         throw new NotSupportedException (SR.GetString (SR.net_noseek));
331                 }
332
333                 public override void Flush ()
334                 {
335                         Impl.Flush ();
336                 }
337
338                 void CheckDisposed ()
339                 {
340                         if (impl == null)
341                                 throw new ObjectDisposedException ("SslStream");
342                 }
343
344                 protected override void Dispose (bool disposing)
345                 {
346                         try {
347                                 if (impl != null && disposing) {
348                                         impl.Dispose ();
349                                         impl = null;
350                                 }
351                         } finally {
352                                 base.Dispose (disposing);
353                         }
354                 }
355
356                 public override int Read (byte[] buffer, int offset, int count)
357                 {
358                         return Impl.Read (buffer, offset, count);
359                 }
360
361                 public void Write (byte[] buffer)
362                 {
363                         Impl.Write (buffer);
364                 }
365
366                 public override void Write (byte[] buffer, int offset, int count)
367                 {
368                         Impl.Write (buffer, offset, count);
369                 }
370
371                 // [HostProtection (ExternalThreading=true)]
372                 public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
373                 {
374                         return Impl.BeginRead (buffer, offset, count, asyncCallback, asyncState);
375                 }
376
377                 public override int EndRead (IAsyncResult asyncResult)
378                 {
379                         return Impl.EndRead (asyncResult);
380                 }
381
382                 // [HostProtection (ExternalThreading=true)]
383                 public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
384                 {
385                         return Impl.BeginWrite (buffer, offset, count, asyncCallback, asyncState);
386                 }
387
388                 public override void EndWrite (IAsyncResult asyncResult)
389                 {
390                         Impl.EndWrite (asyncResult);
391                 }
392 #else // !SECURITY_DEP
393                 const string EXCEPTION_MESSAGE = "System.Net.Security.SslStream is not supported on the current platform.";
394
395                 public SslStream (Stream innerStream)
396                         : this (innerStream, false)
397                 {
398                 }
399
400                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen)
401                         : base (innerStream, leaveInnerStreamOpen)
402                 {
403                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
404                 }
405
406                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback)
407                         : this (innerStream, leaveInnerStreamOpen)
408                 {
409                 }
410
411                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback)
412                         : this (innerStream, leaveInnerStreamOpen)
413                 {
414                 }
415
416                 public SslStream (Stream innerStream, bool leaveInnerStreamOpen, RemoteCertificateValidationCallback userCertificateValidationCallback, LocalCertificateSelectionCallback userCertificateSelectionCallback, EncryptionPolicy encryptionPolicy)
417                         : this (innerStream, leaveInnerStreamOpen)
418                 {
419                 }
420
421                 public virtual void AuthenticateAsClient (string targetHost)
422                 {
423                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
424                 }
425
426                 public virtual void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
427                 {
428                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
429                 }
430
431                 public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState)
432                 {
433                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
434                 }
435
436                 public virtual IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
437                 {
438                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
439                 }
440
441                 public virtual void EndAuthenticateAsClient (IAsyncResult asyncResult)
442                 {
443                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
444                 }
445
446                 public virtual void AuthenticateAsServer (X509Certificate serverCertificate)
447                 {
448                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
449                 }
450
451                 public virtual void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
452                 {
453                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
454                 }
455
456                 public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState)
457                 {
458                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
459                 }
460
461                 public virtual IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState)
462                 {
463                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
464                 }
465
466                 public virtual void EndAuthenticateAsServer (IAsyncResult asyncResult)
467                 {
468                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
469                 }
470
471                 public TransportContext TransportContext {
472                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
473                 }
474
475                 public virtual Task AuthenticateAsClientAsync (string targetHost)
476                 {
477                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
478                 }
479
480                 public virtual Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
481                 {
482                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
483                 }
484
485                 public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate)
486                 {
487                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
488                 }
489
490                 public virtual Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation)
491                 {
492                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
493                 }
494
495                 public override bool IsAuthenticated {
496                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
497                 }
498
499                 public override bool IsMutuallyAuthenticated {
500                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
501                 }
502
503                 public override bool IsEncrypted {
504                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
505                 }
506
507                 public override bool IsSigned {
508                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
509                 }
510
511                 public override bool IsServer {
512                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
513                 }
514
515                 public virtual SslProtocols SslProtocol {
516                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
517                 }
518
519                 public virtual bool CheckCertRevocationStatus {
520                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
521                 }
522
523                 public virtual X509Certificate LocalCertificate {
524                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
525                 }
526
527                 public virtual X509Certificate RemoteCertificate {
528                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
529                 }
530
531                 public virtual CipherAlgorithmType CipherAlgorithm {
532                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
533                 }
534
535                 public virtual int CipherStrength {
536                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
537                 }
538
539                 public virtual HashAlgorithmType HashAlgorithm {
540                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
541                 }
542
543                 public virtual int HashStrength {
544                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
545                 }
546
547                 public virtual ExchangeAlgorithmType KeyExchangeAlgorithm {
548                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
549                 }
550
551                 public virtual int KeyExchangeStrength {
552                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
553                 }
554
555                 public override bool CanSeek {
556                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
557                 }
558
559                 public override bool CanRead {
560                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
561                 }
562
563                 public override bool CanTimeout {
564                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
565                 }
566
567                 public override bool CanWrite {
568                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
569                 }
570
571                 public override int ReadTimeout {
572                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
573                         set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
574                 }
575
576                 public override int WriteTimeout {
577                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
578                         set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
579                 }
580
581                 public override long Length {
582                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
583                 }
584
585                 public override long Position {
586                         get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
587                         set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
588                 }
589
590                 public override void SetLength (long value)
591                 {
592                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
593                 }
594
595                 public override long Seek (long offset, SeekOrigin origin)
596                 {
597                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
598                 }
599
600                 public override void Flush ()
601                 {
602                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
603                 }
604
605                 protected override void Dispose (bool disposing)
606                 {
607                 }
608
609                 public override int Read (byte[] buffer, int offset, int count)
610                 {
611                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
612                 }
613
614                 public void Write (byte[] buffer)
615                 {
616                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
617                 }
618
619                 public override void Write (byte[] buffer, int offset, int count)
620                 {
621                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
622                 }
623
624                 public override IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
625                 {
626                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
627                 }
628
629                 public override int EndRead (IAsyncResult asyncResult)
630                 {
631                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
632                 }
633
634                 public override IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState)
635                 {
636                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
637                 }
638
639                 public override void EndWrite (IAsyncResult asyncResult)
640                 {
641                         throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
642                 }
643 #endif
644         }
645 }