diff dcrypt/crypto/hashes/SHA224.d @ 27:8b5eaf3c2979

Fixed error in hash message padding reported by Glenn Haecker.
author Thomas Dixon <reikon@reikon.us>
date Sat, 09 May 2009 23:29:20 -0400
parents 176c933827a8
children ad687db713a4
line wrap: on
line diff
--- a/dcrypt/crypto/hashes/SHA224.d	Sun Mar 01 13:06:48 2009 -0500
+++ b/dcrypt/crypto/hashes/SHA224.d	Sat May 09 23:29:20 2009 -0400
@@ -16,21 +16,26 @@
  * Conforms: FIPS-180-2
  * References: http://csrc.nist.gov/publications/fips/fips180-2/FIPS180-2_changenotice.pdf
  */
-class SHA224 : SHA256 {
-    this (void[] input_=null) {
+class SHA224 : SHA256
+{
+    this (void[] input_=null)
+    {
         reset();
         super(input_);
     }
     
-    uint digestSize() {
+    uint digestSize()
+    {
         return 28;
     }
     
-    char[] name() {
+    char[] name()
+    {
         return "SHA224";
     }
     
-    ubyte[] digest() {
+    ubyte[] digest()
+    {
     	padMessage(MODE_SHA);
 
         ubyte[] result = new ubyte[digestSize];
@@ -47,7 +52,8 @@
         return result;
     }
 
-    void reset() {
+    void reset()
+    {
         super.reset();
         h0 = 0xc1059ed8u;
         h1 = 0x367cd507u;
@@ -59,7 +65,8 @@
         h7 = 0xbefa4fa4u;
     }
     
-    SHA224 copy() {
+    SHA224 copy()
+    {
         SHA224 h = new SHA224(buffer[0..index]);
         h.bytes = bytes;
         h.h0 = h0;
@@ -73,8 +80,10 @@
         return h;
     }
     
-    debug (UnitTest) {
-        unittest {
+    debug (UnitTest)
+    {
+        unittest
+        {
             static const char[][] test_inputs = [
                 "",
                 "abc",
@@ -94,7 +103,8 @@
             ];
             
             SHA224 h = new SHA224();
-            foreach (uint i, char[] input; test_inputs) {
+            foreach (uint i, char[] input; test_inputs)
+            {
                 for (int j = 0; j < test_repeat[i]; j++)
                     h.update(input);
                 char[] digest = h.hexDigest();