{
}
- internal HashProviderCng(string? hashAlgId, ReadOnlySpan<byte> key, bool isHmac)
+ internal HashProviderCng(string hashAlgId, ReadOnlySpan<byte> key, bool isHmac)
{
BCryptOpenAlgorithmProviderFlags dwFlags = BCryptOpenAlgorithmProviderFlags.None;
if (isHmac)
/// <summary>
/// Return a SafeBCryptAlgorithmHandle of the desired algorithm and flags. This is a shared handle so do not dispose it!
/// </summary>
- public static SafeBCryptAlgorithmHandle GetCachedBCryptAlgorithmHandle(string? hashAlgorithmId, BCryptOpenAlgorithmProviderFlags flags)
+ public static SafeBCryptAlgorithmHandle GetCachedBCryptAlgorithmHandle(string hashAlgorithmId, BCryptOpenAlgorithmProviderFlags flags)
{
// There aren't that many hash algorithms around so rather than use a LowLevelDictionary and guard it with a lock,
// we'll use a simple list. To avoid locking, we'll recreate the entire list each time an entry is added and replace it atomically.
private struct Entry
{
- public Entry(string? hashAlgorithmId, BCryptOpenAlgorithmProviderFlags flags, SafeBCryptAlgorithmHandle handle)
+ public Entry(string hashAlgorithmId, BCryptOpenAlgorithmProviderFlags flags, SafeBCryptAlgorithmHandle handle)
: this()
{
HashAlgorithmId = hashAlgorithmId;
Handle = handle;
}
- public string? HashAlgorithmId { get; private set; }
+ public string HashAlgorithmId { get; private set; }
public BCryptOpenAlgorithmProviderFlags Flags { get; private set; }
public SafeBCryptAlgorithmHandle Handle { get; private set; }
}
internal partial class BCrypt
{
[DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
- internal static extern NTSTATUS BCryptOpenAlgorithmProvider(out SafeBCryptAlgorithmHandle phAlgorithm, string? pszAlgId, string? pszImplementation, BCryptOpenAlgorithmProviderFlags dwFlags);
+ internal static extern NTSTATUS BCryptOpenAlgorithmProvider(out SafeBCryptAlgorithmHandle phAlgorithm, string pszAlgId, string? pszImplementation, BCryptOpenAlgorithmProviderFlags dwFlags);
[Flags]
internal enum BCryptOpenAlgorithmProviderFlags : int
/// <summary>
/// KSP to create the key in
/// </summary>
- [MaybeNull]
public CngProvider Provider
{
get
/// </summary>
public CngUIPolicy? UIPolicy { get; set; }
- private CngProvider? _provider;
+ private CngProvider _provider = null!; // will be initialized via property setter called by ctor
}
}