Fix interop signature of DsaSign to not claim ReadOnly behavior
authorFilip Navara <filip.navara@gmail.com>
Tue, 4 Sep 2018 04:42:47 +0000 (06:42 +0200)
committerJeremy Barton <jbarton@microsoft.com>
Tue, 4 Sep 2018 04:42:47 +0000 (21:42 -0700)
Commit migrated from https://github.com/dotnet/corefx/commit/816056b2a835f5c68f3b2bfaa81bd4bb5ba0932a

src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.Dsa.cs
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.cs
src/libraries/Common/src/System/Security/Cryptography/DSAOpenSsl.cs
src/libraries/Common/src/System/Security/Cryptography/ECDsaOpenSsl.cs

index 8d69e89..f8294dc 100644 (file)
@@ -66,8 +66,8 @@ internal static partial class Interop
             return keySize;
         }
 
-        internal static bool DsaSign(SafeDsaHandle dsa, ReadOnlySpan<byte> hash, int hashLength, ReadOnlySpan<byte> refSignature, out int outSignatureLength) =>
-            DsaSign(dsa, ref MemoryMarshal.GetReference(hash), hashLength, ref MemoryMarshal.GetReference(refSignature), out outSignatureLength);
+        internal static bool DsaSign(SafeDsaHandle dsa, ReadOnlySpan<byte> hash, Span<byte> refSignature, out int outSignatureLength) =>
+            DsaSign(dsa, ref MemoryMarshal.GetReference(hash), hash.Length, ref MemoryMarshal.GetReference(refSignature), out outSignatureLength);
 
         [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_DsaSign")]
         [return: MarshalAs(UnmanagedType.Bool)]
index 17c1232..5ada0a2 100644 (file)
@@ -10,8 +10,8 @@ internal static partial class Interop
 {
     internal static partial class Crypto
     {
-        internal static bool EcDsaSign(ReadOnlySpan<byte> dgst, int dlen, Span<byte> sig, [In, Out] ref int siglen, SafeEcKeyHandle ecKey) =>
-            EcDsaSign(ref MemoryMarshal.GetReference(dgst), dlen, ref MemoryMarshal.GetReference(sig), ref siglen, ecKey);
+        internal static bool EcDsaSign(ReadOnlySpan<byte> dgst, Span<byte> sig, [In, Out] ref int siglen, SafeEcKeyHandle ecKey) =>
+            EcDsaSign(ref MemoryMarshal.GetReference(dgst), dgst.Length, ref MemoryMarshal.GetReference(sig), ref siglen, ecKey);
 
         [DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcDsaSign")]
         [return: MarshalAs(UnmanagedType.Bool)]
index 31bb5f9..e075975 100644 (file)
@@ -193,7 +193,7 @@ namespace System.Security.Cryptography
                 byte[] signature = ArrayPool<byte>.Shared.Rent(signatureSize);
                 try
                 {
-                    bool success = Interop.Crypto.DsaSign(key, rgbHash, rgbHash.Length, new Span<byte>(signature, 0, signatureSize), out signatureSize);
+                    bool success = Interop.Crypto.DsaSign(key, rgbHash, new Span<byte>(signature, 0, signatureSize), out signatureSize);
                     if (!success)
                     {
                         throw Interop.Crypto.CreateOpenSslCryptographicException();
@@ -224,7 +224,7 @@ namespace System.Security.Cryptography
                 byte[] signature = ArrayPool<byte>.Shared.Rent(signatureSize);
                 try
                 {
-                    bool success = Interop.Crypto.DsaSign(key, hash, hash.Length, new Span<byte>(signature, 0, signatureSize), out signatureSize);
+                    bool success = Interop.Crypto.DsaSign(key, hash, new Span<byte>(signature, 0, signatureSize), out signatureSize);
                     if (!success)
                     {
                         throw Interop.Crypto.CreateOpenSslCryptographicException();
index e89992b..292fd65 100644 (file)
@@ -81,7 +81,7 @@ namespace System.Security.Cryptography
                 SafeEcKeyHandle key = _key.Value;
                 int signatureLength = Interop.Crypto.EcDsaSize(key);
                 byte[] signature = new byte[signatureLength];
-                if (!Interop.Crypto.EcDsaSign(hash, hash.Length, signature, ref signatureLength, key))
+                if (!Interop.Crypto.EcDsaSign(hash, signature, ref signatureLength, key))
                     throw Interop.Crypto.CreateOpenSslCryptographicException();
 
                 byte[] converted = AsymmetricAlgorithmHelpers.ConvertDerToIeee1363(signature, 0, signatureLength, KeySize);
@@ -98,7 +98,7 @@ namespace System.Security.Cryptography
                 byte[] signature = ArrayPool<byte>.Shared.Rent(signatureLength);
                 try
                 {
-                    if (!Interop.Crypto.EcDsaSign(hash, hash.Length, new Span<byte>(signature, 0, signatureLength), ref signatureLength, key))
+                    if (!Interop.Crypto.EcDsaSign(hash, new Span<byte>(signature, 0, signatureLength), ref signatureLength, key))
                     {
                         throw Interop.Crypto.CreateOpenSslCryptographicException();
                     }