- Notifications
You must be signed in to change notification settings - Fork5.2k
Enable ToBase64Transform.CanTransformMultipleBlocks#55055
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ghost commentedJul 2, 2021
Tagging subscribers to this area:@bartonjs,@vcsjones,@krwq,@GrabYourPitchforks Issue DetailsFixes#55029
usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Configs;usingBenchmarkDotNet.Running;usingSystem;usingBenchmarkDotNet.Diagnosers;usingPerfolizer.Horology;usingBenchmarkDotNet.Columns;usingSystem.Globalization;usingBenchmarkDotNet.Reports;usingSystem.Security.Cryptography;usingSystem.IO;[MemoryDiagnoser]publicclassProgram{publicstaticvoidMain(string[]args)=>BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args,DefaultConfig.Instance.WithSummaryStyle(newSummaryStyle(CultureInfo.InvariantCulture,printUnitsInHeader:false,sizeUnit:SizeUnit.B,timeUnit:TimeUnit.Nanosecond,printZeroValuesInContent:true)));privatebyte[]_data=RandomNumberGenerator.GetBytes(10_000_000);privateMemoryStream_destination=newMemoryStream();[Benchmark]publicvoidEncode(){_destination.Position=0;using(vartoBase64=newToBase64Transform())using(varstream=newCryptoStream(_destination,toBase64,CryptoStreamMode.Write,leaveOpen:true)){Span<byte>remaining=_data;while(!remaining.IsEmpty){Span<byte>toWrite=remaining.Slice(0,Math.Min(4096,remaining.Length));stream.Write(toWrite);remaining=remaining.Slice(toWrite.Length);}}}}
|
...s/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/Base64Transforms.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...s/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/Base64Transforms.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...s/System.Security.Cryptography.Encoding/src/System/Security/Cryptography/Base64Transforms.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/libraries/System.Security.Cryptography.Encoding/tests/Base64TransformsTests.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
stephentoub commentedJul 2, 2021
I'm realizing now I misunderstood the contract, and the implementation needs to be much more complex, to handle cases where more input is provided than can fit into the output space provided... I was only encoding what would fit, but it appears the contract actually requires the remaining input data to be saved off for later. |
stephentoub commentedJul 2, 2021
Turns out the implementation doesn't need to be more complex as it can make simplifying assumptions about the inputs, ala what UniversalCryptoTransform does. And since this never previously supported anything other than one input block that entirely fit into the output, this won't be a breaking change. I'll fix up the input validation accordingly. |
Uh oh!
There was an error while loading.Please reload this page.
Fixes#55029