Lines Matching full:md
81 static int sha256_compress(struct sha256_state *md, unsigned char *buf) in sha256_compress() argument
89 S[i] = md->state[i]; in sha256_compress()
117 md->state[i] = md->state[i] + S[i]; in sha256_compress()
124 void sha256_init(struct sha256_state *md) in sha256_init() argument
126 md->curlen = 0; in sha256_init()
127 md->length = 0; in sha256_init()
128 md->state[0] = 0x6A09E667UL; in sha256_init()
129 md->state[1] = 0xBB67AE85UL; in sha256_init()
130 md->state[2] = 0x3C6EF372UL; in sha256_init()
131 md->state[3] = 0xA54FF53AUL; in sha256_init()
132 md->state[4] = 0x510E527FUL; in sha256_init()
133 md->state[5] = 0x9B05688CUL; in sha256_init()
134 md->state[6] = 0x1F83D9ABUL; in sha256_init()
135 md->state[7] = 0x5BE0CD19UL; in sha256_init()
140 @param md The hash state
145 int sha256_process(struct sha256_state *md, const unsigned char *in, in sha256_process() argument
150 if (md->curlen >= sizeof(md->buf)) in sha256_process()
154 if (md->curlen == 0 && inlen >= SHA256_BLOCK_SIZE) { in sha256_process()
155 if (sha256_compress(md, (unsigned char *) in) < 0) in sha256_process()
157 md->length += SHA256_BLOCK_SIZE * 8; in sha256_process()
161 n = MIN(inlen, (SHA256_BLOCK_SIZE - md->curlen)); in sha256_process()
162 os_memcpy(md->buf + md->curlen, in, n); in sha256_process()
163 md->curlen += n; in sha256_process()
166 if (md->curlen == SHA256_BLOCK_SIZE) { in sha256_process()
167 if (sha256_compress(md, md->buf) < 0) in sha256_process()
169 md->length += 8 * SHA256_BLOCK_SIZE; in sha256_process()
170 md->curlen = 0; in sha256_process()
181 @param md The hash state
185 int sha256_done(struct sha256_state *md, unsigned char *out) in sha256_done() argument
189 if (md->curlen >= sizeof(md->buf)) in sha256_done()
193 md->length += md->curlen * 8; in sha256_done()
196 md->buf[md->curlen++] = (unsigned char) 0x80; in sha256_done()
202 if (md->curlen > 56) { in sha256_done()
203 while (md->curlen < SHA256_BLOCK_SIZE) { in sha256_done()
204 md->buf[md->curlen++] = (unsigned char) 0; in sha256_done()
206 sha256_compress(md, md->buf); in sha256_done()
207 md->curlen = 0; in sha256_done()
211 while (md->curlen < 56) { in sha256_done()
212 md->buf[md->curlen++] = (unsigned char) 0; in sha256_done()
216 WPA_PUT_BE64(md->buf + 56, md->length); in sha256_done()
217 sha256_compress(md, md->buf); in sha256_done()
221 WPA_PUT_BE32(out + (4 * i), md->state[i]); in sha256_done()