-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
Milestone
Description
class ReadOnlyStream : Stream
{
public override void Flush() => throw new NotSupportedException();
public override int Read(byte[] buffer, int offset, int count) => count;
public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException();
public override void SetLength(long value) => throw new NotSupportedException();
public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException();
public override bool CanRead => true;
public override bool CanSeek => false;
public override bool CanWrite => false;
public override long Length => throw new NotSupportedException();
public override long Position
{
get => throw new NotSupportedException();
set => throw new NotSupportedException();
}
}
static void Main(string[] args)
{
var aes = Aes.Create().CreateDecryptor();
var crypto = new CryptoStream(new ReadOnlyStream(), aes, CryptoStreamMode.Read, false);
crypto.Dispose();
}
I'm not sure if that's the intended behavior, but it makes no logical sense to me and also prevents me from reading encrypted payload from http requests in ASP.NET Core.
ForNeVeR