Lines Matching refs:md

168 static void sha256_init(struct sha256_state *md);
169 static int sha256_process(struct sha256_state *md, const unsigned char *in,
171 static int sha256_done(struct sha256_state *md, unsigned char *out);
234 static int sha256_compress(struct sha256_state *md, unsigned char *buf)
242 S[i] = md->state[i];
270 md->state[i] = md->state[i] + S[i];
277 static void sha256_init(struct sha256_state *md)
279 md->curlen = 0;
280 md->length = 0;
281 md->state[0] = 0x6A09E667UL;
282 md->state[1] = 0xBB67AE85UL;
283 md->state[2] = 0x3C6EF372UL;
284 md->state[3] = 0xA54FF53AUL;
285 md->state[4] = 0x510E527FUL;
286 md->state[5] = 0x9B05688CUL;
287 md->state[6] = 0x1F83D9ABUL;
288 md->state[7] = 0x5BE0CD19UL;
293 @param md The hash state
298 static int sha256_process(struct sha256_state *md, const unsigned char *in,
304 if (md->curlen > sizeof(md->buf))
308 if (md->curlen == 0 && inlen >= block_size) {
309 if (sha256_compress(md, (unsigned char *) in) < 0)
311 md->length += block_size * 8;
315 n = MIN(inlen, (block_size - md->curlen));
316 os_memcpy(md->buf + md->curlen, in, n);
317 md->curlen += n;
320 if (md->curlen == block_size) {
321 if (sha256_compress(md, md->buf) < 0)
323 md->length += 8 * block_size;
324 md->curlen = 0;
335 @param md The hash state
339 static int sha256_done(struct sha256_state *md, unsigned char *out)
343 if (md->curlen >= sizeof(md->buf))
347 md->length += md->curlen * 8;
350 md->buf[md->curlen++] = (unsigned char) 0x80;
356 if (md->curlen > 56) {
357 while (md->curlen < 64) {
358 md->buf[md->curlen++] = (unsigned char) 0;
360 sha256_compress(md, md->buf);
361 md->curlen = 0;
365 while (md->curlen < 56) {
366 md->buf[md->curlen++] = (unsigned char) 0;
370 WPA_PUT_BE64(md->buf + 56, md->length);
371 sha256_compress(md, md->buf);
375 WPA_PUT_BE32(out + (4 * i), md->state[i]);