diff --git a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.Cipher.cs b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.Cipher.cs index f47bf5d3e1b51..df82c65487de1 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.Cipher.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EVP.Cipher.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Microsoft.Win32.SafeHandles; @@ -115,8 +116,12 @@ ref MemoryMarshal.GetReference(input), internal static void EvpCipherSetInputLength(SafeEvpCipherCtxHandle ctx, int inputLength) { - ref byte nullRef = ref MemoryMarshal.GetReference(Span.Empty); - if (!EvpCipherUpdate(ctx, ref nullRef, out _, ref nullRef, inputLength)) + if (!EvpCipherUpdate( + ctx, + ref Unsafe.NullRef(), + out _, + ref Unsafe.NullRef(), + inputLength)) { throw CreateOpenSslCryptographicException(); } @@ -229,8 +234,7 @@ internal static void EvpCipherSetCcmTag(SafeEvpCipherCtxHandle ctx, ReadOnlySpan internal static void EvpCipherSetCcmTagLength(SafeEvpCipherCtxHandle ctx, int tagLength) { - ref byte nullRef = ref MemoryMarshal.GetReference(Span.Empty); - if (!EvpCipherSetCcmTag(ctx, ref nullRef, tagLength)) + if (!EvpCipherSetCcmTag(ctx, ref Unsafe.NullRef(), tagLength)) { throw CreateOpenSslCryptographicException(); }