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

◆ CreateHashHandle() [2/2]

static SafeHashHandle Internal.NativeCrypto.CapiHelper.CreateHashHandle ( this SafeProvHandle hProv,
byte[] hash,
int calgHash,
bool throwOnSizeError )
inlinestaticprivate

Definition at line 1291 of file CapiHelper.cs.

1292 {
1293 if (!CryptCreateHash(hProv, calgHash, SafeKeyHandle.InvalidHandle, global::Interop.Advapi32.CryptCreateHashFlags.None, out var phHash))
1294 {
1295 int hRForLastWin32Error = Marshal.GetHRForLastWin32Error();
1296 phHash.Dispose();
1297 throw hRForLastWin32Error.ToCryptographicException();
1298 }
1299 try
1300 {
1301 int pbData = 0;
1302 int pdwDataLen = 4;
1303 if (!global::Interop.Advapi32.CryptGetHashParam(phHash, global::Interop.Advapi32.CryptHashProperty.HP_HASHSIZE, out pbData, ref pdwDataLen, 0))
1304 {
1305 int hRForLastWin32Error2 = Marshal.GetHRForLastWin32Error();
1306 throw hRForLastWin32Error2.ToCryptographicException();
1307 }
1308 if (pbData != hash.Length)
1309 {
1310 if (throwOnSizeError)
1311 {
1312 throw (-2146893821).ToCryptographicException();
1313 }
1314 return null;
1315 }
1316 if (!global::Interop.Advapi32.CryptSetHashParam(phHash, global::Interop.Advapi32.CryptHashProperty.HP_HASHVAL, hash, 0))
1317 {
1318 int hRForLastWin32Error3 = Marshal.GetHRForLastWin32Error();
1319 throw hRForLastWin32Error3.ToCryptographicException();
1320 }
1321 SafeHashHandle result = phHash;
1322 phHash = null;
1323 return result;
1324 }
1325 finally
1326 {
1327 phHash?.Dispose();
1328 }
1329 }
static bool CryptCreateHash(SafeProvHandle hProv, int algId, SafeKeyHandle hKey, global::Interop.Advapi32.CryptCreateHashFlags dwFlags, out SafeHashHandle phHash)
override void Dispose(bool disposing)

References Internal.NativeCrypto.CapiHelper.CryptCreateHash(), System.Security.Cryptography.SafeHashHandle.Dispose(), and System.Runtime.InteropServices.Marshal.GetHRForLastWin32Error().