2002-06-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mcs / class / corlib / System.Security.Cryptography / CryptoStream.cs
1 //\r
2 // System.Security.Cryptography CryptoStream.cs\r
3 //\r
4 // Author:\r
5 //   Thomas Neidhart (tome@sbox.tugraz.at)\r
6 //\r
7 \r
8 using System;\r
9 using System.IO;\r
10 \r
11 namespace System.Security.Cryptography\r
12 {\r
13 \r
14         public class CryptoStream : Stream\r
15         {\r
16                 private CryptoStreamMode _mode;\r
17                 \r
18                 public CryptoStream(Stream stream, ICryptoTransform transform, CryptoStreamMode mode) \r
19                 {\r
20                         _mode = mode;\r
21                 }\r
22                 \r
23                 public override bool CanRead\r
24                 {\r
25                         get {\r
26                                 switch (_mode) {\r
27                                         case CryptoStreamMode.Read:\r
28                                                 return true;\r
29                                         \r
30                                         case CryptoStreamMode.Write:\r
31                                                 return false;\r
32                                         \r
33                                         default:\r
34                                                 return false;\r
35                                 }\r
36                         }\r
37                 }\r
38 \r
39                 public override bool CanSeek\r
40                 {\r
41                         get {\r
42                                 return false;\r
43                         }\r
44                 }\r
45 \r
46                 public override bool CanWrite\r
47                 {\r
48                         get {\r
49                                 switch (_mode) {\r
50                                         case CryptoStreamMode.Read:\r
51                                                 return false;\r
52                                         \r
53                                         case CryptoStreamMode.Write:\r
54                                                 return true;\r
55                                         \r
56                                         default:\r
57                                                 return false;\r
58                                 }\r
59                         }\r
60                 }\r
61                 \r
62                 public override long Length\r
63                 {\r
64                         get {\r
65                                 throw new NotSupportedException("Length property not supported by CryptoStream");\r
66                         }\r
67                 }\r
68 \r
69                 public override long Position\r
70                 {\r
71                         get {\r
72                                 throw new NotSupportedException("Position property not supported by CryptoStream");\r
73                         }\r
74                         set {\r
75                                 throw new NotSupportedException("Position property not supported by CryptoStream");\r
76                         }\r
77                 }\r
78 \r
79                 [MonoTODO]\r
80                 public override int Read(byte[] buffer, int offset, int count)\r
81                 {\r
82                         // TODO: implement\r
83                         return 0;\r
84                 }\r
85 \r
86                 [MonoTODO]\r
87                 public override void Write(byte[] buffer, int offset, int count)\r
88                 {\r
89                         // TODO: implement\r
90                 }\r
91 \r
92                 [MonoTODO]\r
93                 public override void Flush()\r
94                 {\r
95                         // TODO: implement\r
96                 }\r
97 \r
98                 [MonoTODO]\r
99                 public void FlushFinalBlock()\r
100                 {\r
101                         if (_mode != CryptoStreamMode.Write)\r
102                                 throw new NotSupportedException("cannot flush a non-writeable CryptoStream");\r
103                         \r
104                         // TODO: implement\r
105                 }\r
106 \r
107                 public override long Seek(long offset, SeekOrigin origin)\r
108                 {\r
109                         throw new NotSupportedException("cannot seek a CryptoStream");\r
110                 }\r
111                 \r
112                 public override void SetLength(long value)\r
113                 {\r
114                         // LAMESPEC: should throw NotSupportedException like Seek??\r
115                         return;\r
116                 }\r
117                 \r
118         } // CryptoStream\r
119         \r
120 } // System.Security.Cryptography\r