if (nativeDebugDirectoryEntryNode is not null)
{
Debug.Assert(_generatePdbFile);
- // Compute MD5 hash of the output image and store that in the native DebugDirectory entry
- using (var md5Hash = MD5.Create())
+ // Compute hash of the output image and store that in the native DebugDirectory entry
+ using (var hashAlgorithm = SHA256.Create())
{
peStream.Seek(0, SeekOrigin.Begin);
- byte[] hash = md5Hash.ComputeHash(peStream);
+ byte[] hash = hashAlgorithm.ComputeHash(peStream);
byte[] rsdsEntry = nativeDebugDirectoryEntryNode.GenerateRSDSEntryData(hash);
int offsetToUpdate = r2rPeBuilder.GetSymbolFilePosition(nativeDebugDirectoryEntryNode);
return builder.ToObjectData();
}
- public byte[] GenerateRSDSEntryData(byte[] md5Hash)
+ public byte[] GenerateRSDSEntryData(byte[] hash)
{
MemoryStream rsdsEntry = new MemoryStream(RSDSSize);
{
writer.Write(RsdsMagic);
- // The PDB signature will be the same as our NGEN signature.
- // However we want the printed version of the GUID to be the same as the
- // byte dump of the signature so we swap bytes to make this work.
- Debug.Assert(md5Hash.Length == 16);
- writer.Write((uint)((md5Hash[0] * 256 + md5Hash[1]) * 256 + md5Hash[2]) * 256 + md5Hash[3]);
- writer.Write((ushort)(md5Hash[4] * 256 + md5Hash[5]));
- writer.Write((ushort)(md5Hash[6] * 256 + md5Hash[7]));
- writer.Write(md5Hash, 8, 8);
+ Debug.Assert(hash.Length >= 16);
+ writer.Write(hash, 0, 16);
// Age
writer.Write(1);