11internal static class Helpers
13 [UnsupportedOSPlatformGuard(
"android")]
36 if (
src !=
null &&
src.Length == 0)
50 throw errorCode.ToCryptographicException();
60 case global::Interop.NCrypt.ErrorCode.NTE_NOT_FOUND:
63 throw errorCode.ToCryptographicException();
64 case global::Interop.NCrypt.ErrorCode.ERROR_SUCCESS:
73 case global::Interop.NCrypt.ErrorCode.NTE_NOT_FOUND:
76 throw errorCode.ToCryptographicException();
77 case global::Interop.NCrypt.ErrorCode.ERROR_SUCCESS:
119 global::Interop.NCrypt.ErrorCode.NTE_NOT_FOUND =>
IntPtr.
Zero,
120 global::Interop.NCrypt.ErrorCode.ERROR_SUCCESS =>
intPtr,
121 _ =>
throw errorCode.ToCryptographicException(),
130 throw errorCode.ToCryptographicException();
136 return (bits + 7) / 8;
146 [
return: NotNullIfNotNull(
"src")]
153 return (
byte[])
src.Clone();
static unsafe IntPtr GetPropertyAsIntPtr(this SafeNCryptHandle ncryptHandle, string propertyName, CngPropertyOptions options)
static byte[] GenerateRandom(int count)
static unsafe string GetPropertyAsString(this SafeNCryptHandle ncryptHandle, string propertyName, CngPropertyOptions options)
static byte[] GetCipherIv(this CipherMode cipherMode, byte[] iv)
static bool IsRC2Supported
static byte[] MapZeroLengthArrayToNonNullPointer(this byte[] src)
static int GetPaddingSize(this SymmetricAlgorithm algorithm, CipherMode mode, int feedbackSizeInBits)
static SafeNCryptProviderHandle OpenStorageProvider(this CngProvider provider)
static int GetPropertyAsDword(this SafeNCryptHandle ncryptHandle, string propertyName, CngPropertyOptions options)
static int BitSizeToByteSize(this int bits)
static unsafe void SetExportPolicy(this SafeNCryptKeyHandle keyHandle, CngExportPolicies exportPolicy)
static unsafe byte[] GetProperty(this SafeNCryptHandle ncryptHandle, string propertyName, CngPropertyOptions options)
static byte[] CloneByteArray(this byte[] src)
static bool UsesIv(this CipherMode cipherMode)
static int ToInt32(byte[] value, int startIndex)
static unsafe? string PtrToStringUni(IntPtr ptr)
static string Cryptography_MissingIV
static void Fill(Span< byte > data)
static readonly IntPtr Zero