diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..a5fcbe5 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,6 @@ +2006-10-16 Sebastien Pouliot + + * ChangeLog: New. Track project-wide changes. + * class/*: New. Class libraries. + * common/*: New. Common source for all Crimson assemblies and tools. + * README: New. Information about the Crimson project. diff --git a/README b/README new file mode 100644 index 0000000..67b3b99 --- /dev/null +++ b/README @@ -0,0 +1,21 @@ +Crimson offers a superset of the cryptographic features available in the .NET +framework. For various reasons Crimson isn't distributed within Mono. The main +reasons being: + +* Target audience + + As a superset to both .NET and Mono cryptographic features, Crimson + is useful to everyone, not just Mono users. + +* Support + + Crimson is not required inside Mono to reach feature parity with MS + implementation of the .NET framework and it's related tools. As such + supporting Crimson is not the goal of the Mono project. + +* Export restriction on cryptographic software + + Laws regarding export and, sometimes import, of cryptography are + diverse and complex. It is difficult to add/remove algorithms and + keep all the required paperwork in sync. Distribution as source-only + makes this a lot easier. diff --git a/class/ChangeLog b/class/ChangeLog new file mode 100644 index 0000000..9cff353 --- /dev/null +++ b/class/ChangeLog @@ -0,0 +1,6 @@ +2006-10-16 Sebastien Pouliot + + * ChangeLog: New. Track libraries-wide changes. + * crimson.snk: New. Strongname key for Crimson libraries; + * Crimson.MHash/*: New. Wrapper for libmhash; + * README: New. Description about the libraries; diff --git a/class/Crimson.MHash/AUTHORS b/class/Crimson.MHash/AUTHORS new file mode 100644 index 0000000..5849da3 --- /dev/null +++ b/class/Crimson.MHash/AUTHORS @@ -0,0 +1 @@ +Sebastien Pouliot diff --git a/class/Crimson.MHash/Assembly/AssemblyInfo.cs b/class/Crimson.MHash/Assembly/AssemblyInfo.cs new file mode 100644 index 0000000..a22cf5a --- /dev/null +++ b/class/Crimson.MHash/Assembly/AssemblyInfo.cs @@ -0,0 +1,38 @@ +// +// AssemblyInfo.cs +// +// Authors: +// Andreas Nahr (ClassDevelopment@A-SoftTech.com) +// Sebastien Pouliot (sebastien@ximian.com) +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.com) +// + +using System; +using System.Reflection; +using System.Resources; +using System.Security; +using System.Security.Permissions; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about the system assembly + +#if NET_2_0 +[assembly: AssemblyVersion ("2.0.0.0")] +#else +[assembly: AssemblyVersion ("1.1.0.0")] +#endif + +[assembly: AssemblyCompany ("Novell and contributors")] +[assembly: AssemblyCopyright ("(C) 2006 Novell")] +[assembly: AssemblyDescription ("Crimson MHash Wrapper Assembly")] +[assembly: AssemblyTitle ("Crimson.MHash.dll")] +[assembly: CLSCompliant (true)] +[assembly: ComVisible (false)] +[assembly: NeutralResourcesLanguage ("en-US")] + +[assembly:SecurityPermission (SecurityAction.RequestMinimum, UnmanagedCode=true)] + +[assembly: AssemblyDelaySign (false)] +[assembly: AssemblyKeyFile ("../crimson.snk")] diff --git a/class/Crimson.MHash/Assembly/ChangeLog b/class/Crimson.MHash/Assembly/ChangeLog new file mode 100644 index 0000000..cbe7985 --- /dev/null +++ b/class/Crimson.MHash/Assembly/ChangeLog @@ -0,0 +1,4 @@ +2006-10-16 Sebastien Pouliot + + * AssemblyInfo.cs: Assembly identification. + * ChangeLog: New. Track changes. diff --git a/class/Crimson.MHash/ChangeLog b/class/Crimson.MHash/ChangeLog new file mode 100644 index 0000000..8a5205e --- /dev/null +++ b/class/Crimson.MHash/ChangeLog @@ -0,0 +1,10 @@ +2006-10-16 Sebastien Pouliot + + * AUTHORS: New. + * ChangeLog: New. Track library changes. + * Crimson.MHash.dll.sources: List of source files to build the + assembly. + * LICENSE.LGPL: License of libmhash + * Makefile: New. Build assembly. + * MIT.X11: License of the wrapper code (when not used with libmhash) + * README: New. Information about the wrapper assembly. diff --git a/class/Crimson.MHash/Crimson.MHash.dll.sources b/class/Crimson.MHash/Crimson.MHash.dll.sources new file mode 100644 index 0000000..be807d2 --- /dev/null +++ b/class/Crimson.MHash/Crimson.MHash.dll.sources @@ -0,0 +1,54 @@ +../../common/Locale.cs +Assembly/AssemblyInfo.cs +Crimson.MHash/MHashHelper.cs +Crimson.MHash/MHashId.cs +Crimson.MHash/MHashWrapper.cs +Crimson.Security.Cryptography/ADLER32.cs +Crimson.Security.Cryptography/ADLER32Native.cs +Crimson.Security.Cryptography/CRC32B.cs +Crimson.Security.Cryptography/CRC32BNative.cs +Crimson.Security.Cryptography/CRC32.cs +Crimson.Security.Cryptography/CRC32Native.cs +Crimson.Security.Cryptography/GOST.cs +Crimson.Security.Cryptography/GOSTNative.cs +Crimson.Security.Cryptography/HAVAL128.cs +Crimson.Security.Cryptography/HAVAL128Native.cs +Crimson.Security.Cryptography/HAVAL160.cs +Crimson.Security.Cryptography/HAVAL160Native.cs +Crimson.Security.Cryptography/HAVAL192.cs +Crimson.Security.Cryptography/HAVAL192Native.cs +Crimson.Security.Cryptography/HAVAL224.cs +Crimson.Security.Cryptography/HAVAL224Native.cs +Crimson.Security.Cryptography/HAVAL256.cs +Crimson.Security.Cryptography/HAVAL256Native.cs +Crimson.Security.Cryptography/MD2.cs +Crimson.Security.Cryptography/MD2Native.cs +Crimson.Security.Cryptography/MD4.cs +Crimson.Security.Cryptography/MD4Native.cs +Crimson.Security.Cryptography/MD5Native.cs +Crimson.Security.Cryptography/RIPEMD128.cs +Crimson.Security.Cryptography/RIPEMD128Native.cs +Crimson.Security.Cryptography/RIPEMD160.cs +Crimson.Security.Cryptography/RIPEMD160Native.cs +Crimson.Security.Cryptography/RIPEMD256.cs +Crimson.Security.Cryptography/RIPEMD256Native.cs +Crimson.Security.Cryptography/RIPEMD320.cs +Crimson.Security.Cryptography/RIPEMD320Native.cs +Crimson.Security.Cryptography/SHA1Native.cs +Crimson.Security.Cryptography/SHA224.cs +Crimson.Security.Cryptography/SHA224Native.cs +Crimson.Security.Cryptography/SHA256Native.cs +Crimson.Security.Cryptography/SHA384Native.cs +Crimson.Security.Cryptography/SHA512Native.cs +Crimson.Security.Cryptography/SNEFRU128.cs +Crimson.Security.Cryptography/SNEFRU128Native.cs +Crimson.Security.Cryptography/SNEFRU256.cs +Crimson.Security.Cryptography/SNEFRU256Native.cs +Crimson.Security.Cryptography/TIGER128.cs +Crimson.Security.Cryptography/TIGER128Native.cs +Crimson.Security.Cryptography/TIGER160.cs +Crimson.Security.Cryptography/TIGER160Native.cs +Crimson.Security.Cryptography/TIGER192.cs +Crimson.Security.Cryptography/TIGER192Native.cs +Crimson.Security.Cryptography/WHIRLPOOL.cs +Crimson.Security.Cryptography/WHIRLPOOLNative.cs diff --git a/class/Crimson.MHash/Crimson.MHash/ChangeLog b/class/Crimson.MHash/Crimson.MHash/ChangeLog new file mode 100644 index 0000000..63f1a76 --- /dev/null +++ b/class/Crimson.MHash/Crimson.MHash/ChangeLog @@ -0,0 +1,6 @@ +2006-10-16 Sebastien Pouliot + + * MHashHelper.cs: New. Helper class used by generated code. + * MHashId.cs: New. Enum of all hash algorithms currently supported + in libmhash. + * MHashWrapper.cs: P/Invoke declarations to use libmhash. diff --git a/class/Crimson.MHash/Crimson.MHash/MHashHelper.cs b/class/Crimson.MHash/Crimson.MHash/MHashHelper.cs new file mode 100644 index 0000000..0c4f8bb --- /dev/null +++ b/class/Crimson.MHash/Crimson.MHash/MHashHelper.cs @@ -0,0 +1,121 @@ +// +// Crimson.MHash.MHashHelper class +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Runtime.InteropServices; +using System.Security.Cryptography; + +namespace Crimson.MHash { + + internal class MHashHelper : IDisposable { + + private MHashId type; + private IntPtr handle; + private int blocksize; + + public MHashHelper (MHashId type) + { + this.type = type; + handle = MHashWrapper.mhash_init (type); + if (handle == IntPtr.Zero) { + string msg = String.Format ("Unknown mhash id '{0}'.", type); + throw new CryptographicException (msg); + } + + blocksize = (int) MHashWrapper.mhash_get_block_size (type); + } + + ~MHashHelper () + { + Dispose (); + } + + public int BlockSize { + get { return blocksize; } + } + + public IntPtr Handle { + get { return handle; } + } + + public void Initialize () + { + if (handle == IntPtr.Zero) + GC.ReRegisterForFinalize (this); + handle = MHashWrapper.mhash_init (type); + } + + public void HashCore (byte[] data, int start, int length) + { + if (data == null) + throw new ArgumentNullException ("data"); + if (start < 0) + throw new ArgumentException ("start"); + if (length < 0) + throw new ArgumentException ("length"); + + if (length == 0) + return; + + // avoid copying data unless required (API limitation) + if (start == 0) { + MHashWrapper.mhash (handle, data, (IntPtr)length); + } else { + byte[] partial = new byte [length]; + Buffer.BlockCopy (data, start, partial, 0, length); + MHashWrapper.mhash (handle, partial, (IntPtr)length); + } + } + + public byte[] HashFinal () + { + byte[] result = new byte [blocksize]; + IntPtr digest = MHashWrapper.mhash_end (handle); + try { + Marshal.Copy (digest, result, 0, blocksize); + } + finally { + Marshal.FreeHGlobal (digest); + handle = IntPtr.Zero; + } + return result; + } + + public void Dispose () + { + if (handle != IntPtr.Zero) { + // this frees the hashing structure, but allocates the digest + IntPtr digest = MHashWrapper.mhash_end (handle); + // so we still have a second free to make to complete dispose + Marshal.FreeHGlobal (digest); + handle = IntPtr.Zero; + GC.SuppressFinalize (this); + } + } + } +} diff --git a/class/Crimson.MHash/Crimson.MHash/MHashId.cs b/class/Crimson.MHash/Crimson.MHash/MHashId.cs new file mode 100644 index 0000000..9c2c978 --- /dev/null +++ b/class/Crimson.MHash/Crimson.MHash/MHashId.cs @@ -0,0 +1,61 @@ +// +// Crimson.MHash.MHashId enumeation +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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. +// + +namespace Crimson.MHash { + + internal enum MHashId { + Crc32 = 0, + Md5 = 1, + Sha1 = 2, + Haval256 = 3, + Ripemd160 = 5, + Tiger192 = 7, + Gost = 8, + Crc32b = 9, + Haval224 = 10, + Haval192 = 11, + Haval160 = 12, + Haval128 = 13, + Tiger128 = 14, + Tiger160 = 15, + Md4 = 16, + Sha256 = 17, + Adler32 = 18, + Sha224 = 19, + Sha512 = 20, + Sha384 = 21, + Whirlpool = 22, + Ripemd128 = 23, + Ripemd256 = 24, + Ripemd320 = 25, + Snefru128 = 26, + Snefru256 = 27, + Md2 = 28 + // other values are defined but aren't implemented inside libmhash + } +} diff --git a/class/Crimson.MHash/Crimson.MHash/MHashWrapper.cs b/class/Crimson.MHash/Crimson.MHash/MHashWrapper.cs new file mode 100644 index 0000000..026738c --- /dev/null +++ b/class/Crimson.MHash/Crimson.MHash/MHashWrapper.cs @@ -0,0 +1,50 @@ +// +// Crimson.MHash.MHashWrapper wrapper for libmhash +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Runtime.InteropServices; + +namespace Crimson.MHash { + + internal class MHashWrapper { + + private const string libname = "libmhash.so.2"; + + [DllImport (libname)] + internal extern static IntPtr mhash_init (MHashId type); + + [DllImport (libname)] + internal extern static IntPtr mhash_end (IntPtr handle); + + [DllImport (libname)] + internal extern static IntPtr mhash_get_block_size (MHashId type); + + [DllImport (libname)] + internal extern static int mhash (IntPtr handle, byte[] plaintext, IntPtr size); + } +} diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/ADLER32.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/ADLER32.cs new file mode 100644 index 0000000..1837466 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/ADLER32.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class ADLER32 : HashAlgorithm { + + protected ADLER32 () + { + // ADLER32 digest length is 32 bits long + HashSizeValue = 32; + } + + public static new ADLER32 Create () + { + return Create ("ADLER32"); + } + + public static new ADLER32 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any ADLER32 implementation + if (o == null) { + o = new ADLER32Native (); + } + return (ADLER32) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/ADLER32Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/ADLER32Native.cs new file mode 100644 index 0000000..0ab9754 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/ADLER32Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class ADLER32Native : ADLER32 { + + private MHashId Id = MHashId.Adler32; + private MHashHelper hash; + + public ADLER32Native () + { + hash = new MHashHelper (Id); + } + + ~ADLER32Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/CRC32.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/CRC32.cs new file mode 100644 index 0000000..0c08736 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/CRC32.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class CRC32 : HashAlgorithm { + + protected CRC32 () + { + // CRC32 digest length is 32 bits long + HashSizeValue = 32; + } + + public static new CRC32 Create () + { + return Create ("CRC32"); + } + + public static new CRC32 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any CRC32 implementation + if (o == null) { + o = new CRC32Native (); + } + return (CRC32) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/CRC32B.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/CRC32B.cs new file mode 100644 index 0000000..0a92954 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/CRC32B.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class CRC32B : HashAlgorithm { + + protected CRC32B () + { + // CRC32B digest length is 32 bits long + HashSizeValue = 32; + } + + public static new CRC32B Create () + { + return Create ("CRC32B"); + } + + public static new CRC32B Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any CRC32B implementation + if (o == null) { + o = new CRC32BNative (); + } + return (CRC32B) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/CRC32BNative.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/CRC32BNative.cs new file mode 100644 index 0000000..6f1eaed --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/CRC32BNative.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class CRC32BNative : CRC32B { + + private MHashId Id = MHashId.Crc32b; + private MHashHelper hash; + + public CRC32BNative () + { + hash = new MHashHelper (Id); + } + + ~CRC32BNative () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/CRC32Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/CRC32Native.cs new file mode 100644 index 0000000..e6eda23 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/CRC32Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class CRC32Native : CRC32 { + + private MHashId Id = MHashId.Crc32; + private MHashHelper hash; + + public CRC32Native () + { + hash = new MHashHelper (Id); + } + + ~CRC32Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/ChangeLog b/class/Crimson.MHash/Crimson.Security.Cryptography/ChangeLog new file mode 100644 index 0000000..cec1b90 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/ChangeLog @@ -0,0 +1,51 @@ +2006-10-16 Sebastien Pouliot + + * ADLER32.cs: Base class for ADLER32. + * ADLER32Native.cs: Native ADLER32 hash implementation. + * CRC32B.cs: Base class for CRC32B. + * CRC32BNative.cs: Native CRC32B hash implementation. + * CRC32.cs: Base class for CRC32. + * CRC32Native.cs: Native CRC32 hash implementation. + * GOST.cs: Base class for GOST. + * GOSTNative.cs: Native GOST hash implementation. + * HAVAL128.cs: Base class for HAVAL 128. + * HAVAL128Native.cs: Native HAVAL 128 hash implementation. + * HAVAL160.cs: Base class for HAVAL 160. + * HAVAL160Native.cs: Native HAVAL 160 hash implementation. + * HAVAL192.cs: Base class for HAVAL 192. + * HAVAL192Native.cs: Native HAVAL 192 hash implementation. + * HAVAL224.cs: Base class for HAVAL 224. + * HAVAL224Native.cs: Native HAVAL 224 hash implementation. + * HAVAL256.cs: Base class for HAVAL 256. + * HAVAL256Native.cs: Native HAVAL 256 hash implementation. + * MD2.cs: Base class for MD2. + * MD2Native.cs: Native MD2 hash implementation. + * MD4.cs: Base class for MD4. + * MD4Native.cs: Native MD4 hash implementation. + * MD5Native.cs: Native MD5 hash implementation. + * RIPEMD128.cs: Base class for RIPEMD 128. + * RIPEMD128Native.cs: Native RIPEMD 128 hash implementation. + * RIPEMD160.cs: Base class for RIPEMD 160. + * RIPEMD160Native.cs: Native RIPEMD 160 hash implementation. + * RIPEMD256.cs: Base class for RIPEMD 256. + * RIPEMD256Native.cs: Native RIPEMD 256 hash implementation. + * RIPEMD320.cs: Base class for RIPEMD 320. + * RIPEMD320Native.cs: Native RIPEMD 320 hash implementation. + * SHA1Native.cs: Native SHA-1 hash implementation. + * SHA224.cs: Base class for SHA 224. + * SHA224Native.cs: Native SHA 224 hash implementation. + * SHA256Native.cs: Native SHA 256 hash implementation. + * SHA384Native.cs: Native SHA 384 hash implementation. + * SHA512Native.cs: Native SHA 512 hash implementation. + * SNEFRU128.cs: Base class for SNEFRU 128. + * SNEFRU128Native.cs: Native SNEFRU 128 hash implementation. + * SNEFRU256.cs: Base class for SNEFRU 256. + * SNEFRU256Native.cs: Native SNEFRU 256 hash implementation. + * TIGER128.cs: Base class for TIGER 128. + * TIGER128Native.cs: Native TIGER 128 hash implementation. + * TIGER160.cs: Base class for TIGER 160. + * TIGER160Native.cs: Native TIGER 160 hash implementation. + * TIGER192.cs: Base class for TIGER 192. + * TIGER192Native.cs: Native TIGER 192 hash implementation. + * WHIRLPOOL.cs: Base class for WHIRLPOOL. + * WHIRLPOOLNative.cs: Native WHIRLPOOL hash implementation. diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/GOST.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/GOST.cs new file mode 100644 index 0000000..91688a0 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/GOST.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class GOST : HashAlgorithm { + + protected GOST () + { + // GOST digest length is 256 bits long + HashSizeValue = 256; + } + + public static new GOST Create () + { + return Create ("GOST"); + } + + public static new GOST Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any GOST implementation + if (o == null) { + o = new GOSTNative (); + } + return (GOST) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/GOSTNative.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/GOSTNative.cs new file mode 100644 index 0000000..57025aa --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/GOSTNative.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class GOSTNative : GOST { + + private MHashId Id = MHashId.Gost; + private MHashHelper hash; + + public GOSTNative () + { + hash = new MHashHelper (Id); + } + + ~GOSTNative () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL128.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL128.cs new file mode 100644 index 0000000..5c698cb --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL128.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class HAVAL128 : HashAlgorithm { + + protected HAVAL128 () + { + // HAVAL128 digest length is 128 bits long + HashSizeValue = 128; + } + + public static new HAVAL128 Create () + { + return Create ("HAVAL128"); + } + + public static new HAVAL128 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any HAVAL128 implementation + if (o == null) { + o = new HAVAL128Native (); + } + return (HAVAL128) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL128Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL128Native.cs new file mode 100644 index 0000000..9665e75 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL128Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class HAVAL128Native : HAVAL128 { + + private MHashId Id = MHashId.Haval128; + private MHashHelper hash; + + public HAVAL128Native () + { + hash = new MHashHelper (Id); + } + + ~HAVAL128Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL160.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL160.cs new file mode 100644 index 0000000..c644c95 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL160.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class HAVAL160 : HashAlgorithm { + + protected HAVAL160 () + { + // HAVAL160 digest length is 160 bits long + HashSizeValue = 160; + } + + public static new HAVAL160 Create () + { + return Create ("HAVAL160"); + } + + public static new HAVAL160 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any HAVAL160 implementation + if (o == null) { + o = new HAVAL160Native (); + } + return (HAVAL160) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL160Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL160Native.cs new file mode 100644 index 0000000..5a3c6fc --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL160Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class HAVAL160Native : HAVAL160 { + + private MHashId Id = MHashId.Haval160; + private MHashHelper hash; + + public HAVAL160Native () + { + hash = new MHashHelper (Id); + } + + ~HAVAL160Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL192.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL192.cs new file mode 100644 index 0000000..cd7ae82 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL192.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class HAVAL192 : HashAlgorithm { + + protected HAVAL192 () + { + // HAVAL192 digest length is 192 bits long + HashSizeValue = 192; + } + + public static new HAVAL192 Create () + { + return Create ("HAVAL192"); + } + + public static new HAVAL192 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any HAVAL192 implementation + if (o == null) { + o = new HAVAL192Native (); + } + return (HAVAL192) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL192Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL192Native.cs new file mode 100644 index 0000000..47f9382 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL192Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class HAVAL192Native : HAVAL192 { + + private MHashId Id = MHashId.Haval192; + private MHashHelper hash; + + public HAVAL192Native () + { + hash = new MHashHelper (Id); + } + + ~HAVAL192Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL224.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL224.cs new file mode 100644 index 0000000..13c0760 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL224.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class HAVAL224 : HashAlgorithm { + + protected HAVAL224 () + { + // HAVAL224 digest length is 224 bits long + HashSizeValue = 224; + } + + public static new HAVAL224 Create () + { + return Create ("HAVAL224"); + } + + public static new HAVAL224 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any HAVAL224 implementation + if (o == null) { + o = new HAVAL224Native (); + } + return (HAVAL224) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL224Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL224Native.cs new file mode 100644 index 0000000..1a5531b --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL224Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class HAVAL224Native : HAVAL224 { + + private MHashId Id = MHashId.Haval224; + private MHashHelper hash; + + public HAVAL224Native () + { + hash = new MHashHelper (Id); + } + + ~HAVAL224Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL256.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL256.cs new file mode 100644 index 0000000..a012fcf --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL256.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class HAVAL256 : HashAlgorithm { + + protected HAVAL256 () + { + // HAVAL256 digest length is 256 bits long + HashSizeValue = 256; + } + + public static new HAVAL256 Create () + { + return Create ("HAVAL256"); + } + + public static new HAVAL256 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any HAVAL256 implementation + if (o == null) { + o = new HAVAL256Native (); + } + return (HAVAL256) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL256Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL256Native.cs new file mode 100644 index 0000000..68a18ca --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/HAVAL256Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class HAVAL256Native : HAVAL256 { + + private MHashId Id = MHashId.Haval256; + private MHashHelper hash; + + public HAVAL256Native () + { + hash = new MHashHelper (Id); + } + + ~HAVAL256Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/MD2.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/MD2.cs new file mode 100644 index 0000000..1d92f46 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/MD2.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class MD2 : HashAlgorithm { + + protected MD2 () + { + // MD2 digest length is 128 bits long + HashSizeValue = 128; + } + + public static new MD2 Create () + { + return Create ("MD2"); + } + + public static new MD2 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any MD2 implementation + if (o == null) { + o = new MD2Native (); + } + return (MD2) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/MD2Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/MD2Native.cs new file mode 100644 index 0000000..c26ff0b --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/MD2Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class MD2Native : MD2 { + + private MHashId Id = MHashId.Md2; + private MHashHelper hash; + + public MD2Native () + { + hash = new MHashHelper (Id); + } + + ~MD2Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/MD4.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/MD4.cs new file mode 100644 index 0000000..8886131 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/MD4.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class MD4 : HashAlgorithm { + + protected MD4 () + { + // MD4 digest length is 128 bits long + HashSizeValue = 128; + } + + public static new MD4 Create () + { + return Create ("MD4"); + } + + public static new MD4 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any MD4 implementation + if (o == null) { + o = new MD4Native (); + } + return (MD4) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/MD4Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/MD4Native.cs new file mode 100644 index 0000000..e198921 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/MD4Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class MD4Native : MD4 { + + private MHashId Id = MHashId.Md4; + private MHashHelper hash; + + public MD4Native () + { + hash = new MHashHelper (Id); + } + + ~MD4Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/MD5Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/MD5Native.cs new file mode 100644 index 0000000..7083c8f --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/MD5Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class MD5Native : MD5 { + + private MHashId Id = MHashId.Md5; + private MHashHelper hash; + + public MD5Native () + { + hash = new MHashHelper (Id); + } + + ~MD5Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD128.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD128.cs new file mode 100644 index 0000000..e61b990 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD128.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class RIPEMD128 : HashAlgorithm { + + protected RIPEMD128 () + { + // RIPEMD128 digest length is 128 bits long + HashSizeValue = 128; + } + + public static new RIPEMD128 Create () + { + return Create ("RIPEMD128"); + } + + public static new RIPEMD128 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any RIPEMD128 implementation + if (o == null) { + o = new RIPEMD128Native (); + } + return (RIPEMD128) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD128Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD128Native.cs new file mode 100644 index 0000000..eb4dd47 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD128Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class RIPEMD128Native : RIPEMD128 { + + private MHashId Id = MHashId.Ripemd128; + private MHashHelper hash; + + public RIPEMD128Native () + { + hash = new MHashHelper (Id); + } + + ~RIPEMD128Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD160.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD160.cs new file mode 100644 index 0000000..4d85885 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD160.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class RIPEMD160 : HashAlgorithm { + + protected RIPEMD160 () + { + // RIPEMD160 digest length is 160 bits long + HashSizeValue = 160; + } + + public static new RIPEMD160 Create () + { + return Create ("RIPEMD160"); + } + + public static new RIPEMD160 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any RIPEMD160 implementation + if (o == null) { + o = new RIPEMD160Native (); + } + return (RIPEMD160) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD160Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD160Native.cs new file mode 100644 index 0000000..4cff524 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD160Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class RIPEMD160Native : RIPEMD160 { + + private MHashId Id = MHashId.Ripemd160; + private MHashHelper hash; + + public RIPEMD160Native () + { + hash = new MHashHelper (Id); + } + + ~RIPEMD160Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD256.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD256.cs new file mode 100644 index 0000000..d11942b --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD256.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class RIPEMD256 : HashAlgorithm { + + protected RIPEMD256 () + { + // RIPEMD256 digest length is 256 bits long + HashSizeValue = 256; + } + + public static new RIPEMD256 Create () + { + return Create ("RIPEMD256"); + } + + public static new RIPEMD256 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any RIPEMD256 implementation + if (o == null) { + o = new RIPEMD256Native (); + } + return (RIPEMD256) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD256Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD256Native.cs new file mode 100644 index 0000000..04cae49 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD256Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class RIPEMD256Native : RIPEMD256 { + + private MHashId Id = MHashId.Ripemd256; + private MHashHelper hash; + + public RIPEMD256Native () + { + hash = new MHashHelper (Id); + } + + ~RIPEMD256Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD320.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD320.cs new file mode 100644 index 0000000..9225be3 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD320.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class RIPEMD320 : HashAlgorithm { + + protected RIPEMD320 () + { + // RIPEMD320 digest length is 320 bits long + HashSizeValue = 320; + } + + public static new RIPEMD320 Create () + { + return Create ("RIPEMD320"); + } + + public static new RIPEMD320 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any RIPEMD320 implementation + if (o == null) { + o = new RIPEMD320Native (); + } + return (RIPEMD320) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD320Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD320Native.cs new file mode 100644 index 0000000..6193f83 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/RIPEMD320Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class RIPEMD320Native : RIPEMD320 { + + private MHashId Id = MHashId.Ripemd320; + private MHashHelper hash; + + public RIPEMD320Native () + { + hash = new MHashHelper (Id); + } + + ~RIPEMD320Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/SHA1Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/SHA1Native.cs new file mode 100644 index 0000000..269cf52 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/SHA1Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class SHA1Native : SHA1 { + + private MHashId Id = MHashId.Sha1; + private MHashHelper hash; + + public SHA1Native () + { + hash = new MHashHelper (Id); + } + + ~SHA1Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/SHA224.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/SHA224.cs new file mode 100644 index 0000000..02d58ec --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/SHA224.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class SHA224 : HashAlgorithm { + + protected SHA224 () + { + // SHA224 digest length is 224 bits long + HashSizeValue = 224; + } + + public static new SHA224 Create () + { + return Create ("SHA224"); + } + + public static new SHA224 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any SHA224 implementation + if (o == null) { + o = new SHA224Native (); + } + return (SHA224) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/SHA224Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/SHA224Native.cs new file mode 100644 index 0000000..65e676b --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/SHA224Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class SHA224Native : SHA224 { + + private MHashId Id = MHashId.Sha224; + private MHashHelper hash; + + public SHA224Native () + { + hash = new MHashHelper (Id); + } + + ~SHA224Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/SHA256Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/SHA256Native.cs new file mode 100644 index 0000000..989872a --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/SHA256Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class SHA256Native : SHA256 { + + private MHashId Id = MHashId.Sha256; + private MHashHelper hash; + + public SHA256Native () + { + hash = new MHashHelper (Id); + } + + ~SHA256Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/SHA384Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/SHA384Native.cs new file mode 100644 index 0000000..903548f --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/SHA384Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class SHA384Native : SHA384 { + + private MHashId Id = MHashId.Sha384; + private MHashHelper hash; + + public SHA384Native () + { + hash = new MHashHelper (Id); + } + + ~SHA384Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/SHA512Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/SHA512Native.cs new file mode 100644 index 0000000..de62614 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/SHA512Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class SHA512Native : SHA512 { + + private MHashId Id = MHashId.Sha512; + private MHashHelper hash; + + public SHA512Native () + { + hash = new MHashHelper (Id); + } + + ~SHA512Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/SNEFRU128.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/SNEFRU128.cs new file mode 100644 index 0000000..fa2900c --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/SNEFRU128.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class SNEFRU128 : HashAlgorithm { + + protected SNEFRU128 () + { + // SNEFRU128 digest length is 128 bits long + HashSizeValue = 128; + } + + public static new SNEFRU128 Create () + { + return Create ("SNEFRU128"); + } + + public static new SNEFRU128 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any SNEFRU128 implementation + if (o == null) { + o = new SNEFRU128Native (); + } + return (SNEFRU128) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/SNEFRU128Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/SNEFRU128Native.cs new file mode 100644 index 0000000..a89df5c --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/SNEFRU128Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class SNEFRU128Native : SNEFRU128 { + + private MHashId Id = MHashId.Snefru128; + private MHashHelper hash; + + public SNEFRU128Native () + { + hash = new MHashHelper (Id); + } + + ~SNEFRU128Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/SNEFRU256.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/SNEFRU256.cs new file mode 100644 index 0000000..0dbdd4b --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/SNEFRU256.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class SNEFRU256 : HashAlgorithm { + + protected SNEFRU256 () + { + // SNEFRU256 digest length is 256 bits long + HashSizeValue = 256; + } + + public static new SNEFRU256 Create () + { + return Create ("SNEFRU256"); + } + + public static new SNEFRU256 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any SNEFRU256 implementation + if (o == null) { + o = new SNEFRU256Native (); + } + return (SNEFRU256) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/SNEFRU256Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/SNEFRU256Native.cs new file mode 100644 index 0000000..4a94354 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/SNEFRU256Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class SNEFRU256Native : SNEFRU256 { + + private MHashId Id = MHashId.Snefru256; + private MHashHelper hash; + + public SNEFRU256Native () + { + hash = new MHashHelper (Id); + } + + ~SNEFRU256Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER128.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER128.cs new file mode 100644 index 0000000..387546e --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER128.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class TIGER128 : HashAlgorithm { + + protected TIGER128 () + { + // TIGER128 digest length is 128 bits long + HashSizeValue = 128; + } + + public static new TIGER128 Create () + { + return Create ("TIGER128"); + } + + public static new TIGER128 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any TIGER128 implementation + if (o == null) { + o = new TIGER128Native (); + } + return (TIGER128) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER128Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER128Native.cs new file mode 100644 index 0000000..e5d4203 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER128Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class TIGER128Native : TIGER128 { + + private MHashId Id = MHashId.Tiger128; + private MHashHelper hash; + + public TIGER128Native () + { + hash = new MHashHelper (Id); + } + + ~TIGER128Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER160.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER160.cs new file mode 100644 index 0000000..5cc6b9c --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER160.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class TIGER160 : HashAlgorithm { + + protected TIGER160 () + { + // TIGER160 digest length is 160 bits long + HashSizeValue = 160; + } + + public static new TIGER160 Create () + { + return Create ("TIGER160"); + } + + public static new TIGER160 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any TIGER160 implementation + if (o == null) { + o = new TIGER160Native (); + } + return (TIGER160) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER160Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER160Native.cs new file mode 100644 index 0000000..21fc668 --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER160Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class TIGER160Native : TIGER160 { + + private MHashId Id = MHashId.Tiger160; + private MHashHelper hash; + + public TIGER160Native () + { + hash = new MHashHelper (Id); + } + + ~TIGER160Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER192.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER192.cs new file mode 100644 index 0000000..9ad5dbd --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER192.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class TIGER192 : HashAlgorithm { + + protected TIGER192 () + { + // TIGER192 digest length is 192 bits long + HashSizeValue = 192; + } + + public static new TIGER192 Create () + { + return Create ("TIGER192"); + } + + public static new TIGER192 Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any TIGER192 implementation + if (o == null) { + o = new TIGER192Native (); + } + return (TIGER192) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER192Native.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER192Native.cs new file mode 100644 index 0000000..b8e07ef --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/TIGER192Native.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class TIGER192Native : TIGER192 { + + private MHashId Id = MHashId.Tiger192; + private MHashHelper hash; + + public TIGER192Native () + { + hash = new MHashHelper (Id); + } + + ~TIGER192Native () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/WHIRLPOOL.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/WHIRLPOOL.cs new file mode 100644 index 0000000..6901c6a --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/WHIRLPOOL.cs @@ -0,0 +1,57 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +namespace Crimson.Security.Cryptography { + + public abstract class WHIRLPOOL : HashAlgorithm { + + protected WHIRLPOOL () + { + // WHIRLPOOL digest length is 512 bits long + HashSizeValue = 512; + } + + public static new WHIRLPOOL Create () + { + return Create ("WHIRLPOOL"); + } + + public static new WHIRLPOOL Create (string hashName) + { + object o = CryptoConfig.CreateFromName (hashName); + // in case machine.config isn't configured to use any WHIRLPOOL implementation + if (o == null) { + o = new WHIRLPOOLNative (); + } + return (WHIRLPOOL) o; + } + } +}/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/Crimson.Security.Cryptography/WHIRLPOOLNative.cs b/class/Crimson.MHash/Crimson.Security.Cryptography/WHIRLPOOLNative.cs new file mode 100644 index 0000000..97daa9a --- /dev/null +++ b/class/Crimson.MHash/Crimson.Security.Cryptography/WHIRLPOOLNative.cs @@ -0,0 +1,84 @@ +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { + + public class WHIRLPOOLNative : WHIRLPOOL { + + private MHashId Id = MHashId.Whirlpool; + private MHashHelper hash; + + public WHIRLPOOLNative () + { + hash = new MHashHelper (Id); + } + + ~WHIRLPOOLNative () + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ diff --git a/class/Crimson.MHash/LICENSE.LGPL b/class/Crimson.MHash/LICENSE.LGPL new file mode 100644 index 0000000..341b7f9 --- /dev/null +++ b/class/Crimson.MHash/LICENSE.LGPL @@ -0,0 +1,15 @@ + Copyright (C) 2006 Novell, Inc. and all authors listed in individual + ChangeLog entries. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. diff --git a/class/Crimson.MHash/MIT.X11 b/class/Crimson.MHash/MIT.X11 new file mode 100644 index 0000000..a865c97 --- /dev/null +++ b/class/Crimson.MHash/MIT.X11 @@ -0,0 +1,21 @@ +Copyright (C) 2006 Novell, Inc. and all authors listed in individual +ChangeLog entries. + +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. diff --git a/class/Crimson.MHash/Makefile b/class/Crimson.MHash/Makefile new file mode 100644 index 0000000..1bb3c88 --- /dev/null +++ b/class/Crimson.MHash/Makefile @@ -0,0 +1,19 @@ +ifndef PROFILE +PROFILE=net_1_1 +endif + +ifeq ($(PROFILE),net_2_0) +MCS=gmcs /d:NET_2_0,NET_1_1 +else +MCS=mcs /d:NET_1_1 +endif + +all: + $(MCS) -debug -target:library -out:../lib/$(PROFILE)/Crimson.MHash.dll @Crimson.MHash.dll.sources + +install: + gacutil -i ../lib/$(PROFILE)/Crimson.MHash.dll + +clean: + rm *.dll + rm *.mdb diff --git a/class/Crimson.MHash/README b/class/Crimson.MHash/README new file mode 100644 index 0000000..9472505 --- /dev/null +++ b/class/Crimson.MHash/README @@ -0,0 +1,28 @@ +Crimson.MHash.dll + + +* How to use + +In most cases you shouldn't reference this assembly directly. E.g. it is not +required if you want performance benefits of using the native implementation +of the common hash algorithms. The .NET framework has a plug-able design that +allow re-mapping the implementations at runtime (using machine.config). + +However if you want to access the less common hash algorithms you'll need to +reference Crimson.MHash.dll directly in your projects (or copy the required +source files in your project). + + +* License + +The C# files are all MIT X.11 licensed. However MHash itself is LGPL, so the +end result is LGPL. The C# files are MIT X.11 licensed so they can be easily +reused to wrap other native cryptographic libraries (without making the new +project LGPL). + + +* Notes + +The generated files are kept in SVN to allow anyone to build this assembly +even if the libmhash library isn't present on their system. However executing +or testing the assembly won't work unless the library is present. diff --git a/class/Crimson.MHash/tools/generator/ChangeLog b/class/Crimson.MHash/tools/generator/ChangeLog new file mode 100644 index 0000000..28a03eb --- /dev/null +++ b/class/Crimson.MHash/tools/generator/ChangeLog @@ -0,0 +1,5 @@ +2006-10-16 Sebastien Pouliot + + * ChangeLog: New. Track changes. + * generator.cs: New. Generate wrapper source files. + * Makefile: build generator.exe and source files. diff --git a/class/Crimson.MHash/tools/generator/Makefile b/class/Crimson.MHash/tools/generator/Makefile new file mode 100644 index 0000000..6bcc3fe --- /dev/null +++ b/class/Crimson.MHash/tools/generator/Makefile @@ -0,0 +1,9 @@ +all: generator.cs + mcs -debug generator.cs ../../Crimson.MHash/MHashId.cs ../../Crimson.MHash/MHashWrapper.cs + +update: all + mono --debug generator.exe ../../Crimson.Security.Cryptography + +clean: + rm *.exe + rm *.mdb diff --git a/class/Crimson.MHash/tools/generator/generator.cs b/class/Crimson.MHash/tools/generator/generator.cs new file mode 100644 index 0000000..9e3f343 --- /dev/null +++ b/class/Crimson.MHash/tools/generator/generator.cs @@ -0,0 +1,232 @@ +// +// generator.cs: Libmhash wrapper generator +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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 System.Text; + +using Crimson.MHash; + +public class Generator { + + static string header = @"/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ + +// +// Authors: +// Sebastien Pouliot +// +// Copyright (C) 2006 Novell, Inc (http://www.novell.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. +// +"; + + static string mhash_start = @" +using System; +using System.Security.Cryptography; + +using Crimson.MHash; + +namespace Crimson.Security.Cryptography { +"; + + static string mhash_ctor = @" + { + hash = new MHashHelper (Id); + } + +"; + + static string mhash_end = @" + { + Dispose (); + } + + public void Dispose () + { + if (hash.Handle != IntPtr.Zero) { + hash.Dispose (); + GC.SuppressFinalize (this); + } + } + + public override void Initialize () + { + if (hash.Handle == IntPtr.Zero) { + GC.ReRegisterForFinalize (this); + hash.Initialize (); + } + } + + protected override void HashCore (byte[] data, int start, int length) + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + hash.HashCore (data, start, length); + } + + protected override byte[] HashFinal () + { + if (hash.Handle == IntPtr.Zero) + Initialize (); + + return hash.HashFinal (); + } + } +} +"; + + static string footer = @" + +/* DO NOT EDIT *** This file was generated automatically *** DO NOT EDIT */ +"; + + static string mhash_base_start = @" +using System; +using System.Security.Cryptography; + +namespace Crimson.Security.Cryptography { +"; + + static void WriteToFile (string filename, string content) + { + using (StreamWriter sw = new StreamWriter (filename)) { + sw.Write (content); + } + } + + static private void GenerateMHashAbstractClass (string dir, MHashId id, double fx) + { + string algo = id.ToString ().ToUpper (); + int size = ((int) MHashWrapper.mhash_get_block_size (id) << 3); // bytes to bits + + StringBuilder sb = new StringBuilder (header); + sb.Append (mhash_base_start); + sb.AppendFormat ("{0}\tpublic abstract class {1} : HashAlgorithm {{{0}", Environment.NewLine, algo); + sb.AppendFormat ("{0}\t\tprotected {1} (){0}\t\t{{", Environment.NewLine, algo); + sb.AppendFormat ("{0}\t\t\t// {1} digest length is {2} bits long", Environment.NewLine, algo, size); + sb.AppendFormat ("{0}\t\t\tHashSizeValue = {1};{0}\t\t}}{0}", Environment.NewLine, size); + sb.AppendFormat ("{0}\t\tpublic static new {1} Create (){0}\t\t{{", Environment.NewLine, algo); + sb.AppendFormat ("{0}\t\t\treturn Create (\"{1}\");{0}\t\t}}{0}", Environment.NewLine, algo); + sb.AppendFormat ("{0}\t\tpublic static new {1} Create (string hashName){0}\t\t{{{0}", Environment.NewLine, algo); + sb.Append ("\t\t\tobject o = CryptoConfig.CreateFromName (hashName);"); + sb.AppendFormat ("{0}\t\t\t// in case machine.config isn't configured to use any {1} implementation", Environment.NewLine, algo); + sb.AppendFormat ("{0}\t\t\tif (o == null) {{{0}\t\t\t\to = new {1}Native ();{0}\t\t\t}}", Environment.NewLine, algo); + sb.AppendFormat ("{0}\t\t\treturn ({1}) o;{0}\t\t}}{0}\t}}{0}}}", Environment.NewLine, algo); + sb.Append (footer); + + string filename = Path.Combine (dir, algo + ".cs"); + WriteToFile (filename, sb.ToString ()); + } + + static private void GenerateMHashClass (string dir, MHashId id, double fx) + { + string algo = id.ToString ().ToUpper (); + string classname = String.Format ("{0}Native", algo); + string baseclass = " : " + algo; + + StringBuilder sb = new StringBuilder (header); + sb.Append (mhash_start); +// if (fx < 2.0){ + sb.AppendFormat ("{0}\tpublic class {1}{2} {{{0}", Environment.NewLine, classname, baseclass); +// } else { +// sb.AppendFormat ("{0}#if NET_2_0{0}\tpublic class {1}{2} {{{0}#else{0}\tpublic class {1}{2 : HashAlgorithm {{{0}#endif{0}", +// Environment.NewLine, classname, baseclass); +// } + sb.AppendFormat ("{0}\t\tprivate MHashId Id = MHashId.{1};{0}", Environment.NewLine, id); + sb.Append ("\t\tprivate MHashHelper hash;"); + sb.AppendFormat ("{0}{0}\t\tpublic {1} ()", Environment.NewLine, classname); + sb.Append (mhash_ctor); + sb.AppendFormat ("\t\t~{0} ()", classname); + sb.Append (mhash_end); + sb.Append (footer); + + string filename = Path.Combine (dir, classname + ".cs"); + WriteToFile (filename, sb.ToString ()); + } + + static private void GenerateMHash (string dir, MHashId id) + { + string algo = id.ToString ().ToUpper (); + double fx = 1.0; + + switch (algo) { + case "SHA1": + case "MD5": + case "SHA256": + case "SHA384": + case "SHA512": + // base class already defined in Fx 1.0 + break; + case "RIPEMD160": + // base class already defined, but only in Fx 2.0 + GenerateMHashAbstractClass (dir, id, 2.0); + break; + default: + // we need to generate our own base class + GenerateMHashAbstractClass (dir, id, 1.0); + break; + } + + GenerateMHashClass (dir, id, fx); + } + + static void MHash (string dir) + { + Console.WriteLine ("Generating HashAlgorithm for MHash inside directory {0}", dir); + foreach (MHashId id in Enum.GetValues (typeof (MHashId))) { + Console.WriteLine ("\t{0}", id); + GenerateMHash (dir, id); + } + } + + + static void Main (string[] args) + { + string dir = args.Length == 0 ? "." : args [0]; + MHash (dir); + } +} diff --git a/class/Crimson.MHash/tools/perf/ChangeLog b/class/Crimson.MHash/tools/perf/ChangeLog new file mode 100644 index 0000000..7d92695 --- /dev/null +++ b/class/Crimson.MHash/tools/perf/ChangeLog @@ -0,0 +1,4 @@ +2006-10-16 Sebastien Pouliot + + * ChangeLog: New. Track changes. + * README: Benchmark instructions. diff --git a/class/Crimson.MHash/tools/perf/Makefile b/class/Crimson.MHash/tools/perf/Makefile new file mode 100644 index 0000000..41e66c7 --- /dev/null +++ b/class/Crimson.MHash/tools/perf/Makefile @@ -0,0 +1,41 @@ +ifndef PROFILE +PROFILE=net_1_1 +endif + +ifeq ($(PROFILE),net_2_0) +MCS=gmcs /d:NET_2_0,NET_1_1 +else +MCS=mcs /d:NET_1_1 +endif + +all: managed native bf + +managed: managed.cs + $(MCS) managed.cs -r:Mono.Security.dll + +native: native.cs + cp ../../../lib/$(PROFILE)/Crimson.MHash.dll . + $(MCS) native.cs -r:Crimson.MHash.dll + +bf: bf.cs + $(MCS) bf.cs + +bigfile: bf + mono bf.exe bigfile 250000000 + +md5: bigfile + time md5sum bigfile + time mono managed.exe MD5 bigfile + time mono native.exe MD5 bigfile + +sha1: bigfile + time sha1sum bigfile + time mono managed.exe SHA1 bigfile + time mono native.exe SHA1 bigfile + +benchmark: md5 sha1 + +clean: + rm -f bigfile + rm -f *.exe + rm -f *.dll diff --git a/class/Crimson.MHash/tools/perf/README b/class/Crimson.MHash/tools/perf/README new file mode 100644 index 0000000..e67793f --- /dev/null +++ b/class/Crimson.MHash/tools/perf/README @@ -0,0 +1,17 @@ +Mono has managed implementation of the following hash algorithms: + +* mscorlib.dll: MD5, SHA1, SHA256, SHA384, SHA512 and, only in 2.0, RIPEMD160 +* Mono.Security.dll: SHA224, MD2 and MD4 + +Most UNIX system also have a md5sum and sha1sum that can be used to compare +performance. + +HOWTO + + make + mono bf.exe bigfile 1000000 + time md5sum bigfile + time mono managed.exe MD5 bigfile + time mono native.exe MD5 bigfile + +Change size (x10) and retry. diff --git a/class/Crimson.MHash/tools/perf/bf.cs b/class/Crimson.MHash/tools/perf/bf.cs new file mode 100644 index 0000000..bbb794a --- /dev/null +++ b/class/Crimson.MHash/tools/perf/bf.cs @@ -0,0 +1,21 @@ +using System; +using System.IO; + +class Program { + + static void Main (string[] args) + { + string filename = (args.Length == 0) ? "bigfile" : args [0]; + long size = (args.Length < 2) ? 10000000 : Int64.Parse (args [1]); + using (FileStream fs = File.OpenWrite (filename)) { + byte[] k = new byte [1024]; + while (size >= 1024) { + fs.Write (k, 0, 1024); + size -= 1024; + } + if (size > 0) + fs.Write (k, 0, (int)size); + fs.Close (); + } + } +} diff --git a/class/Crimson.MHash/tools/perf/managed.cs b/class/Crimson.MHash/tools/perf/managed.cs new file mode 100644 index 0000000..f122f71 --- /dev/null +++ b/class/Crimson.MHash/tools/perf/managed.cs @@ -0,0 +1,29 @@ +using System; +using System.IO; +using System.Security.Cryptography; +//using Mono.Security.Cryptography; + +class Program { + + // we avoid using CryptoConfig (via SHA1.Create) to get "true" results + static HashAlgorithm CreateFromName (string name) + { + switch (name) { + case "MD5": + return new MD5CryptoServiceProvider (); + case "SHA1": + return new SHA1CryptoServiceProvider (); + default: + throw new NotSupportedException (String.Format ("Unknown hash algorithm '{0}'.", name)); + } + } + + static void Main (string[] args) + { + using (HashAlgorithm digest = CreateFromName (args [0])) { + using (FileStream fs = File.OpenRead (args[1])){ + Console.WriteLine (BitConverter.ToString (digest.ComputeHash (fs))); + } + } + } +} diff --git a/class/Crimson.MHash/tools/perf/native.cs b/class/Crimson.MHash/tools/perf/native.cs new file mode 100644 index 0000000..280af17 --- /dev/null +++ b/class/Crimson.MHash/tools/perf/native.cs @@ -0,0 +1,81 @@ +using System; +using System.IO; +using System.Security.Cryptography; +using Crimson.Security.Cryptography; + +class Program { + + // we avoid using CryptoConfig (via SHA1.Create) to get "true" results + static HashAlgorithm CreateFromName (string name) + { + switch (name.ToUpper ()) { + + case "ADLER32": + return new ADLER32Native (); + case "CRC32B": + return new CRC32BNative (); + case "CRC32": + return new CRC32Native (); + case "GOST": + return new GOSTNative (); + case "HAVAL128": + return new HAVAL128Native (); + case "HAVAL160": + return new HAVAL160Native (); + case "HAVAL192": + return new HAVAL192Native (); + case "HAVAL224": + return new HAVAL224Native (); + case "HAVAL256": + return new HAVAL256Native (); + case "MD2": + return new MD2Native (); + case "MD4": + return new MD4Native (); + case "MD5": + return new MD5Native (); + case "RIPEMD128": + return new RIPEMD128Native (); + case "RIPEMD160": + return new RIPEMD160Native (); + case "RIPEMD256": + return new RIPEMD256Native (); + case "RIPEMD320": + return new RIPEMD320Native (); + case "SHA1": + return new SHA1Native (); + case "SHA224": + return new SHA224Native (); + case "SHA256": + return new SHA256Native (); + case "SHA384": + return new SHA384Native (); + case "SHA512": + return new SHA512Native (); + case "SNEFRU128": + return new SNEFRU128Native (); + case "SNEFRU256.cs": + return new SNEFRU256Native (); + case "TIGER128": + return new TIGER128Native (); + case "TIGER160": + return new TIGER160Native (); + case "TIGER192": + return new TIGER192Native (); + case "WHIRLPOOL": + return new WHIRLPOOLNative (); + + default: + throw new NotSupportedException (String.Format ("Unknown hash algorithm '{0}'.", name)); + } + } + + static void Main (string[] args) + { + using (HashAlgorithm digest = CreateFromName (args [0])) { + using (FileStream fs = File.OpenRead (args[1])){ + Console.WriteLine (BitConverter.ToString (digest.ComputeHash (fs))); + } + } + } +} diff --git a/class/README b/class/README new file mode 100644 index 0000000..8b735ff --- /dev/null +++ b/class/README @@ -0,0 +1,18 @@ +The following assemblies are available in Crimson: + +* Crimson.MHash.dll + + This assembly provides wrapper around the native hash implementations + around libmhash (http://mhash.sourceforge.net/). It serve two main + purposes: + + * it provides native (and potentially faster) implementation of common + hash algorithms (e.g. MD5, SHA1, SHA-256/384/512) already part of the + .NET framework; + + * it provides implementation for many, less know (e.g. TIGER, SNEFRU) + or non-cryptographic (e.g. CRC32), hash algorithms. + + +The Crimson module is open to new wrappers around existing cryptographic +libraries as well as new crypto-related ideas. diff --git a/class/crimson.snk b/class/crimson.snk new file mode 100644 index 0000000..21cfc96 Binary files /dev/null and b/class/crimson.snk differ diff --git a/common/ChangeLog b/common/ChangeLog new file mode 100644 index 0000000..e5923c8 --- /dev/null +++ b/common/ChangeLog @@ -0,0 +1,4 @@ +2006-10-16 Sebastien Pouliot + + * Locale.cs: New. Include a copy of Mono's Locale.cs so we can + reuse Mono localization stuff when ready. diff --git a/common/Locale.cs b/common/Locale.cs new file mode 100644 index 0000000..7293ab2 --- /dev/null +++ b/common/Locale.cs @@ -0,0 +1,51 @@ +// +// Locale.cs +// +// Author: +// Miguel de Icaza (miguel@ximian.com) +// Andreas Nahr (ClassDevelopment@A-SoftTech.com) +// +// (C) 2001 - 2003 Ximian, Inc (http://www.ximian.com) +// + +// +// Copyright (C) 2004 Novell, Inc (http://www.novell.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; + +internal sealed class Locale { + + private Locale () + { + } + + public static string GetText (string msg) + { + return msg; + } + + public static string GetText (string fmt, params object [] args) + { + return String.Format (fmt, args); + } +}