-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* OpenSSL providers support * Address self feedback (Lazy+leak) * Attempt to fix EVP_PKEY_CTX_new_from_pkey errors * update osslcompat_30.h with EVP_PKEY types * properly ifdef extraHandle code * fix: unused parameter extraHandle when OSSL 3 not available * bugfixes, feedback * ifndef some defines in compat layer, remove CryptoNative_EvpPkeyExtraHandleDestroy * change style to match old RsaSignHash * XML doc + extra test case * remote OSSL_STORE_open usage and revert comment on the DuplicateKeyHandle * Address feedback * Add back HasNoPrivateKey check on OSSL ver LT 3 * move check to SignHash * address feedback (ThrowIfNull + switch expression) * update XML doc * attempt to fix ossl 1.0.2 build by moving ifndef to opensslshim.h
- Loading branch information
Showing
39 changed files
with
1,429 additions
and
708 deletions.
There are no files selected for viewing
61 changes: 0 additions & 61 deletions
61
src/libraries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EcDsa.cs
This file was deleted.
Oops, something went wrong.
81 changes: 81 additions & 0 deletions
81
...ries/Common/src/Interop/Unix/System.Security.Cryptography.Native/Interop.EvpPkey.EcDsa.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
using System.Security.Cryptography; | ||
using Microsoft.Win32.SafeHandles; | ||
|
||
internal static partial class Interop | ||
{ | ||
internal static partial class Crypto | ||
{ | ||
[LibraryImport(Libraries.CryptoNative)] | ||
private static partial int CryptoNative_EcDsaSignHash( | ||
SafeEvpPKeyHandle pkey, | ||
IntPtr extraHandle, | ||
ref byte hash, | ||
int hashLength, | ||
ref byte destination, | ||
int destinationLength); | ||
|
||
internal static int EcDsaSignHash( | ||
SafeEvpPKeyHandle pkey, | ||
ReadOnlySpan<byte> hash, | ||
Span<byte> destination) | ||
{ | ||
int written = CryptoNative_EcDsaSignHash( | ||
pkey, | ||
pkey.ExtraHandle, | ||
ref MemoryMarshal.GetReference(hash), | ||
hash.Length, | ||
ref MemoryMarshal.GetReference(destination), | ||
destination.Length); | ||
|
||
if (written < 0) | ||
{ | ||
Debug.Assert(written == -1); | ||
throw CreateOpenSslCryptographicException(); | ||
} | ||
|
||
return written; | ||
} | ||
|
||
[LibraryImport(Libraries.CryptoNative)] | ||
private static partial int CryptoNative_EcDsaVerifyHash( | ||
SafeEvpPKeyHandle pkey, | ||
IntPtr extraHandle, | ||
ref byte hash, | ||
int hashLength, | ||
ref byte signature, | ||
int signatureLength); | ||
|
||
internal static bool EcDsaVerifyHash( | ||
SafeEvpPKeyHandle pkey, | ||
ReadOnlySpan<byte> hash, | ||
ReadOnlySpan<byte> signature) | ||
{ | ||
int ret = CryptoNative_EcDsaVerifyHash( | ||
pkey, | ||
pkey.ExtraHandle, | ||
ref MemoryMarshal.GetReference(hash), | ||
hash.Length, | ||
ref MemoryMarshal.GetReference(signature), | ||
signature.Length); | ||
|
||
if (ret == 1) | ||
{ | ||
return true; | ||
} | ||
|
||
if (ret == 0) | ||
{ | ||
return false; | ||
} | ||
|
||
Debug.Assert(ret == -1); | ||
throw CreateOpenSslCryptographicException(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.