Skip to content

Commit d87aeaf

Browse files
committed
raise stackalloc to 256
1 parent c8019fb commit d87aeaf

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/DataProtection/DataProtection/src/Managed/ManagedAuthenticatedEncryptor.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,16 +197,16 @@ public byte[] Decrypt(ArraySegment<byte> protectedPayload, ArraySegment<byte> ad
197197

198198
// Step 2: Decrypt the KDK and use it to restore the original encryption and MAC keys.
199199
#if NET10_0_OR_GREATER
200-
Span<byte> decryptedKdk = _keyDerivationKey.Length <= 128
201-
? stackalloc byte[128].Slice(0, _keyDerivationKey.Length)
200+
Span<byte> decryptedKdk = _keyDerivationKey.Length <= 256
201+
? stackalloc byte[256].Slice(0, _keyDerivationKey.Length)
202202
: new byte[_keyDerivationKey.Length];
203203
#else
204204
var decryptedKdk = new byte[_keyDerivationKey.Length];
205205
#endif
206206

207207
byte[]? validationSubkeyArray = null;
208-
var validationSubkey = _validationAlgorithmSubkeyLengthInBytes <= 128
209-
? stackalloc byte[128].Slice(0, _validationAlgorithmSubkeyLengthInBytes)
208+
var validationSubkey = _validationAlgorithmSubkeyLengthInBytes <= 256
209+
? stackalloc byte[256].Slice(0, _validationAlgorithmSubkeyLengthInBytes)
210210
: (validationSubkeyArray = new byte[_validationAlgorithmSubkeyLengthInBytes]);
211211

212212
#if NET10_0_OR_GREATER
@@ -307,26 +307,26 @@ public byte[] Encrypt(ArraySegment<byte> plaintext, ArraySegment<byte> additiona
307307
var ivLength = _symmetricAlgorithmBlockSizeInBytes;
308308

309309
#if NET10_0_OR_GREATER
310-
Span<byte> decryptedKdk = _keyDerivationKey.Length <= 128
311-
? stackalloc byte[128].Slice(0, _keyDerivationKey.Length)
310+
Span<byte> decryptedKdk = _keyDerivationKey.Length <= 256
311+
? stackalloc byte[256].Slice(0, _keyDerivationKey.Length)
312312
: new byte[_keyDerivationKey.Length];
313313
#else
314314
var decryptedKdk = new byte[_keyDerivationKey.Length];
315315
#endif
316316

317317
#if NET10_0_OR_GREATER
318318
byte[]? validationSubkeyArray = null;
319-
Span<byte> validationSubkey = _validationAlgorithmSubkeyLengthInBytes <= 128
320-
? stackalloc byte[128].Slice(0, _validationAlgorithmSubkeyLengthInBytes)
319+
Span<byte> validationSubkey = _validationAlgorithmSubkeyLengthInBytes <= 256
320+
? stackalloc byte[256].Slice(0, _validationAlgorithmSubkeyLengthInBytes)
321321
: (validationSubkeyArray = new byte[_validationAlgorithmSubkeyLengthInBytes]);
322322
#else
323323
var validationSubkeyArray = new byte[_validationAlgorithmSubkeyLengthInBytes];
324324
var validationSubkey = validationSubkeyArray.AsSpan();
325325
#endif
326326

327327
#if NET10_0_OR_GREATER
328-
Span<byte> encryptionSubkey = _symmetricAlgorithmSubkeyLengthInBytes <= 128
329-
? stackalloc byte[128].Slice(0, _symmetricAlgorithmSubkeyLengthInBytes)
328+
Span<byte> encryptionSubkey = _symmetricAlgorithmSubkeyLengthInBytes <= 256
329+
? stackalloc byte[256].Slice(0, _symmetricAlgorithmSubkeyLengthInBytes)
330330
: new byte[_symmetricAlgorithmSubkeyLengthInBytes];
331331
#else
332332
byte[] encryptionSubkey = new byte[_symmetricAlgorithmSubkeyLengthInBytes];

0 commit comments

Comments
 (0)