Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit74cafe7

Browse files
authored
Fix over-zeroing of destination buffer with PaddingMode.Zeros
This addresses two issues with how zero padding is handled.The first is performance. When applying zero padding, we were clearingthe entire destination, then copying the plaintext over it. We werezeroing more data than required, the only data that needed to be zeroedis where the zero padding is applied.The second is in the case of overlapping buffers for the plaintextand ciphertext. However, this cannot happen currently since we alwaysensure the destination buffer does not overlap the input buffer.If overlapping is permitted in a future change, this would clear theplaintext, not just where padding is required.
1 parent28cff50 commit74cafe7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

‎src/libraries/Common/src/Internal/Cryptography/UniversalCryptoEncryptor.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ private int PadBlock(ReadOnlySpan<byte> block, Span<byte> destination)
168168
thrownewArgumentException(SR.Argument_DestinationTooShort,nameof(destination));
169169
}
170170

171-
destination.Slice(0,zeroSize).Clear();
172171
block.CopyTo(destination);
172+
destination.Slice(count,padBytes).Clear();
173173
returnzeroSize;
174174

175175
default:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp