Hash a single 512-bit block. This is the core of the algorithm.
| 53 | |
| 54 | // Hash a single 512-bit block. This is the core of the algorithm. |
| 55 | void SHA1::SHA1Transform(uint32_t state[5], const uint8_t buffer[64]) { |
| 56 | union CHAR64LONG16 { |
| 57 | uint8_t c[64]; |
| 58 | uint32_t l[16]; |
| 59 | }; |
| 60 | |
| 61 | // Note(fbarchard): This option does modify the user's data buffer. |
| 62 | CHAR64LONG16* block = const_cast<CHAR64LONG16*>( |
| 63 | reinterpret_cast<const CHAR64LONG16*>(buffer)); |
| 64 | |
| 65 | // Copy context_.state[] to working vars. |
| 66 | uint32_t a = state[0]; |
| 67 | uint32_t b = state[1]; |
| 68 | uint32_t c = state[2]; |
| 69 | uint32_t d = state[3]; |
| 70 | uint32_t e = state[4]; |
| 71 | |
| 72 | // 4 rounds of 20 operations each. Loop unrolled. |
| 73 | // Note(fbarchard): The following has lint warnings for multiple ; on |
| 74 | // a line and no space after , but is left as-is to be similar to the |
| 75 | // original code. |
| 76 | R0(a, b, c, d, e, 0); |
| 77 | R0(e, a, b, c, d, 1); |
| 78 | R0(d, e, a, b, c, 2); |
| 79 | R0(c, d, e, a, b, 3); |
| 80 | R0(b, c, d, e, a, 4); |
| 81 | R0(a, b, c, d, e, 5); |
| 82 | R0(e, a, b, c, d, 6); |
| 83 | R0(d, e, a, b, c, 7); |
| 84 | R0(c, d, e, a, b, 8); |
| 85 | R0(b, c, d, e, a, 9); |
| 86 | R0(a, b, c, d, e, 10); |
| 87 | R0(e, a, b, c, d, 11); |
| 88 | R0(d, e, a, b, c, 12); |
| 89 | R0(c, d, e, a, b, 13); |
| 90 | R0(b, c, d, e, a, 14); |
| 91 | R0(a, b, c, d, e, 15); |
| 92 | R1(e, a, b, c, d, 16); |
| 93 | R1(d, e, a, b, c, 17); |
| 94 | R1(c, d, e, a, b, 18); |
| 95 | R1(b, c, d, e, a, 19); |
| 96 | R2(a, b, c, d, e, 20); |
| 97 | R2(e, a, b, c, d, 21); |
| 98 | R2(d, e, a, b, c, 22); |
| 99 | R2(c, d, e, a, b, 23); |
| 100 | R2(b, c, d, e, a, 24); |
| 101 | R2(a, b, c, d, e, 25); |
| 102 | R2(e, a, b, c, d, 26); |
| 103 | R2(d, e, a, b, c, 27); |
| 104 | R2(c, d, e, a, b, 28); |
| 105 | R2(b, c, d, e, a, 29); |
| 106 | R2(a, b, c, d, e, 30); |
| 107 | R2(e, a, b, c, d, 31); |
| 108 | R2(d, e, a, b, c, 32); |
| 109 | R2(c, d, e, a, b, 33); |
| 110 | R2(b, c, d, e, a, 34); |
| 111 | R2(a, b, c, d, e, 35); |
| 112 | R2(e, a, b, c, d, 36); |
nothing calls this directly
no outgoing calls
no test coverage detected