Overview
Comment: | OFMD5Hash improvements. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
165c2c0b9db56658c7d9065c56a7559c |
User & Date: | js on 2008-10-26 17:48:05 |
Other Links: | manifest | tags |
Context
2008-10-26
| ||
19:35 | Add OFSHA1Hash. check-in: 631895440e user: js tags: trunk | |
17:48 | OFMD5Hash improvements. check-in: 165c2c0b9d user: js tags: trunk | |
12:05 | Actually test OFXMLFactory. check-in: 58e11df891 user: js tags: trunk | |
Changes
Modified src/OFHashes.h from [714154ae18] to [4951f2110c].
︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | + + | #import "OFObject.h" @interface OFMD5Hash: OFObject { uint32_t buf[4]; uint32_t bits[2]; uint8_t in[64]; BOOL calculated; } - init; - (void)updateWithBuffer: (const uint8_t*)buf ofSize: (size_t)size; - (uint8_t*)digest; @end |
Modified src/OFHashes.m from [5bb7027c8f] to [e568bcc89c].
︙ | |||
17 18 19 20 21 22 23 | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | - + - + + + + + | #import "OFHashes.h" #ifdef BIG_ENDIAN inline void bswap(uint8_t *buf, size_t len) { uint32_t t; |
︙ | |||
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | + + + + + + + | buf[0] = 0x67452301; buf[1] = 0xEFCDAB89; buf[2] = 0x98BADCFE; buf[3] = 0x10325476; bits[0] = 0; bits[1] = 0; calculated = NO; } return self; } - (void)updateWithBuffer: (const uint8_t*)buffer ofSize: (size_t)size { uint32_t t; if (calculated) return; if (size == 0) return; /* Update bitcount */ t = bits[0]; if ((bits[0] = t + ((uint32_t)size << 3)) < t) bits[1]++; /* Carry from low to high */ bits[1] += size >> 29; |
︙ | |||
185 186 187 188 189 190 191 192 193 194 195 196 197 198 | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | + + + | } - (uint8_t*)digest { uint8_t *p; size_t count; if (calculated) return (uint8_t*)buf; /* Compute number of bytes mod 64 */ count = (bits[0] >> 3) & 0x3F; /* * Set the first char of padding to 0x80. This is safe since there is * always at least one byte free */ |
︙ | |||
219 220 221 222 223 224 225 226 227 228 229 | 233 234 235 236 237 238 239 240 241 242 243 244 245 | + + | /* Append length in bits and transform */ ((uint32_t*)in)[14] = bits[0]; ((uint32_t*)in)[15] = bits[1]; md5_transform(buf, (uint32_t*)in); bswap((uint8_t*)buf, 4); calculated = YES; return (uint8_t*)buf; } @end |