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

◆ GetCachedBCryptAlgorithmHandle() [1/2]

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

Definition at line 330 of file Interop.cs.

331 {
332 Entry[] array = _cache;
333 Entry[] array2 = array;
334 for (int i = 0; i < array2.Length; i++)
335 {
336 Entry entry = array2[i];
337 if (entry.HashAlgorithmId == hashAlgorithmId && entry.Flags == flags)
338 {
339 hashSizeInBytes = entry.HashSizeInBytes;
340 return entry.Handle;
341 }
342 }
343 SafeBCryptAlgorithmHandle phAlgorithm;
344 NTSTATUS nTSTATUS = BCryptOpenAlgorithmProvider(out phAlgorithm, hashAlgorithmId, null, flags);
345 if (nTSTATUS != 0)
346 {
347 throw CreateCryptographicException(nTSTATUS);
348 }
349 Array.Resize(ref array, array.Length + 1);
350 Entry entry2 = new Entry(hashAlgorithmId, flags, phAlgorithm);
351 array[^1] = new Entry(hashAlgorithmId, flags, phAlgorithm);
352 _cache = array;
353 hashSizeInBytes = entry2.HashSizeInBytes;
354 return entry2.Handle;
355 }
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(), Interop.BCrypt.CreateCryptographicException(), Interop.BCrypt.BCryptAlgorithmCache.Entry.Flags, Interop.BCrypt.BCryptAlgorithmCache.Entry.Handle, Interop.BCrypt.BCryptAlgorithmCache.Entry.HashAlgorithmId, and Interop.BCrypt.BCryptAlgorithmCache.Entry.HashSizeInBytes.