mirror of
https://github.com/vxunderground/MalwareSourceCode.git
synced 2024-12-19 09:56:10 +00:00
f2ac1ece55
add
55 lines
2.6 KiB
C#
55 lines
2.6 KiB
C#
// Decompiled with JetBrains decompiler
|
|
// Type: Microsoft.InfoCards.HashUtility
|
|
// Assembly: infocard, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
|
|
// MVID: ADE0A079-11DB-4A46-8BDE-D2A592CA8DEA
|
|
// Assembly location: C:\Users\Administrateur\Downloads\Virusshare-00001-msil\Virus.Win32.Expiro.w-1f15ee7e9f7da02b6bfb4c5a5e6484eb9fa71b82d3699c54bcc7a31794b4a66d.exe
|
|
|
|
using Microsoft.InfoCards.Diagnostics;
|
|
using System;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace Microsoft.InfoCards
|
|
{
|
|
internal static class HashUtility
|
|
{
|
|
public const string HashAlgorithmName = "SHA256";
|
|
private static object s_lock = new object();
|
|
private static SHA256Managed s_hasher = new SHA256Managed();
|
|
|
|
public static int HashBitLength => HashUtility.s_hasher.HashSize;
|
|
|
|
public static int HashBufferLength => HashUtility.HashBitLength / 8;
|
|
|
|
public static void SetHashValue(byte[] data, int dataIndex, byte[] dataToHash)
|
|
{
|
|
if (dataToHash == null)
|
|
throw InfoCardTrace.ThrowHelperArgumentNull(nameof (dataToHash));
|
|
HashUtility.SetHashValue(data, dataIndex, dataToHash, 0, dataToHash.Length);
|
|
}
|
|
|
|
public static void SetHashValue(
|
|
byte[] data,
|
|
int dataIndex,
|
|
byte[] dataToHash,
|
|
int dataToHashIndex,
|
|
int dataToHashSize)
|
|
{
|
|
if (data == null)
|
|
throw InfoCardTrace.ThrowHelperArgumentNull(nameof (data));
|
|
if (dataIndex < 0 || dataIndex >= data.Length)
|
|
throw InfoCardTrace.ThrowHelperError((Exception) new ArgumentOutOfRangeException(nameof (dataIndex), (object) dataIndex, SR.GetString("StoreHashUtilityDataOutOfRange")));
|
|
if (dataToHash == null)
|
|
throw InfoCardTrace.ThrowHelperArgumentNull(nameof (dataToHash));
|
|
if (dataToHashIndex < 0 || dataToHashIndex > dataToHash.Length)
|
|
throw InfoCardTrace.ThrowHelperError((Exception) new ArgumentOutOfRangeException(nameof (dataToHashIndex), (object) dataToHashIndex, SR.GetString("StoreHashUtilityDataToHashOutOfRange")));
|
|
if (dataToHashSize < 0 || dataToHashSize > dataToHash.Length - dataToHashIndex)
|
|
throw InfoCardTrace.ThrowHelperError((Exception) new ArgumentOutOfRangeException(nameof (dataToHashIndex), (object) dataToHashIndex, SR.GetString("StoreHashUtilityDataToHashOutOfRange")));
|
|
byte[] sourceArray = (byte[]) null;
|
|
lock (HashUtility.s_lock)
|
|
sourceArray = HashUtility.s_hasher.ComputeHash(dataToHash, dataToHashIndex, dataToHashSize);
|
|
Array.Copy((Array) sourceArray, 0, (Array) data, dataIndex, sourceArray.Length);
|
|
Array.Clear((Array) sourceArray, 0, sourceArray.Length);
|
|
}
|
|
}
|
|
}
|