Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Exists() [3/3]

static bool System.Security.Cryptography.CngKey.Exists ( string keyName,
CngProvider provider,
CngKeyOpenOptions options )
inlinestatic

Definition at line 771 of file CngKey.cs.

772 {
773 if (keyName == null)
774 {
775 throw new ArgumentNullException("keyName");
776 }
777 if (provider == null)
778 {
779 throw new ArgumentNullException("provider");
780 }
781 using SafeNCryptProviderHandle hProvider = provider.OpenStorageProvider();
782 SafeNCryptKeyHandle phKey = null;
783 try
784 {
785 global::Interop.NCrypt.ErrorCode errorCode = global::Interop.NCrypt.NCryptOpenKey(hProvider, out phKey, keyName, 0, options);
786 return errorCode switch
787 {
788 global::Interop.NCrypt.ErrorCode.NTE_BAD_KEYSET => false,
789 global::Interop.NCrypt.ErrorCode.ERROR_SUCCESS => true,
790 _ => throw errorCode.ToCryptographicException(),
791 };
792 }
793 finally
794 {
795 phKey?.Dispose();
796 }
797 }

References System.Runtime.InteropServices.SafeHandle.Dispose(), and System.options.