-
Notifications
You must be signed in to change notification settings - Fork 361
Add Dapr.Cryptography package + fix for large files #1527
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
…tory Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
…equire more than one message to process Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
… for in a separate file Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
daprdocs/content/en/dotnet-sdk-docs/dotnet-cryptography/_index.md
Outdated
Show resolved
Hide resolved
daprdocs/content/en/dotnet-sdk-docs/dotnet-cryptography/dotnet-cryptography-usage.md
Outdated
Show resolved
Hide resolved
examples/Cryptography/Examples/EncryptDecryptLargeFileExample.cs
Outdated
Show resolved
Hide resolved
Signed-off-by: Whit Waldo <[email protected]>
Co-authored-by: Christopher Watford <[email protected]> Signed-off-by: Whit Waldo <[email protected]>
…-cryptography-usage.md Co-authored-by: Christopher Watford <[email protected]> Signed-off-by: Whit Waldo <[email protected]>
Co-authored-by: Christopher Watford <[email protected]> Signed-off-by: Whit Waldo <[email protected]>
watfordsuzy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of nits, some notes, and an unobserved task exception issue.
| var duplexStream = Client.DecryptAlpha1(grpcCallOptions); | ||
|
|
||
| using var streamProcessor = new DecryptionStreamProcessor(); | ||
| await streamProcessor.ProcessStreamAsync(ciphertextStream, duplexStream, options.StreamingBlockSizeInBytes, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This await doesn't really do anything given how the processor is setup.
I think a design like you see in the Azure.Data.Tables library would be amenable here: https://learn.microsoft.com/en-us/dotnet/api/azure.data.tables.tableclient.queryasync?view=azure-dotnet
Basically, instead of returning a Task the process stream returns a wrapper which includes the IAsyncEnumerable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's true that await doesn't really do anything, but between it and just discarding the value, C# requires that I put something there. I don't know that I want to return any additional public types just for the sake of it when I could just return the IAsyncEnumerable and leave it to consumers to decide what to do with it.
| var duplexStream = Client.EncryptAlpha1(grpcCallOptions); | ||
|
|
||
| using var streamProcessor = new EncryptionStreamProcessor(); | ||
| await streamProcessor.ProcessStreamAsync(plaintextStream, duplexStream, encryptRequestOptions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One interesting thing I noticed in the dapr Go code is that it does encryption/decryption on the full buffer in memory (byte[]) rather than streaming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't speak to what happens in the runtime, but the specification is that this is implemented using a bidirectional streaming connection.
Signed-off-by: Whit Waldo <[email protected]>
Co-authored-by: Christopher Watford <[email protected]> Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
…wing Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Co-authored-by: Christopher Watford <[email protected]> Signed-off-by: Whit Waldo <[email protected]>
…uggestion. Signed-off-by: Whit Waldo <[email protected]>
…ly block in case of exception Signed-off-by: Whit Waldo <[email protected]>
… the scope was no longer effective. Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
Signed-off-by: Whit Waldo <[email protected]>
* Implementation of the new crypto client Signed-off-by: Whit Waldo <[email protected]> Co-authored-by: Christopher Watford <[email protected]>
* Implementation of the new crypto client Signed-off-by: Whit Waldo <[email protected]> Co-authored-by: Christopher Watford <[email protected]>
* Implementation of the new crypto client Signed-off-by: Whit Waldo <[email protected]> Co-authored-by: Christopher Watford <[email protected]>
Description
This PR implements three things:
Dapr.Cryptographypackage to be released with 1.16. All existing methods on Dapr.Client have an updated [Obsolete] attribute with a message telling developers that this method will be removed with the release of 1.17.Dapr.Cryptographypackage and modernized to reflect a DI-first approach. It features three samples that demonstrate encryption and decryption of strings, streams and byte arrays of small (a dozen bytes), medium (~1 KB) and 1 GB files.Issue reference
We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.
Please reference the issue this PR will close: #1488 dapr/dapr#8244
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: