~ubuntu-branches/ubuntu/precise/nordugrid-arc/precise

« back to all changes in this revision

Viewing changes to debian/patches/nordugrid-arc-md5.patch

  • Committer: Package Import Robot
  • Author(s): Mattias Ellert
  • Date: 2012-03-01 19:48:16 UTC
  • mfrom: (3.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20120301194816-m1ezrwnwt2qgnc2e
Tags: 1.1.1-1
* 1.1.1 Bugfix Release
* Fixes FTBFS (Closes: #661774) (LP: #935007)
* Fix typo in package description (Closes: #646979)
* Split binary rule in debian/rules for arch and indep

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Index: trunk/src/hed/libs/common/CheckSum.cpp
2
 
===================================================================
3
 
--- trunk/src/hed/libs/common/CheckSum.cpp      (revision 22836)
4
 
+++ trunk/src/hed/libs/common/CheckSum.cpp      (revision 23053)
5
 
@@ -170,5 +170,5 @@
6
 
 
7
 
   // ----------------------------------------------------------------------------
8
 
-  // This is MD5 implementation for LOW-ENDIAN machines derived directly from RFC
9
 
+  // This is MD5 implementation derived directly from RFC
10
 
   // ----------------------------------------------------------------------------
11
 
 
12
 
@@ -235,4 +235,5 @@
13
 
     count = 0;
14
 
     Xlen = 0;
15
 
+    memset(X,0,sizeof(X));
16
 
     computed = false;
17
 
   }
18
 
@@ -241,16 +242,15 @@
19
 
     u_char *buf_ = (u_char*)buf;
20
 
     for (; len;) {
21
 
-      if (Xlen < 64) { // 16 words = 64 bytes
22
 
-        u_int l = 64 - Xlen;
23
 
-        if (len < l)
24
 
-          l = len;
25
 
-        memcpy(((u_char*)X) + Xlen, buf_, l);
26
 
-        Xlen += l;
27
 
-        count += l;
28
 
-        len -= l;
29
 
-        buf_ += l;
30
 
+      for(;Xlen < 64;) { // 16 words = 64 bytes
31
 
+        if(!len) break;
32
 
+        u_int Xi = Xlen >> 2;
33
 
+        u_int Xs = (Xlen & 3) << 3;
34
 
+        X[Xi] |= ((uint32_t)(*buf_)) << Xs;
35
 
+        ++Xlen;
36
 
+        ++count;
37
 
+        --len;
38
 
+        ++buf_;
39
 
       }
40
 
-      if (Xlen < 64)
41
 
-        return;
42
 
+      if (Xlen < 64) return;
43
 
 
44
 
       uint32_t AA = A;
45
 
@@ -349,10 +349,10 @@
46
 
       D += DD;
47
 
       Xlen = 0;
48
 
+      memset(X,0,sizeof(X));
49
 
     }
50
 
   }
51
 
 
52
 
   void MD5Sum::end(void) {
53
 
-    if (computed)
54
 
-      return;
55
 
+    if (computed) return;
56
 
     // pad
57
 
     uint64_t l = 8 * count; // number of bits
58
 
@@ -360,7 +360,14 @@
59
 
     add(&c, 1);
60
 
     c = 0;
61
 
-    for (; Xlen != 56;)
62
 
-      add(&c, 1);
63
 
-    add(&l, 8);
64
 
+    for (; Xlen != 56;) add(&c, 1);
65
 
+    //add(&l, 8);
66
 
+    c = (u_char)(l>>0);  add(&c, 1);
67
 
+    c = (u_char)(l>>8);  add(&c, 1);
68
 
+    c = (u_char)(l>>16); add(&c, 1);
69
 
+    c = (u_char)(l>>24); add(&c, 1);
70
 
+    c = (u_char)(l>>32); add(&c, 1);
71
 
+    c = (u_char)(l>>40); add(&c, 1);
72
 
+    c = (u_char)(l>>48); add(&c, 1);
73
 
+    c = (u_char)(l>>56); add(&c, 1);
74
 
     computed = true;
75
 
   }
76
 
@@ -368,31 +375,31 @@
77
 
   int MD5Sum::print(char *buf, int len) const {
78
 
     if (!computed) {
79
 
-      if (len > 0)
80
 
-        buf[0] = 0;
81
 
+      if (len > 0) buf[0] = 0;
82
 
       return 0;
83
 
     }
84
 
     return snprintf(buf, len,
85
 
                     "md5:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
86
 
-                    ((u_char*)&A)[0], ((u_char*)&A)[1], ((u_char*)&A)[2], ((u_char*)&A)[3],
87
 
-                    ((u_char*)&B)[0], ((u_char*)&B)[1], ((u_char*)&B)[2], ((u_char*)&B)[3],
88
 
-                    ((u_char*)&C)[0], ((u_char*)&C)[1], ((u_char*)&C)[2], ((u_char*)&C)[3],
89
 
-                    ((u_char*)&D)[0], ((u_char*)&D)[1], ((u_char*)&D)[2], ((u_char*)&D)[3]
90
 
+                    (u_char)(A>>0), (u_char)(A>>8), (u_char)(A>>16), (u_char)(A>>24),
91
 
+                    (u_char)(B>>0), (u_char)(B>>8), (u_char)(B>>16), (u_char)(B>>24),
92
 
+                    (u_char)(C>>0), (u_char)(C>>8), (u_char)(C>>16), (u_char)(C>>24),
93
 
+                    (u_char)(D>>0), (u_char)(D>>8), (u_char)(D>>16), (u_char)(D>>24)
94
 
                     );
95
 
   }
96
 
 
97
 
   void MD5Sum::scan(const char *buf) {
98
 
+    u_char A0, A1, A2, A3, B0, B1, B2, B3, C0, C1, C2, C3, D0, D1, D2, D3;
99
 
     computed = false;
100
 
-    if (strncasecmp("md5:", buf, 4) != 0)
101
 
-      return;
102
 
+    if (strncasecmp("md5:", buf, 4) != 0) return;
103
 
     int l = sscanf(buf + 4,
104
 
                    "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx"
105
 
                    "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx",
106
 
-                   ((u_char*)&A) + 0, ((u_char*)&A) + 1, ((u_char*)&A) + 2, ((u_char*)&A) + 3,
107
 
-                   ((u_char*)&B) + 0, ((u_char*)&B) + 1, ((u_char*)&B) + 2, ((u_char*)&B) + 3,
108
 
-                   ((u_char*)&C) + 0, ((u_char*)&C) + 1, ((u_char*)&C) + 2, ((u_char*)&C) + 3,
109
 
-                   ((u_char*)&D) + 0, ((u_char*)&D) + 1, ((u_char*)&D) + 2, ((u_char*)&D) + 3
110
 
+                   &A0, &A1, &A2, &A3, &B0, &B1, &B2, &B3,
111
 
+                   &C0, &C1, &C2, &C3, &D0, &D1, &D2, &D3
112
 
                    );
113
 
-    if (l != 16)
114
 
-      return;
115
 
+    A = (((uint32_t)A0)<<0) | (((uint32_t)A1)<<8) | (((uint32_t)A2)<<16) | (((uint32_t)A3)<<24);
116
 
+    B = (((uint32_t)B0)<<0) | (((uint32_t)B1)<<8) | (((uint32_t)B2)<<16) | (((uint32_t)B3)<<24);
117
 
+    C = (((uint32_t)C0)<<0) | (((uint32_t)C1)<<8) | (((uint32_t)C2)<<16) | (((uint32_t)C3)<<24);
118
 
+    D = (((uint32_t)D0)<<0) | (((uint32_t)D1)<<8) | (((uint32_t)D2)<<16) | (((uint32_t)D3)<<24);
119
 
+    if (l != 16) return;
120
 
     computed = true;
121
 
     return;
122
 
Index: trunk/src/hed/libs/common/test/CheckSumTest.cpp
123
 
===================================================================
124
 
--- trunk/src/hed/libs/common/test/CheckSumTest.cpp     (revision 22394)
125
 
+++ trunk/src/hed/libs/common/test/CheckSumTest.cpp     (revision 23053)
126
 
@@ -47,4 +47,9 @@
127
 
   CPPUNIT_ASSERT_EQUAL((std::string)"acb7ca96", Arc::CheckSumAny::FileChecksum("CheckSumTest.f1K.data", Arc::CheckSumAny::cksum));
128
 
   CPPUNIT_ASSERT_EQUAL((std::string)"53a57307", Arc::CheckSumAny::FileChecksum("CheckSumTest.f1M.data", Arc::CheckSumAny::cksum));
129
 
+  char buf[64];
130
 
+  Arc::CheckSumAny ck(Arc::CheckSumAny::cksum);
131
 
+  ck.scan("cksum:53a57307");
132
 
+  ck.print(buf,sizeof(buf));
133
 
+  CPPUNIT_ASSERT_EQUAL((std::string)"cksum:53a57307", (std::string)buf);
134
 
 }
135
 
 
136
 
@@ -52,4 +57,9 @@
137
 
   CPPUNIT_ASSERT_EQUAL((std::string)"88bb69a5d5e02ec7af5f68d82feb1f1d", Arc::CheckSumAny::FileChecksum("CheckSumTest.f1K.data"));
138
 
   CPPUNIT_ASSERT_EQUAL((std::string)"2f54d66538c094bf229e89ed0667b6fd", Arc::CheckSumAny::FileChecksum("CheckSumTest.f1M.data"));
139
 
+  char buf[64];
140
 
+  Arc::CheckSumAny ck(Arc::CheckSumAny::md5);
141
 
+  ck.scan("md5:2f54d66538c094bf229e89ed0667b6fd");
142
 
+  ck.print(buf,sizeof(buf));
143
 
+  CPPUNIT_ASSERT_EQUAL((std::string)"md5:2f54d66538c094bf229e89ed0667b6fd", (std::string)buf);
144
 
 }
145
 
 
146
 
@@ -57,4 +67,9 @@
147
 
   CPPUNIT_ASSERT_EQUAL((std::string)"ad1abb81", Arc::CheckSumAny::FileChecksum("CheckSumTest.f1K.data", Arc::CheckSumAny::adler32));
148
 
   CPPUNIT_ASSERT_EQUAL((std::string)"471b96e5", Arc::CheckSumAny::FileChecksum("CheckSumTest.f1M.data", Arc::CheckSumAny::adler32));
149
 
+  //char buf[64];
150
 
+  //Arc::CheckSumAny ck(Arc::CheckSumAny::adler32);
151
 
+  //ck.scan("adler32:471b96e5");
152
 
+  //ck.print(buf,sizeof(buf));
153
 
+  //CPPUNIT_ASSERT_EQUAL((std::string)"adler32:471b96e5", (std::string)buf);
154
 
 }
155