You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
File diff suppressed because it is too large
Load Diff
@@ -16,6 +16,7 @@ net_4_5_dirs := \
|
||||
xbuild \
|
||||
csharp \
|
||||
corcompare \
|
||||
mono-api-html \
|
||||
compiler-tester \
|
||||
mono-xmltool \
|
||||
mono-shlib-cop \
|
||||
@@ -48,11 +49,11 @@ net_4_5_dirs := \
|
||||
mono-symbolicate \
|
||||
linker-analyzer
|
||||
|
||||
build_SUBDIRS = gacutil security culevel
|
||||
build_SUBDIRS = gacutil security culevel cil-stringreplacer commoncryptogenerator
|
||||
net_4_5_SUBDIRS = gacutil
|
||||
net_4_5_PARALLEL_SUBDIRS = $(net_4_5_dirs)
|
||||
|
||||
SUBDIRS = $(basic_SUBDIRS) $(net_4_5_dirs)
|
||||
SUBDIRS = $(build_SUBDIRS) $(net_4_5_dirs)
|
||||
|
||||
include ../build/rules.make
|
||||
|
||||
|
@@ -1,75 +0,0 @@
|
||||
2007-08-23 Gert Driesen <drieseng@users.sourceforge.net>
|
||||
|
||||
* Al.cs: Ignore AssemblyKeyAttribute in template when KeyFile is null
|
||||
or a zero-length string. Ignore AssemblyKeyNameAtribute in template
|
||||
when KeyName is null or a zero-length string. Fixes bug #82550.
|
||||
|
||||
2007-01-15 Gert Driesen <drieseng@users.sourceforge.net>
|
||||
|
||||
* Al.cs: Use DelaySign enum to capture whether a delaysign (+ or -)
|
||||
option was specified, and what value was set. This was necessary to
|
||||
make a distinction between leaving the default value (possibly
|
||||
obtained from a template assembly), and explicitly turned delay signing
|
||||
off. Removed unused IsStrongName method. Added support for absolute
|
||||
paths for modules on unix (borrowed from mcs). Previously absolute
|
||||
paths where reported as unrecognized command line options. Only add
|
||||
AssemblyDelaySignAttribute, AssemblyKeyFileAttribute and
|
||||
AssemblyKeyNameAttribute on 1.0 profile. Do not add an
|
||||
AssemblyCultureAttribute if culture is specified, instead set the
|
||||
culture on the AssemblyName. When template is not an absolute path,
|
||||
then consider it to relative to the current directory. Removed unused
|
||||
AddResource method. Do not require template to be strongly signed;
|
||||
although MSDN states this, MS does not enforce this (and it should not).
|
||||
Template option take a file name, not an assembly name. Fixed bug
|
||||
#80440. When a template is set, use the keyfile specified in
|
||||
AssemblyKeyFileAttribute of that template to sign the assembly (unless
|
||||
overridden by /keyfile option). Same goes for AssemblyDelaySignAttribute
|
||||
and AssemblyKeyNameAttribute.
|
||||
|
||||
2007-01-12 Gert Driesen <drieseng@users.sourceforge.net>
|
||||
|
||||
* Makefile: Make profile-specific.
|
||||
(CLEAN_FILES): Add 'al.exe' and 'al.exe.mdb'.
|
||||
|
||||
2005-08-01 Carlos Alberto Cortez <calberto.cortez@gmail.com>
|
||||
|
||||
* Al.cs: Use AssemblyBuilder.AddResourceFile instead of
|
||||
AddResourceFile when linkin to a resource, just as .NET
|
||||
does.
|
||||
|
||||
2005-07-08 Zoltan Varga <vargaz@freemail.hu>
|
||||
|
||||
* Al.cs: Applied patch from Sridhar Kulkarni (sridharkulkarni@msn.com).
|
||||
Implement /template option. Fixes #74814.
|
||||
|
||||
2005-06-14 Sebastien Pouliot <sebastien@ximian.com>
|
||||
|
||||
* Al.cs: Added support for signing/delay-signing/ecma-delay-signing.
|
||||
* Makefile: Added dependency on Mono.Security.dll for CryptoConvert.
|
||||
|
||||
2005-03-01 Zoltan Varga <vargaz@freemail.hu>
|
||||
|
||||
* Al.cs: Applied patch from Gert Driesen (gert.driesen@pandora.be).
|
||||
Fixes #72274.
|
||||
|
||||
* Al.cs: Algid and Flags should be specified in hexadecimal. Fixes
|
||||
#72282.
|
||||
|
||||
2005-01-30 Zoltan Varga <vargaz@freemail.hu>
|
||||
|
||||
* Al.cs: Fix spitting of newlines.
|
||||
|
||||
* Al.cs: Add support for response files. Fixes #71949.
|
||||
|
||||
2004-03-15 Zoltan Varga <vargaz@freemail.hu>
|
||||
|
||||
* Al.cs: Avoid crash if entryPoint is not defined.
|
||||
|
||||
2004-01-16 Atsushi Enomoto <atsushi@ximian.com>
|
||||
|
||||
* Al.cs : csc build fix. See bugzilla #47991.
|
||||
|
||||
2004-01-15 Zoltan Varga <vargaz@freemail.hu>
|
||||
|
||||
* Al.cs Makefile ChangeLog al.exe.sources: New files.
|
||||
|
@@ -2,7 +2,8 @@ thisdir = tools/al
|
||||
SUBDIRS =
|
||||
include ../../build/rules.make
|
||||
|
||||
LOCAL_MCS_FLAGS = -r:Mono.Security.dll -r:System.Security.dll -r:Mono.CompilerServices.SymbolWriter
|
||||
LOCAL_MCS_FLAGS =
|
||||
LIB_REFS = System System.Core Mono.Security System.Security Mono.CompilerServices.SymbolWriter
|
||||
PROGRAM = al.exe
|
||||
|
||||
CLEAN_FILES = al.exe al.exe.mdb
|
||||
|
@@ -1,12 +0,0 @@
|
||||
2004-05-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
|
||||
|
||||
* BrowserCapsUpdater.cs: update URL for browscap.ini.
|
||||
|
||||
2003-12-16 Gonzalo Paniagua Javier <gonzalo@ximian.com>
|
||||
|
||||
* ChangeLog:
|
||||
* Makefile:
|
||||
* browsercaps-updater.exe.sources:
|
||||
* BrowserCapsUpdater.cs: new tool to update browscap.ini file. For
|
||||
those users who just can't wait for the next mono release.
|
||||
|
@@ -2,6 +2,9 @@ thisdir = tools/browsercaps-updater
|
||||
SUBDIRS =
|
||||
include ../../build/rules.make
|
||||
|
||||
LOCAL_MCS_FLAGS =
|
||||
LIB_REFS = System
|
||||
|
||||
PROGRAM = browsercaps-updater.exe
|
||||
|
||||
include ../../build/executable.make
|
||||
|
@@ -4,6 +4,7 @@ include ../../build/rules.make
|
||||
|
||||
PROGRAM = cccheck.exe
|
||||
|
||||
LOCAL_MCS_FLAGS = -r:Mono.CodeContracts.dll
|
||||
LOCAL_MCS_FLAGS =
|
||||
LIB_REFS = Mono.CodeContracts System
|
||||
|
||||
include ../../build/executable.make
|
||||
|
@@ -4,6 +4,7 @@ include ../../build/rules.make
|
||||
|
||||
PROGRAM = ccrewrite.exe
|
||||
|
||||
LOCAL_MCS_FLAGS = -r:Mono.CodeContracts.dll
|
||||
LOCAL_MCS_FLAGS =
|
||||
LIB_REFS = Mono.CodeContracts System System.Core
|
||||
|
||||
include ../../build/executable.make
|
||||
|
10
mcs/tools/cil-stringreplacer/Makefile
Normal file
10
mcs/tools/cil-stringreplacer/Makefile
Normal file
@@ -0,0 +1,10 @@
|
||||
thisdir = tools/cil-stringreplacer
|
||||
SUBDIRS =
|
||||
include ../../build/rules.make
|
||||
|
||||
PROGRAM = cil-stringreplacer.exe
|
||||
NO_INSTALL = yes
|
||||
|
||||
LIB_REFS = System Mono.Cecil
|
||||
|
||||
include ../../build/executable.make
|
158
mcs/tools/cil-stringreplacer/cil-stringreplacer.cs
Normal file
158
mcs/tools/cil-stringreplacer/cil-stringreplacer.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
//
|
||||
// cil-stringreplacer.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <marek.safar@gmail.com>
|
||||
//
|
||||
// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Mono.Cecil;
|
||||
using Mono.Cecil.Cil;
|
||||
using Mono.Options;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class Program
|
||||
{
|
||||
class CmdOptions
|
||||
{
|
||||
public bool ShowHelp { get; set; }
|
||||
public bool Verbose { get; set; }
|
||||
public List<string> ResourcesStrings { get; }
|
||||
|
||||
public CmdOptions ()
|
||||
{
|
||||
ResourcesStrings = new List<string> ();
|
||||
}
|
||||
}
|
||||
|
||||
public static int Main (string[] args)
|
||||
{
|
||||
var options = new CmdOptions ();
|
||||
|
||||
var p = new OptionSet () {
|
||||
{ "r|resourcestrings=", "File with string resource in key=value format",
|
||||
v => options.ResourcesStrings.Add (v) },
|
||||
{ "h|help", "Display available options",
|
||||
v => options.ShowHelp = v != null },
|
||||
{ "v|verbose", "Use verbose output",
|
||||
v => options.Verbose = v != null },
|
||||
};
|
||||
|
||||
List<string> extra;
|
||||
try {
|
||||
extra = p.Parse (args);
|
||||
}
|
||||
catch (OptionException e) {
|
||||
Console.WriteLine (e.Message);
|
||||
Console.WriteLine ("Try 'cil-stringreplacer -help' for more information.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (options.ShowHelp) {
|
||||
ShowHelp (p);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (extra.Count != 1) {
|
||||
ShowHelp (p);
|
||||
return 2;
|
||||
}
|
||||
|
||||
var resourcesStrings = new Dictionary<string, string> ();
|
||||
if (!LoadGetResourceStrings (resourcesStrings, options))
|
||||
return 3;
|
||||
|
||||
RewriteAssembly (extra [0], resourcesStrings, options);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ShowHelp (OptionSet p)
|
||||
{
|
||||
Console.WriteLine ("Usage: cil-stringreplacer [options] assembly");
|
||||
Console.WriteLine ("Rewrites all occurences of string keys with their values from string resource file");
|
||||
Console.WriteLine ();
|
||||
Console.WriteLine ("Options:");
|
||||
p.WriteOptionDescriptions (Console.Out);
|
||||
}
|
||||
|
||||
static void RewriteAssembly (string assemblyLocation, Dictionary<string, string> resourcesStrings, CmdOptions options)
|
||||
{
|
||||
var readerParameters = new ReaderParameters { ReadSymbols = true };
|
||||
var assembly = AssemblyDefinition.ReadAssembly (assemblyLocation, readerParameters);
|
||||
foreach (var module in assembly.Modules) {
|
||||
foreach (var type in module.GetTypes ()) {
|
||||
foreach (var method in type.Methods) {
|
||||
if (!method.HasBody)
|
||||
continue;
|
||||
|
||||
foreach (var instr in method.Body.Instructions) {
|
||||
if (instr.OpCode != OpCodes.Ldstr)
|
||||
continue;
|
||||
|
||||
string value;
|
||||
if (resourcesStrings.TryGetValue ((string)instr.Operand, out value)) {
|
||||
if (options.Verbose) {
|
||||
Console.WriteLine ($"Replacing '{instr.Operand}' with '{value}'");
|
||||
}
|
||||
|
||||
instr.Operand = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var writerParameters = new WriterParameters { WriteSymbols = true };
|
||||
assembly.Write (assemblyLocation, writerParameters);
|
||||
}
|
||||
|
||||
static bool LoadGetResourceStrings (Dictionary<string, string> resourcesStrings, CmdOptions options)
|
||||
{
|
||||
foreach (var fileName in options.ResourcesStrings) {
|
||||
if (!File.Exists (fileName)) {
|
||||
Console.Error.WriteLine ($"Error reading resource file '{fileName}'");
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var l in File.ReadLines (fileName)) {
|
||||
var line = l.Trim ();
|
||||
if (line.Length == 0 || line [0] == '#' || line [0] == ';')
|
||||
continue;
|
||||
|
||||
var epos = line.IndexOf ('=');
|
||||
if (epos < 0)
|
||||
continue;
|
||||
|
||||
var key = line.Substring (0, epos).Trim ();
|
||||
var value = line.Substring (epos + 1).Trim ();
|
||||
|
||||
resourcesStrings [key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,2 @@
|
||||
cil-stringreplacer.cs
|
||||
../../class/Mono.Options/Mono.Options/Options.cs
|
@@ -1,8 +0,0 @@
|
||||
2009-03-12 Jb Evain <jbevain@novell.com>
|
||||
|
||||
* cilstrip.cs: unwrap TargetInvocationException.
|
||||
|
||||
2008-10-01 Jb Evain <jbevain@novell.com>
|
||||
|
||||
* cilstrip.cs: mono-cecil-cil is a tool to empty method bodies for
|
||||
assemblies that have been AOTed.
|
@@ -2,6 +2,9 @@ thisdir = tools/cil-strip
|
||||
SUBDIRS =
|
||||
include ../../build/rules.make
|
||||
|
||||
LOCAL_MCS_FLAGS =
|
||||
LIB_REFS = System
|
||||
|
||||
PROGRAM = mono-cil-strip.exe
|
||||
|
||||
include ../../build/executable.make
|
||||
|
@@ -1,28 +0,0 @@
|
||||
2005-06-15 Atsushi Enomoto <atsushi@ximian.com>
|
||||
|
||||
* SmallXmlParser.cs, SecurityParser.cs : they can be CLSCompliant now.
|
||||
|
||||
2005-05-12 Atsushi Enomoto <atsushi@ximian.com>
|
||||
|
||||
* SmallXmlParser.cs,
|
||||
SecurityParser.cs : Use new SmallXmlParser.cs instead of MiniParser.
|
||||
|
||||
2004-09-16 Sebastien Pouliot <sebastien@ximian.com>
|
||||
|
||||
* MiniParser.cs: Fixed warning (l4) for unused variables. Removed
|
||||
duplicate (and identical) license.
|
||||
|
||||
2004-05-14 Marek Safar <marek.safar@seznam.cz>
|
||||
|
||||
* MiniParser.cs, SecurityParser.cs: [CLSCompliant (false)]
|
||||
only for public mode.
|
||||
|
||||
2003-07-05 Sebastien Pouliot <spouliot@videotron.ca>
|
||||
|
||||
* SecurityParser.cs: Parse an XML string and convert it to a
|
||||
SecurityElement object.
|
||||
|
||||
2003-02-08 Sebastien Pouliot <spouliot@videotron.ca>
|
||||
|
||||
* MiniParser.cs: Renamed namespace to match new location.
|
||||
|
104
mcs/tools/commoncryptogenerator/CommonCryptorGenerator.cs
Normal file
104
mcs/tools/commoncryptogenerator/CommonCryptorGenerator.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
//
|
||||
// CommonCrypto code generator for symmetric block cipher algorithms
|
||||
//
|
||||
// Authors:
|
||||
// Sebastien Pouliot <sebastien@xamarin.com>
|
||||
//
|
||||
// Copyright 2012 Xamarin Inc.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Xamarin {
|
||||
|
||||
public static class CommonCryptor {
|
||||
|
||||
static public void Generate (string namespaceName, string typeName, string baseTypeName, string ccAlgorithmName, string feedbackSize = "8", string ctorInitializers = null)
|
||||
{
|
||||
string template = @"// Generated file to bind CommonCrypto cipher algorithms - DO NOT EDIT
|
||||
//
|
||||
// Authors:
|
||||
// Sebastien Pouliot <sebastien@xamarin.com>
|
||||
//
|
||||
// Copyright 2012-2014 Xamarin Inc.
|
||||
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
using Mono.Security.Cryptography;
|
||||
using Crimson.CommonCrypto;
|
||||
|
||||
namespace %NAMESPACE% {
|
||||
|
||||
public sealed partial class %TYPE% : %BASE% {
|
||||
|
||||
public %TYPE% ()
|
||||
{
|
||||
FeedbackSizeValue = %FEEDBACKSIZE%;
|
||||
%CTOR_INIT%
|
||||
}
|
||||
|
||||
public override void GenerateIV ()
|
||||
{
|
||||
IVValue = KeyBuilder.IV (BlockSizeValue >> 3);
|
||||
}
|
||||
|
||||
public override void GenerateKey ()
|
||||
{
|
||||
KeyValue = KeyBuilder.Key (KeySizeValue >> 3);
|
||||
}
|
||||
|
||||
public override ICryptoTransform CreateDecryptor (byte[] rgbKey, byte[] rgbIV)
|
||||
{
|
||||
IntPtr decryptor = IntPtr.Zero;
|
||||
switch (Mode) {
|
||||
case CipherMode.CBC:
|
||||
decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.None, rgbKey, rgbIV);
|
||||
return new FastCryptorTransform (decryptor, this, false, rgbIV);
|
||||
case CipherMode.ECB:
|
||||
decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
|
||||
return new FastCryptorTransform (decryptor, this, false, rgbIV);
|
||||
case CipherMode.CFB:
|
||||
#if MONOTOUCH || XAMMAC
|
||||
IntPtr encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
|
||||
decryptor = Cryptor.Create (CCOperation.Decrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
|
||||
return new CryptorTransform (decryptor, encryptor, this, false, rgbIV);
|
||||
#else
|
||||
throw new CryptographicException (""CFB is not supported by Crimson.CommonCrypto"");
|
||||
#endif
|
||||
default:
|
||||
throw new CryptographicException (String.Format (""{0} is not supported by the .NET framework"", Mode));
|
||||
}
|
||||
}
|
||||
|
||||
public override ICryptoTransform CreateEncryptor (byte[] rgbKey, byte[] rgbIV)
|
||||
{
|
||||
IntPtr encryptor = IntPtr.Zero;
|
||||
switch (Mode) {
|
||||
case CipherMode.CBC:
|
||||
encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.None, rgbKey, rgbIV);
|
||||
return new FastCryptorTransform (encryptor, this, true, rgbIV);
|
||||
case CipherMode.ECB:
|
||||
encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
|
||||
return new FastCryptorTransform (encryptor, this, true, rgbIV);
|
||||
case CipherMode.CFB:
|
||||
#if MONOTOUCH || XAMMAC
|
||||
encryptor = Cryptor.Create (CCOperation.Encrypt, CCAlgorithm.%CCALGORITHM%, CCOptions.ECBMode, rgbKey, rgbIV);
|
||||
return new CryptorTransform (encryptor, IntPtr.Zero, this, true, rgbIV);
|
||||
#else
|
||||
throw new CryptographicException (""CFB is not supported by Crimson.CommonCrypto"");
|
||||
#endif
|
||||
default:
|
||||
throw new CryptographicException (String.Format (""{0} is not supported by the .NET framework"", Mode));
|
||||
}
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
|
||||
Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).Replace("%FEEDBACKSIZE%", feedbackSize).Replace ("%CTOR_INIT%", ctorInitializers).
|
||||
Replace ("%CCALGORITHM%", ccAlgorithmName.ToString ()));
|
||||
}
|
||||
}
|
||||
}
|
167
mcs/tools/commoncryptogenerator/CommonDigestGenerator.cs
Normal file
167
mcs/tools/commoncryptogenerator/CommonDigestGenerator.cs
Normal file
@@ -0,0 +1,167 @@
|
||||
//
|
||||
// CommonCrypto code generator for digest algorithms
|
||||
//
|
||||
// Authors:
|
||||
// Sebastien Pouliot <sebastien@xamarin.com>
|
||||
//
|
||||
// Copyright 2012-2014 Xamarin Inc.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Xamarin {
|
||||
|
||||
public static class CommonDigest {
|
||||
|
||||
#if !MONOTOUCH && !XAMMAC
|
||||
// we do not add anything in MonoTouch, just replacing, so this is not needed
|
||||
// however we can avoid a dependency on Mono.Security for Crimson.CommonCrypto.dll by including the base classes
|
||||
static public void GenerateBaseClass (string namespaceName, string typeName, string baseTypeName, int hashSize,
|
||||
string visibilityStart = "", string visibilityEnd = "")
|
||||
{
|
||||
string template = @"// Generated file to bind CommonCrypto/CommonDigest - DO NOT EDIT
|
||||
//
|
||||
// Authors:
|
||||
// Sebastien Pouliot <sebastien@xamarin.com>
|
||||
//
|
||||
// Copyright 2012-2014 Xamarin Inc.
|
||||
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace %NAMESPACE% {
|
||||
|
||||
%VISIBILITY_START%
|
||||
public
|
||||
%VISIBILITY_END%
|
||||
abstract class %BASE% : HashAlgorithm {
|
||||
|
||||
protected %BASE% ()
|
||||
{
|
||||
HashSizeValue = %HASHSIZE%;
|
||||
}
|
||||
|
||||
public static new %BASE% Create ()
|
||||
{
|
||||
return Create (""%BASE%"");
|
||||
}
|
||||
|
||||
public static new %BASE% Create (string hashName)
|
||||
{
|
||||
object o = CryptoConfig.CreateFromName (hashName);
|
||||
return (%BASE%) o ?? new %TYPE% ();
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
File.WriteAllText (baseTypeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
|
||||
Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).
|
||||
Replace ("%VISIBILITY_START%", visibilityStart).Replace ("%VISIBILITY_END%", visibilityEnd).
|
||||
Replace ("%HASHSIZE%", hashSize.ToString ()));
|
||||
}
|
||||
#endif
|
||||
static public void Generate (string namespaceName, string typeName, string baseTypeName, int contextSize,
|
||||
string visibilityStart = "", string visibilityEnd = "")
|
||||
{
|
||||
string template = @"// Generated file to bind CommonCrypto/CommonDigest - DO NOT EDIT
|
||||
//
|
||||
// Authors:
|
||||
// Sebastien Pouliot <sebastien@xamarin.com>
|
||||
//
|
||||
// Copyright 2011-2014 Xamarin Inc.
|
||||
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
using Mono.Security.Cryptography;
|
||||
|
||||
namespace %NAMESPACE% {
|
||||
|
||||
%VISIBILITY_START%
|
||||
public
|
||||
%VISIBILITY_END%
|
||||
sealed class %TYPE% : %BASE% {
|
||||
|
||||
IntPtr ctx;
|
||||
|
||||
[DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Init"")]
|
||||
static extern int Init (/* CC_%BASE%_CTX */ IntPtr c);
|
||||
|
||||
[DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Update"")]
|
||||
static extern int Update (/* CC_%BASE%_CTX */ IntPtr c, /* const void * */ IntPtr data, /* uint32_t */ uint len);
|
||||
|
||||
[DllImport (""/usr/lib/libSystem.dylib"", EntryPoint=""CC_%BASE%_Final"")]
|
||||
static extern int Final (/* unsigned char * */ byte [] md, /* CC_%BASE%_CTX */ IntPtr c);
|
||||
|
||||
public %TYPE% ()
|
||||
{
|
||||
ctx = IntPtr.Zero;
|
||||
}
|
||||
|
||||
~%TYPE% ()
|
||||
{
|
||||
Dispose (false);
|
||||
}
|
||||
|
||||
protected override void Dispose (bool disposing)
|
||||
{
|
||||
if (ctx != IntPtr.Zero) {
|
||||
Marshal.FreeHGlobal (ctx);
|
||||
ctx = IntPtr.Zero;
|
||||
}
|
||||
base.Dispose (disposing);
|
||||
GC.SuppressFinalize (this);
|
||||
}
|
||||
|
||||
public override void Initialize ()
|
||||
{
|
||||
if (ctx == IntPtr.Zero)
|
||||
ctx = Marshal.AllocHGlobal (%CTX_SIZE%);
|
||||
|
||||
int hr = Init (ctx);
|
||||
if (hr != 1)
|
||||
throw new CryptographicException (hr);
|
||||
}
|
||||
|
||||
protected override void HashCore (byte[] data, int start, int length)
|
||||
{
|
||||
if (ctx == IntPtr.Zero)
|
||||
Initialize ();
|
||||
|
||||
if (data.Length == 0)
|
||||
return;
|
||||
|
||||
unsafe {
|
||||
fixed (byte* p = &data [0]) {
|
||||
int hr = Update (ctx, (IntPtr) (p + start), (uint) length);
|
||||
if (hr != 1)
|
||||
throw new CryptographicException (hr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override byte[] HashFinal ()
|
||||
{
|
||||
if (ctx == IntPtr.Zero)
|
||||
Initialize ();
|
||||
|
||||
byte[] data = new byte [HashSize >> 3];
|
||||
int hr = Final (data, ctx);
|
||||
if (hr != 1)
|
||||
throw new CryptographicException (hr);
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}";
|
||||
|
||||
File.WriteAllText (typeName + ".g.cs", template.Replace ("%NAMESPACE%", namespaceName).
|
||||
Replace ("%TYPE%", typeName).Replace ("%BASE%", baseTypeName).
|
||||
Replace ("%VISIBILITY_START%", visibilityStart).Replace ("%VISIBILITY_END%", visibilityEnd).
|
||||
Replace ("%CTX_SIZE%", contextSize.ToString ()));
|
||||
}
|
||||
}
|
||||
}
|
11
mcs/tools/commoncryptogenerator/Makefile
Normal file
11
mcs/tools/commoncryptogenerator/Makefile
Normal file
@@ -0,0 +1,11 @@
|
||||
thisdir = tools/commoncryptogenerator
|
||||
SUBDIRS =
|
||||
include ../../build/rules.make
|
||||
|
||||
LIB_REFS =
|
||||
LOCAL_MCS_FLAGS =
|
||||
|
||||
PROGRAM = commoncryptogenerator.exe
|
||||
NO_INSTALL = yes
|
||||
|
||||
include ../../build/executable.make
|
@@ -0,0 +1,3 @@
|
||||
CommonCryptorGenerator.cs
|
||||
generator.cs
|
||||
CommonDigestGenerator.cs
|
57
mcs/tools/commoncryptogenerator/generator.cs
Normal file
57
mcs/tools/commoncryptogenerator/generator.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// CommonCrypto Code Generator
|
||||
//
|
||||
// Authors:
|
||||
// Sebastien Pouliot <sebastien@xamarin.com>
|
||||
//
|
||||
// Copyright 2012 Xamarin Inc.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace Xamarin {
|
||||
|
||||
class Program {
|
||||
static void Main (string [] args)
|
||||
{
|
||||
// mscorlib replacements
|
||||
CommonDigest.Generate ("System.Security.Cryptography", "MD5CryptoServiceProvider", "MD5", 1000);
|
||||
CommonDigest.Generate ("System.Security.Cryptography", "SHA1CryptoServiceProvider", "SHA1", 1000);
|
||||
CommonDigest.Generate ("System.Security.Cryptography", "SHA1Managed", "SHA1", 1000);
|
||||
CommonDigest.Generate ("System.Security.Cryptography", "SHA256Managed", "SHA256", 1000);
|
||||
CommonDigest.Generate ("System.Security.Cryptography", "SHA384Managed", "SHA384", 1000);
|
||||
CommonDigest.Generate ("System.Security.Cryptography", "SHA512Managed", "SHA512", 1000);
|
||||
|
||||
// System.Core replacements - not yet in MT profile (4.0 - functional dupes anyway)
|
||||
//CommonDigest.Generate ("System.Security.Cryptography", "MD5Cng", "MD5", 1000);
|
||||
//CommonDigest.Generate ("System.Security.Cryptography", "SHA256Cng", "SHA256", 1000);
|
||||
//CommonDigest.Generate ("System.Security.Cryptography", "SHA384Cng", "SHA384", 1000);
|
||||
//CommonDigest.Generate ("System.Security.Cryptography", "SHA512Cng", "SHA512", 1000);
|
||||
//CommonDigest.Generate ("System.Security.Cryptography", "SHA256CryptoServiceProvider", "SHA256", 1000);
|
||||
//CommonDigest.Generate ("System.Security.Cryptography", "SHA384CryptoServiceProvider", "SHA384", 1000);
|
||||
//CommonDigest.Generate ("System.Security.Cryptography", "SHA512CryptoServiceProvider", "SHA512", 1000);
|
||||
|
||||
// Mono.Security replacements
|
||||
CommonDigest.Generate ("Mono.Security.Cryptography", "MD2Managed", "MD2", 1000, "#if !INSIDE_CORLIB", "#endif");
|
||||
CommonDigest.Generate ("Mono.Security.Cryptography", "MD4Managed", "MD4", 1000, "#if !INSIDE_CORLIB", "#endif");
|
||||
CommonDigest.Generate ("Mono.Security.Cryptography", "SHA224Managed", "SHA224", 1000);
|
||||
|
||||
// mscorlib replacements
|
||||
CommonCryptor.Generate ("System.Security.Cryptography", "DESCryptoServiceProvider", "DES", "DES");
|
||||
CommonCryptor.Generate ("System.Security.Cryptography", "TripleDESCryptoServiceProvider", "TripleDES", "TripleDES");
|
||||
CommonCryptor.Generate ("System.Security.Cryptography", "RC2CryptoServiceProvider", "RC2", "RC2", ctorInitializers: "LegalKeySizesValue = new[] { new KeySizes(40, 128, 8) };");
|
||||
// Rijndael supports block sizes that are not available in AES - as such it does not use the same generated code
|
||||
// but has it's own version, using AES (128 bits block size) and falling back to managed (192/256 bits block size)
|
||||
|
||||
// System.Core replacements
|
||||
CommonCryptor.Generate ("System.Security.Cryptography", "AesManaged", "Aes", "AES128", "128");
|
||||
CommonCryptor.Generate ("System.Security.Cryptography", "AesCryptoServiceProvider", "Aes", "AES128");
|
||||
|
||||
// Mono.Security replacements
|
||||
// RC4 is a stream (not a block) cipher so it can not reuse the generated code
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,171 +0,0 @@
|
||||
2009-11-05 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Add predefined negative file masks.
|
||||
|
||||
2009-09-20 Sebastien Pouliot <sebastien@ximian.com>
|
||||
|
||||
* compiler-tester.cs: Define out some parts for NET_2_1 since
|
||||
they are not part of Silverlight 2 public API
|
||||
|
||||
2009-07-29 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Add predefined file masks.
|
||||
|
||||
2009-06-02 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Add "safe-execution" options.
|
||||
|
||||
2009-02-19 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: More verbosity needed for runtime crashes.
|
||||
|
||||
2008-11-05 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Better -warnaserror detection.
|
||||
|
||||
2008-10-01 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Fixed broken value type test.
|
||||
|
||||
2008-09-10 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Add non-varags LogLine overload.
|
||||
|
||||
2008-07-28 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Removed ExecuteFile.
|
||||
|
||||
2008-07-24 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Always exercise symbol writer.
|
||||
|
||||
2008-07-29 Martin Baulig <martin@ximian.com>
|
||||
|
||||
* compiler-tester.cs: Added `-compiler-options' command line
|
||||
argument to specify global compiler options in addition to the
|
||||
ones which are read from the test cases.
|
||||
|
||||
2008-04-22 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Print test name when IL reduction is detected.
|
||||
|
||||
2008-04-07 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Don't report IL reduction as regression.
|
||||
|
||||
2008-03-14 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Handle new tests correctly.
|
||||
|
||||
2008-03-14 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Replaced XmlTextWriter and XmlTextReader with
|
||||
XmlWriter and XmlReader.
|
||||
|
||||
2008-03-14 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Added IL regression support.
|
||||
|
||||
2008-03-13 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Refactored to support verbose mode.
|
||||
|
||||
2008-02-18 Raja R Harinath <harinath@hurrynot.org>
|
||||
|
||||
* Makefile ($(dir $(PROGRAM))/.stamp): New.
|
||||
|
||||
2008-02-17 Raja R Harinath <harinath@hurrynot.org>
|
||||
|
||||
* Makefile [PROFILE=net_2_1]: Copy file from net_2_1_raw profile.
|
||||
* compiler-tester.cs: Work better with 'net_2_1' profiles.
|
||||
|
||||
2007-11-28 Raja R Harinath <harinath@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Work better with the 'net_2_1' profile.
|
||||
* xmldocdiff.cs: Disable in the 'net_2_1' profile.
|
||||
|
||||
2007-11-06 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Made the test output less verbose.
|
||||
|
||||
2007-09-21 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Mono assembly loading issue has been fixed, switch
|
||||
to app-domain execution only.
|
||||
|
||||
2007-08-01 Marek Safar <marek.safar@gmail.com>
|
||||
|
||||
* compiler-tester.cs: Report invalid tests separately.
|
||||
|
||||
2006-11-20 Martin Baulig <martin@ximian.com>
|
||||
|
||||
* compiler-tester.cs
|
||||
(PositiveChecker.HandleFailure): Use `LogLine ("{0}", extra)'
|
||||
since the error message from the compiler might contain {}.
|
||||
|
||||
2006-10-06 Marek Safar <marek.safar@seznam.cz>
|
||||
|
||||
* compiler-tester.cs: Positive test file can be now DLL.
|
||||
|
||||
2006-09-27 Marek Safar <marek.safar@seznam.cz>
|
||||
|
||||
* compiler-tester.cs: Add a new "//GMCS:" comment for messages
|
||||
different on 2.0 runtime.
|
||||
Add detection of the exactly same error/warning.
|
||||
|
||||
2006-04-07 Marek Safar <marek.safar@seznam.cz>
|
||||
|
||||
* compiler-tester.cs: Prints known issues stats.
|
||||
|
||||
2006-01-18 Martin Baulig <martin@ximian.com>
|
||||
|
||||
* compiler-tester.cs: Added a new "// Dependencies: " magical
|
||||
comment to provide real dependency tracking.
|
||||
|
||||
2005-11-11 Marek Safar <marek.safar@seznam.cz>
|
||||
|
||||
* compiler-tester.cs: Implemented compiler warning map checking.
|
||||
Enabled message ckeck for gmcs.
|
||||
|
||||
2005-09-27 Marek Safar <marek.safar@seznam.cz>
|
||||
|
||||
* compiler-tester.cs (GetCompilerError): Small fix when no error
|
||||
location and text contains ':'.
|
||||
|
||||
2005-09-22 Raja R Harinath <rharinath@novell.com>
|
||||
|
||||
* compiler-tester.cs (TestRunner.ExecFile): New helper carved out
|
||||
of ...
|
||||
(TestRunner.ExecuteFile) [process version]: ... this.
|
||||
(TestRunner.ExecuteFile) [MethodInfo version]: Add new parameter.
|
||||
Fall back to executing the process if the method invocation fails.
|
||||
(TestRunner.Check): Update to changes.
|
||||
|
||||
2005-09-19 Marek Safar <marek.safar@seznam.cz>
|
||||
|
||||
* compiler-tester: Reverted Martin's revert and ignore gmcs error
|
||||
tests for new checks as most of them are not "valid".
|
||||
|
||||
2005-08-31 Martin Baulig <martin@ximian.com>
|
||||
|
||||
* compiler-tester: Reverted Marek's latest changes - they were
|
||||
breaking 231 gmcs tests.
|
||||
|
||||
2005-06-09 Marek Safar <marek.safar@seznam.cz>
|
||||
|
||||
* compiler-tester: Add process test runner to cope with
|
||||
too many files in AppDomain(s).
|
||||
|
||||
2005-06-06 Raja R Harinath <harinath@gmail.com>
|
||||
|
||||
* Makefile (NO_INSTALL): Set.
|
||||
|
||||
2005-06-06 Raja R Harinath <rharinath@novell.com>
|
||||
|
||||
* Makefile: Convert to use executable.make.
|
||||
* compiler-tester.exe.sources: New.
|
||||
|
||||
2005-06-06 Marek Safar <marek.safar@seznam.cz>
|
||||
|
||||
* Initial commit
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user