CSharpTest.Net
WhirlpoolManaged Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Crypto Namespace : WhirlpoolManaged Class

Glossary Item Box

The Whirlpool hashing function. References The Whirlpool algorithm was developed by Paulo S. L. M. Barreto and Vincent Rijmen. See P.S.L.M. Barreto, V. Rijmen, ``The Whirlpool hashing function,'' NESSIE submission, 2000 (tweaked version, 2001), https://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/whirlpool.zip @author Paulo S.L.M. Barreto @author Vincent Rijmen. ============================================================================= .Net Coversion on May 2010 by Roger O Knapp http://csharptest.net Performance considerations: coult be improved by moving to unmanaged/unsafe implementations, currently SHA512 is about 10% faster. The code remains, as much as was possible, exactly as it appears in the example 'c' implementation available from the documentation package on http://www.larc.usp.br/~pbarreto/WhirlpoolPage.html ============================================================================= @version 3.0 (2003.03.12) ============================================================================= Differences from version 2.1: - Suboptimal diffusion matrix replaced by cir(1, 1, 4, 1, 8, 5, 2, 9). ============================================================================= Differences from version 2.0: - Generation of ISO/IEC 10118-3 test vectors. - Bug fix: nonzero carry was ignored when tallying the data length (this bug apparently only manifested itself when feeding data in pieces rather than in a single chunk at once). - Support for MS Visual C++ 64-bit integer arithmetic. Differences from version 1.0: - Original S-box replaced by the tweaked, hardware-efficient version. ============================================================================= THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Syntax

Visual Basic (Declaration) 
Public Class WhirlpoolManaged 
   Inherits System.Security.Cryptography.HashAlgorithm
C# 
public class WhirlpoolManaged : System.Security.Cryptography.HashAlgorithm 

Example

Library/Library.Test/TestWhirlpoolHash.cs

C#Copy Code
byte[] speedInput = System.Text.Encoding.ASCII.GetBytes("12345678901234567890123456789012345678901234567890123456789012345678901234567890");

Stopwatch sw;

HashAlgorithm sha512 = SHA512.Create();
WhirlpoolManaged alg = new WhirlpoolManaged();

for (int rep = 3; rep > 0; rep--)
{
    sw = new Stopwatch();
    sw.Start();
    for (int i = 0; i < 100000; i++)
        sha512.ComputeHash(speedInput);
    sw.Stop();
    Console.WriteLine("100000 SHA512 in     {0}", sw.Elapsed);

    sw = new Stopwatch();
    sw.Start();
    for (int i = 0; i < 100000; i++)
        alg.ComputeHash(speedInput);
    sw.Stop();
    Console.WriteLine("100000 WhirlpoolT in {0}", sw.Elapsed);
}
VB.NETCopy Code
Dim speedInput As Byte() = System.Text.Encoding.ASCII.GetBytes("12345678901234567890123456789012345678901234567890123456789012345678901234567890")

Dim sw As Stopwatch

Dim sha512 As HashAlgorithm = SHA512.Create()
Dim alg As New WhirlpoolManaged()

Dim rep As Integer = 3
While rep > 0
    sw = New Stopwatch()
    sw.Start()
    Dim i As Integer = 0
    While i < 100000
        sha512.ComputeHash(speedInput)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    sw.[Stop]()
    Console.WriteLine("100000 SHA512 in     {0}", sw.Elapsed)

    sw = New Stopwatch()
    sw.Start()
    Dim i As Integer = 0
    While i < 100000
        alg.ComputeHash(speedInput)
        System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
    End While
    sw.[Stop]()
    Console.WriteLine("100000 WhirlpoolT in {0}", sw.Elapsed)
    System.Math.Max(System.Threading.Interlocked.Decrement(rep),rep + 1)
End While

Inheritance Hierarchy

System.Object
   System.Security.Cryptography.HashAlgorithm
      CSharpTest.Net.Crypto.WhirlpoolManaged

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys