772 {
773 if (keyName == null)
774 {
775 throw new ArgumentNullException("keyName");
776 }
777 if (provider == null)
778 {
779 throw new ArgumentNullException("provider");
780 }
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 {
796 }
797 }