Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.cs')
-rw-r--r--src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.cs32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.cs b/src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.cs
index 91c1beab99..17c1232f24 100644
--- a/src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.cs
+++ b/src/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.cs
@@ -17,8 +17,22 @@ internal static partial class Interop
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool EcDsaSign(ref byte dgst, int dlen, ref byte sig, [In, Out] ref int siglen, SafeEcKeyHandle ecKey);
- internal static unsafe int EcDsaVerify(ReadOnlySpan<byte> dgst, int dgst_len, ReadOnlySpan<byte> sigbuf, int sig_len, SafeEcKeyHandle ecKey) =>
- EcDsaVerify(ref MemoryMarshal.GetReference(dgst), dgst_len, ref MemoryMarshal.GetReference(sigbuf), sig_len, ecKey);
+ internal static int EcDsaVerify(ReadOnlySpan<byte> dgst, ReadOnlySpan<byte> sigbuf, SafeEcKeyHandle ecKey)
+ {
+ int ret = EcDsaVerify(
+ ref MemoryMarshal.GetReference(dgst),
+ dgst.Length,
+ ref MemoryMarshal.GetReference(sigbuf),
+ sigbuf.Length,
+ ecKey);
+
+ if (ret < 0)
+ {
+ ErrClearError();
+ }
+
+ return ret;
+ }
/*-
* returns
@@ -31,6 +45,18 @@ internal static partial class Interop
// returns the maximum length of a DER encoded ECDSA signature created with this key.
[DllImport(Libraries.CryptoNative, EntryPoint = "CryptoNative_EcDsaSize")]
- internal static extern int EcDsaSize(SafeEcKeyHandle ecKey);
+ private static extern int CryptoNative_EcDsaSize(SafeEcKeyHandle ecKey);
+
+ internal static int EcDsaSize(SafeEcKeyHandle ecKey)
+ {
+ int ret = CryptoNative_EcDsaSize(ecKey);
+
+ if (ret == 0)
+ {
+ throw CreateOpenSslCryptographicException();
+ }
+
+ return ret;
+ }
}
}