Lines Matching full:md

84 static int sha256_compress(struct sha256_state *md, unsigned char *buf)  in sha256_compress()  argument
92 S[i] = md->state[i]; in sha256_compress()
120 md->state[i] = md->state[i] + S[i]; in sha256_compress()
127 void sha256_init(struct sha256_state *md) in sha256_init() argument
129 md->curlen = 0; in sha256_init()
130 md->length = 0; in sha256_init()
131 md->state[0] = 0x6A09E667UL; in sha256_init()
132 md->state[1] = 0xBB67AE85UL; in sha256_init()
133 md->state[2] = 0x3C6EF372UL; in sha256_init()
134 md->state[3] = 0xA54FF53AUL; in sha256_init()
135 md->state[4] = 0x510E527FUL; in sha256_init()
136 md->state[5] = 0x9B05688CUL; in sha256_init()
137 md->state[6] = 0x1F83D9ABUL; in sha256_init()
138 md->state[7] = 0x5BE0CD19UL; in sha256_init()
143 @param md The hash state
148 int sha256_process(struct sha256_state *md, const unsigned char *in, in sha256_process() argument
153 if (md->curlen >= sizeof(md->buf)) in sha256_process()
157 if (md->curlen == 0 && inlen >= SHA256_BLOCK_SIZE) { in sha256_process()
158 if (sha256_compress(md, (unsigned char *) in) < 0) in sha256_process()
160 md->length += SHA256_BLOCK_SIZE * 8; in sha256_process()
164 n = MIN(inlen, (SHA256_BLOCK_SIZE - md->curlen)); in sha256_process()
165 os_memcpy(md->buf + md->curlen, in, n); in sha256_process()
166 md->curlen += n; in sha256_process()
169 if (md->curlen == SHA256_BLOCK_SIZE) { in sha256_process()
170 if (sha256_compress(md, md->buf) < 0) in sha256_process()
172 md->length += 8 * SHA256_BLOCK_SIZE; in sha256_process()
173 md->curlen = 0; in sha256_process()
184 @param md The hash state
188 int sha256_done(struct sha256_state *md, unsigned char *out) in sha256_done() argument
192 if (md->curlen >= sizeof(md->buf)) in sha256_done()
196 md->length += md->curlen * 8; in sha256_done()
199 md->buf[md->curlen++] = (unsigned char) 0x80; in sha256_done()
205 if (md->curlen > 56) { in sha256_done()
206 while (md->curlen < SHA256_BLOCK_SIZE) { in sha256_done()
207 md->buf[md->curlen++] = (unsigned char) 0; in sha256_done()
209 sha256_compress(md, md->buf); in sha256_done()
210 md->curlen = 0; in sha256_done()
214 while (md->curlen < 56) { in sha256_done()
215 md->buf[md->curlen++] = (unsigned char) 0; in sha256_done()
219 WPA_PUT_BE64(md->buf + 56, md->length); in sha256_done()
220 sha256_compress(md, md->buf); in sha256_done()
224 WPA_PUT_BE32(out + (4 * i), md->state[i]); in sha256_done()