OLD | NEW |
1 /* | 1 /* |
2 * SHA-1 in C | 2 * SHA-1 in C |
3 * By Steve Reid <sreid@sea-to-sky.net> | 3 * By Steve Reid <sreid@sea-to-sky.net> |
4 * 100% Public Domain | 4 * 100% Public Domain |
5 * | 5 * |
6 * ----------------- | 6 * ----------------- |
7 * Modified 7/98 | 7 * Modified 7/98 |
8 * By James H. Brown <jbrown@burgoyne.com> | 8 * By James H. Brown <jbrown@burgoyne.com> |
9 * Still 100% Public Domain | 9 * Still 100% Public Domain |
10 * | 10 * |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
110 namespace rtc { | 110 namespace rtc { |
111 | 111 |
112 namespace { | 112 namespace { |
113 | 113 |
114 #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) | 114 #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) |
115 | 115 |
116 // blk0() and blk() perform the initial expand. | 116 // blk0() and blk() perform the initial expand. |
117 // I got the idea of expanding during the round function from SSLeay | 117 // I got the idea of expanding during the round function from SSLeay |
118 // FIXME: can we do this in an endian-proof way? | 118 // FIXME: can we do this in an endian-proof way? |
119 #ifdef ARCH_CPU_BIG_ENDIAN | 119 #ifdef RTC_ARCH_CPU_BIG_ENDIAN |
120 #define blk0(i) block->l[i] | 120 #define blk0(i) block->l[i] |
121 #else | 121 #else |
122 #define blk0(i) (block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) | \ | 122 #define blk0(i) (block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) | \ |
123 (rol(block->l[i], 8) & 0x00FF00FF)) | 123 (rol(block->l[i], 8) & 0x00FF00FF)) |
124 #endif | 124 #endif |
125 #define blk(i) (block->l[i & 15] = rol(block->l[(i + 13) & 15] ^ \ | 125 #define blk(i) (block->l[i & 15] = rol(block->l[(i + 13) & 15] ^ \ |
126 block->l[(i + 8) & 15] ^ block->l[(i + 2) & 15] ^ block->l[i & 15], 1)) | 126 block->l[(i + 8) & 15] ^ block->l[(i + 2) & 15] ^ block->l[i & 15], 1)) |
127 | 127 |
128 // (R0+R1), R2, R3, R4 are the different operations used in SHA1. | 128 // (R0+R1), R2, R3, R4 are the different operations used in SHA1. |
129 #define R0(v, w, x, y, z, i) \ | 129 #define R0(v, w, x, y, z, i) \ |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 memset(context->state, 0, 20); | 284 memset(context->state, 0, 20); |
285 memset(context->count, 0, 8); | 285 memset(context->count, 0, 8); |
286 memset(finalcount, 0, 8); // SWR | 286 memset(finalcount, 0, 8); // SWR |
287 | 287 |
288 #ifdef SHA1HANDSOFF // Make SHA1Transform overwrite its own static vars. | 288 #ifdef SHA1HANDSOFF // Make SHA1Transform overwrite its own static vars. |
289 SHA1Transform(context->state, context->buffer); | 289 SHA1Transform(context->state, context->buffer); |
290 #endif | 290 #endif |
291 } | 291 } |
292 | 292 |
293 } // namespace rtc | 293 } // namespace rtc |
OLD | NEW |