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

◆ HashProviderCng() [4/4]

Internal.Cryptography.HashProviderCng.HashProviderCng ( string hashAlgId,
ReadOnlySpan< byte > key,
bool isHmac )
inlinepackage

Definition at line 27 of file HashProviderCng.cs.

28 {
29 global::Interop.BCrypt.BCryptOpenAlgorithmProviderFlags bCryptOpenAlgorithmProviderFlags = global::Interop.BCrypt.BCryptOpenAlgorithmProviderFlags.None;
30 if (isHmac)
31 {
32 _key = key.ToArray();
33 bCryptOpenAlgorithmProviderFlags |= global::Interop.BCrypt.BCryptOpenAlgorithmProviderFlags.BCRYPT_ALG_HANDLE_HMAC_FLAG;
34 }
35 _hAlgorithm = global::Interop.BCrypt.BCryptAlgorithmCache.GetCachedBCryptAlgorithmHandle(hashAlgId, bCryptOpenAlgorithmProviderFlags, out _hashSize);
37 global::Interop.BCrypt.NTSTATUS nTSTATUS = global::Interop.BCrypt.BCryptCreateHash(_hAlgorithm, out phHash, IntPtr.Zero, 0, key, (!(key == null)) ? key.Length : 0, global::Interop.BCrypt.BCryptCreateHashFlags.BCRYPT_HASH_REUSABLE_FLAG);
38 switch (nTSTATUS)
39 {
40 case global::Interop.BCrypt.NTSTATUS.STATUS_INVALID_PARAMETER:
41 phHash.Dispose();
42 Reset();
43 break;
44 default:
45 phHash.Dispose();
46 throw global::Interop.BCrypt.CreateCryptographicException(nTSTATUS);
47 case global::Interop.BCrypt.NTSTATUS.STATUS_SUCCESS:
48 _hHash = phHash;
49 _reusable = true;
50 break;
51 }
52 }
readonly SafeBCryptAlgorithmHandle _hAlgorithm
static readonly IntPtr Zero
Definition IntPtr.cs:18

References Internal.Cryptography.HashProviderCng._hAlgorithm, Internal.Cryptography.HashProviderCng._hashSize, Internal.Cryptography.HashProviderCng._hHash, Internal.Cryptography.HashProviderCng._key, Internal.Cryptography.HashProviderCng._reusable, System.Runtime.InteropServices.SafeHandle.Dispose(), System.key, Internal.Cryptography.HashProviderCng.Reset(), and System.IntPtr.Zero.