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

◆ GetCachedBCryptAlgorithmHandle() [2/2]

static Microsoft.Win32.SafeHandles.SafeBCryptAlgorithmHandle Interop.BCrypt.BCryptAlgorithmCache.GetCachedBCryptAlgorithmHandle ( string hashAlgorithmId,
BCryptOpenAlgorithmProviderFlags flags,
out int hashSizeInBytes )
inlinestatic

Definition at line 278 of file Interop.cs.

279 {
280 Entry[] array = _cache;
281 Entry[] array2 = array;
282 for (int i = 0; i < array2.Length; i++)
283 {
284 Entry entry = array2[i];
285 if (entry.HashAlgorithmId == hashAlgorithmId && entry.Flags == flags)
286 {
287 hashSizeInBytes = entry.HashSizeInBytes;
288 return entry.Handle;
289 }
290 }
292 NTSTATUS nTSTATUS = BCryptOpenAlgorithmProvider(out phAlgorithm, hashAlgorithmId, null, flags);
293 if (nTSTATUS != 0)
294 {
295 throw CreateCryptographicException(nTSTATUS);
296 }
297 Array.Resize(ref array, array.Length + 1);
298 Entry entry2 = new Entry(hashAlgorithmId, flags, phAlgorithm);
299 array[^1] = new Entry(hashAlgorithmId, flags, phAlgorithm);
300 _cache = array;
301 hashSizeInBytes = entry2.HashSizeInBytes;
302 return entry2.Handle;
303 }
static volatile Entry[] _cache
Definition Interop.cs:328
static Exception CreateCryptographicException(NTSTATUS ntStatus)
Definition Interop.cs:461
static NTSTATUS BCryptOpenAlgorithmProvider(out SafeBCryptAlgorithmHandle phAlgorithm, string pszAlgId, string pszImplementation, BCryptOpenAlgorithmProviderFlags dwFlags)

References Interop.BCrypt.BCryptAlgorithmCache._cache, System.array, Interop.BCrypt.BCryptOpenAlgorithmProvider(), and Interop.BCrypt.CreateCryptographicException().