Imported Upstream version 6.6.0.108
Former-commit-id: 00c6fff7917ab7dddc0c67044b046850c2283096
This commit is contained in:
parent
4c26f54a2f
commit
9050bbfc26
@ -1 +1 @@
|
||||
37cc903befff71e98631598a26de46eacfdc7aca
|
||||
e2349164fad4ccd2424944cf6b3605ae76e1f876
|
@ -1 +1 @@
|
||||
f1495d076977e40b18b728f5367643e7374a3bc0
|
||||
1e5e08337bc1443e8611aa9a92c9fd36e0baf00f
|
13
external/ikvm/reflect/AssemblyName.cs
vendored
13
external/ikvm/reflect/AssemblyName.cs
vendored
@ -402,13 +402,16 @@ namespace IKVM.Reflection
|
||||
{
|
||||
return publicKey;
|
||||
}
|
||||
byte[] hash = new SHA1Managed().ComputeHash(publicKey);
|
||||
byte[] token = new byte[8];
|
||||
for (int i = 0; i < token.Length; i++)
|
||||
using (var sha1 = SHA1.Create())
|
||||
{
|
||||
token[i] = hash[hash.Length - 1 - i];
|
||||
byte[] hash = sha1.ComputeHash(publicKey);
|
||||
byte[] token = new byte[8];
|
||||
for (int i = 0; i < token.Length; i++)
|
||||
{
|
||||
token[i] = hash[hash.Length - 1 - i];
|
||||
}
|
||||
return token;
|
||||
}
|
||||
return token;
|
||||
}
|
||||
|
||||
internal static string ComputePublicKeyToken(string publicKey)
|
||||
|
24
external/ikvm/reflect/Emit/AssemblyBuilder.cs
vendored
24
external/ikvm/reflect/Emit/AssemblyBuilder.cs
vendored
@ -472,21 +472,23 @@ namespace IKVM.Reflection.Emit
|
||||
|
||||
private int AddFile(ModuleBuilder manifestModule, string fileName, int flags)
|
||||
{
|
||||
SHA1Managed hash = new SHA1Managed();
|
||||
string fullPath = fileName;
|
||||
if (dir != null)
|
||||
using (var hash = SHA1.Create())
|
||||
{
|
||||
fullPath = Path.Combine(dir, fileName);
|
||||
}
|
||||
using (FileStream fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
using (CryptoStream cs = new CryptoStream(Stream.Null, hash, CryptoStreamMode.Write))
|
||||
string fullPath = fileName;
|
||||
if (dir != null)
|
||||
{
|
||||
byte[] buf = new byte[8192];
|
||||
ModuleWriter.HashChunk(fs, cs, buf, (int)fs.Length);
|
||||
fullPath = Path.Combine(dir, fileName);
|
||||
}
|
||||
using (FileStream fs = new FileStream(fullPath, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
using (CryptoStream cs = new CryptoStream(Stream.Null, hash, CryptoStreamMode.Write))
|
||||
{
|
||||
byte[] buf = new byte[8192];
|
||||
ModuleWriter.HashChunk(fs, cs, buf, (int)fs.Length);
|
||||
}
|
||||
}
|
||||
return manifestModule.__AddModule(flags, Path.GetFileName(fileName), hash.Hash);
|
||||
}
|
||||
return manifestModule.__AddModule(flags, Path.GetFileName(fileName), hash.Hash);
|
||||
}
|
||||
|
||||
public void AddResourceFile(string name, string fileName)
|
||||
|
114
external/ikvm/reflect/Writer/ModuleWriter.cs
vendored
114
external/ikvm/reflect/Writer/ModuleWriter.cs
vendored
@ -382,53 +382,55 @@ namespace IKVM.Reflection.Writer
|
||||
|
||||
private static void StrongName(Stream stream, StrongNameKeyPair keyPair, uint headerLength, uint textSectionFileOffset, uint strongNameSignatureFileOffset, uint strongNameSignatureLength)
|
||||
{
|
||||
SHA1Managed hash = new SHA1Managed();
|
||||
using (CryptoStream cs = new CryptoStream(Stream.Null, hash, CryptoStreamMode.Write))
|
||||
using (var hash = SHA1.Create())
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
byte[] buf = new byte[8192];
|
||||
HashChunk(stream, cs, buf, (int)headerLength);
|
||||
stream.Seek(textSectionFileOffset, SeekOrigin.Begin);
|
||||
HashChunk(stream, cs, buf, (int)(strongNameSignatureFileOffset - textSectionFileOffset));
|
||||
stream.Seek(strongNameSignatureLength, SeekOrigin.Current);
|
||||
HashChunk(stream, cs, buf, (int)(stream.Length - (strongNameSignatureFileOffset + strongNameSignatureLength)));
|
||||
}
|
||||
using (RSA rsa = keyPair.CreateRSA())
|
||||
{
|
||||
RSAPKCS1SignatureFormatter sign = new RSAPKCS1SignatureFormatter(rsa);
|
||||
byte[] signature = sign.CreateSignature(hash);
|
||||
Array.Reverse(signature);
|
||||
if (signature.Length != strongNameSignatureLength)
|
||||
using (CryptoStream cs = new CryptoStream(Stream.Null, hash, CryptoStreamMode.Write))
|
||||
{
|
||||
throw new InvalidOperationException("Signature length mismatch");
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
byte[] buf = new byte[8192];
|
||||
HashChunk(stream, cs, buf, (int)headerLength);
|
||||
stream.Seek(textSectionFileOffset, SeekOrigin.Begin);
|
||||
HashChunk(stream, cs, buf, (int)(strongNameSignatureFileOffset - textSectionFileOffset));
|
||||
stream.Seek(strongNameSignatureLength, SeekOrigin.Current);
|
||||
HashChunk(stream, cs, buf, (int)(stream.Length - (strongNameSignatureFileOffset + strongNameSignatureLength)));
|
||||
}
|
||||
using (RSA rsa = keyPair.CreateRSA())
|
||||
{
|
||||
RSAPKCS1SignatureFormatter sign = new RSAPKCS1SignatureFormatter(rsa);
|
||||
byte[] signature = sign.CreateSignature(hash);
|
||||
Array.Reverse(signature);
|
||||
if (signature.Length != strongNameSignatureLength)
|
||||
{
|
||||
throw new InvalidOperationException("Signature length mismatch");
|
||||
}
|
||||
stream.Seek(strongNameSignatureFileOffset, SeekOrigin.Begin);
|
||||
stream.Write(signature, 0, signature.Length);
|
||||
}
|
||||
stream.Seek(strongNameSignatureFileOffset, SeekOrigin.Begin);
|
||||
stream.Write(signature, 0, signature.Length);
|
||||
}
|
||||
|
||||
// compute the PE checksum
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
int count = (int)stream.Length / 4;
|
||||
BinaryReader br = new BinaryReader(stream);
|
||||
long sum = 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
sum += br.ReadUInt32();
|
||||
int carry = (int)(sum >> 32);
|
||||
sum &= 0xFFFFFFFFU;
|
||||
sum += carry;
|
||||
}
|
||||
while ((sum >> 16) != 0)
|
||||
{
|
||||
sum = (sum & 0xFFFF) + (sum >> 16);
|
||||
}
|
||||
sum += stream.Length;
|
||||
// compute the PE checksum
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
int count = (int)stream.Length / 4;
|
||||
BinaryReader br = new BinaryReader(stream);
|
||||
long sum = 0;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
sum += br.ReadUInt32();
|
||||
int carry = (int)(sum >> 32);
|
||||
sum &= 0xFFFFFFFFU;
|
||||
sum += carry;
|
||||
}
|
||||
while ((sum >> 16) != 0)
|
||||
{
|
||||
sum = (sum & 0xFFFF) + (sum >> 16);
|
||||
}
|
||||
sum += stream.Length;
|
||||
|
||||
// write the PE checksum, note that it is always at offset 0xD8 in the file
|
||||
ByteBuffer bb = new ByteBuffer(4);
|
||||
bb.Write((int)sum);
|
||||
stream.Seek(0xD8, SeekOrigin.Begin);
|
||||
bb.WriteTo(stream);
|
||||
// write the PE checksum, note that it is always at offset 0xD8 in the file
|
||||
ByteBuffer bb = new ByteBuffer(4);
|
||||
bb.Write((int)sum);
|
||||
stream.Seek(0xD8, SeekOrigin.Begin);
|
||||
bb.WriteTo(stream);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void HashChunk(Stream stream, CryptoStream cs, byte[] buf, int length)
|
||||
@ -443,21 +445,23 @@ namespace IKVM.Reflection.Writer
|
||||
|
||||
private static Guid GenerateModuleVersionId(Stream stream)
|
||||
{
|
||||
SHA1Managed hash = new SHA1Managed();
|
||||
using (CryptoStream cs = new CryptoStream(Stream.Null, hash, CryptoStreamMode.Write))
|
||||
using (var hash = SHA1.Create())
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
byte[] buf = new byte[8192];
|
||||
HashChunk(stream, cs, buf, (int)stream.Length);
|
||||
using (CryptoStream cs = new CryptoStream(Stream.Null, hash, CryptoStreamMode.Write))
|
||||
{
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
byte[] buf = new byte[8192];
|
||||
HashChunk(stream, cs, buf, (int)stream.Length);
|
||||
}
|
||||
byte[] bytes = new byte[16];
|
||||
Buffer.BlockCopy(hash.Hash, 0, bytes, 0, bytes.Length);
|
||||
// set GUID type to "version 4" (random)
|
||||
bytes[7] &= 0x0F;
|
||||
bytes[7] |= 0x40;
|
||||
bytes[8] &= 0x3F;
|
||||
bytes[8] |= 0x80;
|
||||
return new Guid(bytes);
|
||||
}
|
||||
byte[] bytes = new byte[16];
|
||||
Buffer.BlockCopy(hash.Hash, 0, bytes, 0, bytes.Length);
|
||||
// set GUID type to "version 4" (random)
|
||||
bytes[7] &= 0x0F;
|
||||
bytes[7] |= 0x40;
|
||||
bytes[8] &= 0x3F;
|
||||
bytes[8] |= 0x80;
|
||||
return new Guid(bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ static partial class Consts
|
||||
// Use these assembly version constants to make code more maintainable.
|
||||
//
|
||||
|
||||
public const string MonoVersion = "6.6.0.104";
|
||||
public const string MonoVersion = "6.6.0.108";
|
||||
public const string MonoCompany = "Mono development team";
|
||||
public const string MonoProduct = "Mono Common Language Infrastructure";
|
||||
public const string MonoCopyright = "(c) Various Mono authors";
|
||||
|
@ -1 +1 @@
|
||||
addab8be965ae9005b32f1e7d936ae29cb4ddcb9
|
||||
b10ab205f4ddf7ade4f67c298be0e63e3c5f8f21
|
@ -1 +1 @@
|
||||
08b71dcc521f5daf8d9ae0ed23c76174fd660f3d
|
||||
e3f5bd3451532718c09696f79f48473f70fa4fda
|
@ -1 +1 @@
|
||||
8fa48a2b7ac8924c42b928ae493daa20f9f7b5fd
|
||||
3663feb80116629dcca2773e113a1deafac0bce0
|
@ -1 +1 @@
|
||||
a5183e89063f54935ac22fc1f71783b278094ec8
|
||||
327b3da707a9b6f16d9231839094d1ca0765c5f5
|
@ -1 +1 @@
|
||||
6432fb38c53b70767df7c23d754f0389dd1c81c2
|
||||
4bc82e5018b862e746408c4226aaabb48a39c7ce
|
@ -1 +1 @@
|
||||
3fc6751cf2f2ec7fdaf7aef8bdc83bf41b164075
|
||||
7fc65f5a9b87a7c64125074e2dcf74a3ae422bb4
|
@ -1 +1 @@
|
||||
e352912f599cf03664d63b0c48185fa3935cb9ce
|
||||
50c42c6133e6f0da5d405fe88fa3fe18c494d6e7
|
@ -1 +1 @@
|
||||
addab8be965ae9005b32f1e7d936ae29cb4ddcb9
|
||||
b10ab205f4ddf7ade4f67c298be0e63e3c5f8f21
|
@ -1 +1 @@
|
||||
08b71dcc521f5daf8d9ae0ed23c76174fd660f3d
|
||||
e3f5bd3451532718c09696f79f48473f70fa4fda
|
@ -1 +1 @@
|
||||
8fa48a2b7ac8924c42b928ae493daa20f9f7b5fd
|
||||
3663feb80116629dcca2773e113a1deafac0bce0
|
@ -1 +1 @@
|
||||
a5183e89063f54935ac22fc1f71783b278094ec8
|
||||
327b3da707a9b6f16d9231839094d1ca0765c5f5
|
@ -1 +1 @@
|
||||
6432fb38c53b70767df7c23d754f0389dd1c81c2
|
||||
4bc82e5018b862e746408c4226aaabb48a39c7ce
|
@ -1 +1 @@
|
||||
3fc6751cf2f2ec7fdaf7aef8bdc83bf41b164075
|
||||
7fc65f5a9b87a7c64125074e2dcf74a3ae422bb4
|
@ -1 +1 @@
|
||||
f96950d184e0aef6f894f376f123130316461e94
|
||||
130318c7d2a52a90714b422cfad67998f7bb3cf7
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user