Welcome to mirror list, hosted at ThFree Co, Russian Federation.

CryptoStream.cs « System.Security.Cryptography « corlib « class « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6dad1ca628d9f25d34dde03c0d897c0d30e0aa3d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
//
// System.Security.Cryptography CryptoStream.cs
//
// Author:
//   Thomas Neidhart (tome@sbox.tugraz.at)
//

using System;
using System.IO;

namespace System.Security.Cryptography
{

	public class CryptoStream : Stream
	{
		private CryptoStreamMode _mode;
		
		public CryptoStream(Stream stream, ICryptoTransform transform, CryptoStreamMode mode) 
		{
			_mode = mode;
		}
		
		public override bool CanRead
		{
			get {
				switch (_mode) {
					case CryptoStreamMode.Read:
						return true;
					
					case CryptoStreamMode.Write:
						return false;
					
					default:
						return false;
				}
			}
		}

		public override bool CanSeek
		{
			get {
				return false;
			}
		}

		public override bool CanWrite
		{
			get {
				switch (_mode) {
					case CryptoStreamMode.Read:
						return false;
					
					case CryptoStreamMode.Write:
						return true;
					
					default:
						return false;
				}
			}
		}
		
		public override long Length
		{
			get {
				throw new NotSupportedException("Length property not supported by CryptoStream");
			}
		}

		public override long Position
		{
			get {
				throw new NotSupportedException("Position property not supported by CryptoStream");
			}
			set {
				throw new NotSupportedException("Position property not supported by CryptoStream");
			}
		}

		[MonoTODO]
		public override int Read(byte[] buffer, int offset, int count)
		{
			// TODO: implement
			return 0;
		}

		[MonoTODO]
		public override void Write(byte[] buffer, int offset, int count)
		{
			// TODO: implement
		}

		[MonoTODO]
		public override void Flush()
		{
			// TODO: implement
		}

		[MonoTODO]
		public void FlushFinalBlock()
		{
			if (_mode != CryptoStreamMode.Write)
				throw new NotSupportedException("cannot flush a non-writeable CryptoStream");
			
			// TODO: implement
		}

		public override long Seek(long offset, SeekOrigin origin)
		{
			throw new NotSupportedException("cannot seek a CryptoStream");
		}
		
		public override void SetLength(long value)
		{
			// LAMESPEC: should throw NotSupportedException like Seek??
			return;
		}
		
	} // CryptoStream
	
} // System.Security.Cryptography