Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Decrypt() [4/4]

static unsafe int System.Security.Cryptography.PasswordBasedEncryption.Decrypt ( SymmetricAlgorithm cipher,
ReadOnlySpan< byte > key,
ReadOnlySpan< byte > iv,
ReadOnlySpan< byte > encryptedData,
Span< byte > destination )
inlinestaticprivate

Definition at line 559 of file PasswordBasedEncryption.cs.

560 {
561 byte[] array = new byte[key.Length];
562 byte[] array2 = new byte[iv.Length];
563 byte[] array3 = System.Security.Cryptography.CryptoPool.Rent(encryptedData.Length);
564 byte[] array4 = System.Security.Cryptography.CryptoPool.Rent(destination.Length);
565 fixed (byte* ptr5 = array)
566 {
567 fixed (byte* ptr4 = array2)
568 {
569 fixed (byte* ptr3 = array3)
570 {
571 fixed (byte* ptr2 = array4)
572 {
573 try
574 {
575 key.CopyTo(array);
576 iv.CopyTo(array2);
577 using ICryptoTransform cryptoTransform = cipher.CreateDecryptor(array, array2);
578 encryptedData.CopyTo(array3);
579 int num = cryptoTransform.TransformBlock(array3, 0, encryptedData.Length, array4, 0);
580 array4.AsSpan(0, num).CopyTo(destination);
581 byte[] array5 = cryptoTransform.TransformFinalBlock(Array.Empty<byte>(), 0, 0);
582 fixed (byte* ptr = array5)
583 {
584 Span<byte> buffer = array5.AsSpan();
585 buffer.CopyTo(destination.Slice(num));
586 CryptographicOperations.ZeroMemory(buffer);
587 }
588 return num + array5.Length;
589 }
590 finally
591 {
592 CryptographicOperations.ZeroMemory(array);
593 CryptographicOperations.ZeroMemory(array2);
594 System.Security.Cryptography.CryptoPool.Return(array3, encryptedData.Length);
596 }
597 }
598 }
599 }
600 }
601 }
static void Return(byte[] array, int clearSize=-1)
Definition CryptoPool.cs:12
static byte[] Rent(int minimumLength)
Definition CryptoPool.cs:7
void CopyTo(Span< T > destination)

References System.array, System.buffer, System.ReadOnlySpan< T >.CopyTo(), System.Security.Cryptography.SymmetricAlgorithm.CreateDecryptor(), System.destination, System.key, System.ReadOnlySpan< T >.Length, System.Security.Cryptography.CryptoPool.Rent(), System.Security.Cryptography.CryptoPool.Return(), and System.Security.Cryptography.CryptographicOperations.ZeroMemory().