| 124 | } |
| 125 | |
| 126 | static void sha_process(sha256_state *md, const void *src, u32 inlen) |
| 127 | { |
| 128 | const u32 block_size = 64; |
| 129 | const unsigned char *in = (const unsigned char *)src; |
| 130 | |
| 131 | while(inlen > 0) |
| 132 | { |
| 133 | if(md->curlen == 0 && inlen >= block_size) |
| 134 | { |
| 135 | sha_compress(md, in); |
| 136 | md->length += block_size * 8; |
| 137 | in += block_size; |
| 138 | inlen -= block_size; |
| 139 | } |
| 140 | else |
| 141 | { |
| 142 | u32 n = minimum(inlen, (block_size - md->curlen)); |
| 143 | memcpy(md->buf + md->curlen, in, n); |
| 144 | md->curlen += n; |
| 145 | in += n; |
| 146 | inlen -= n; |
| 147 | |
| 148 | if(md->curlen == block_size) |
| 149 | { |
| 150 | sha_compress(md, md->buf); |
| 151 | md->length += 8 * block_size; |
| 152 | md->curlen = 0; |
| 153 | } |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | static void sha_done(sha256_state *md, void *out) |
| 159 | { |
no test coverage detected