Change stackalloc size in Security

This commit is contained in:
2021-06-07 19:49:06 +02:00
parent 0f88e82e28
commit adbee34498

View File

@@ -87,7 +87,7 @@ namespace Akari.Prototype.Server.Utils
// We write everything into one big array for easier encoding
int encryptedDataLength = 4 + nonceSize + 4 + tagSize + cipherSize;
Span<byte> encryptedData = encryptedDataLength < 1024
Span<byte> encryptedData = encryptedDataLength <= 1024
? stackalloc byte[encryptedDataLength]
: new byte[encryptedDataLength];
@@ -122,7 +122,7 @@ namespace Akari.Prototype.Server.Utils
var cipherBytes = encryptedData.Slice(4 + nonceSize + 4 + tagSize, cipherSize);
// Decrypt
Span<byte> plainBytes = cipherSize < 1024
Span<byte> plainBytes = cipherSize <= 1024
? stackalloc byte[cipherSize]
: new byte[cipherSize];