Skip to content

Commit 2d57a44

Browse files
authored
[Storage] Buffer reads of blobs encrypted on client side. (Azure#21652)
* buffer network stream./ * changelog.
1 parent f5b425d commit 2d57a44

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

sdk/storage/Azure.Storage.Blobs/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- Fixed bug where specifying "*" as IfMatch condition could lead to inconsistend read in BlobClient.DownloadTo.
66
- Fixed bug where specifying conditions in BlobBaseClient.OpenRead could override allowModifications flag in BlobOpenReadOptions leading to inconsistent read.
77
- Fixed bug where BlobProperties.IsLatestVersion from BlobBaseClient.GetProperties did not set the value (defaulted to false).
8+
- Fixed bug where reading blob with Client Side Encryption enabled results in high CPU.
89

910
## 12.8.4 (2021-05-20)
1011
- Fixed bug where Client Side Encryption during large transactions (greater than max int value) would throw an exception.

sdk/storage/Azure.Storage.Common/src/Shared/ClientsideEncryption/ClientSideDecryptor.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,11 @@ private static Stream WrapStream(
240240
aesProvider.Padding = PaddingMode.None;
241241
}
242242

243-
return new CryptoStream(contentStream, aesProvider.CreateDecryptor(), CryptoStreamMode.Read);
243+
// Buffer network stream. CryptoStream issues tiny (~16 byte) reads which can lead to resources churn.
244+
// By default buffer is 4KB.
245+
var bufferedContentStream = new BufferedStream(contentStream);
246+
247+
return new CryptoStream(bufferedContentStream, aesProvider.CreateDecryptor(), CryptoStreamMode.Read);
244248
}
245249
}
246250

0 commit comments

Comments
 (0)