diff --git a/Assets/Mirror/Transports/Encryption/Native/AesGCMEncryptionNative.cs b/Assets/Mirror/Transports/Encryption/Native/AesGCMEncryptionNative.cs index 580488efdd4..923849585d3 100644 --- a/Assets/Mirror/Transports/Encryption/Native/AesGCMEncryptionNative.cs +++ b/Assets/Mirror/Transports/Encryption/Native/AesGCMEncryptionNative.cs @@ -40,7 +40,7 @@ static AesGCMEncryptionNative() public static bool IsSupported => _supported; public static unsafe ArraySegment Encrypt(byte[] key, byte[] nonce, ArraySegment plaintext, ArraySegment dataOut) { - plaintext.CopyTo(dataOut); + Array.Copy(plaintext.Array, plaintext.Offset, dataOut.Array, dataOut.Offset ,plaintext.Count); fixed (byte* keyPtr = key) { fixed (byte* noncePtr = nonce) @@ -57,9 +57,10 @@ public static unsafe ArraySegment Encrypt(byte[] key, byte[] nonce, ArrayS } } } + public static unsafe ArraySegment Decrypt(byte[] key, byte[] nonce, ArraySegment ciphertext, ArraySegment dataOut) { - ciphertext.CopyTo(dataOut); + Array.Copy(ciphertext.Array, ciphertext.Offset, dataOut.Array, dataOut.Offset, ciphertext.Count); fixed (byte* keyPtr = key) { fixed (byte* noncePtr = nonce)