Lines Matching full:md

110 static int sha512_compress(struct sha512_state *md, unsigned char *buf)  in sha512_compress()  argument
122 S[i] = md->state[i]; in sha512_compress()
151 md->state[i] = md->state[i] + S[i]; in sha512_compress()
161 @param md The hash state you wish to initialize
164 void sha512_init(struct sha512_state *md) in sha512_init() argument
166 md->curlen = 0; in sha512_init()
167 md->length = 0; in sha512_init()
168 md->state[0] = CONST64(0x6a09e667f3bcc908); in sha512_init()
169 md->state[1] = CONST64(0xbb67ae8584caa73b); in sha512_init()
170 md->state[2] = CONST64(0x3c6ef372fe94f82b); in sha512_init()
171 md->state[3] = CONST64(0xa54ff53a5f1d36f1); in sha512_init()
172 md->state[4] = CONST64(0x510e527fade682d1); in sha512_init()
173 md->state[5] = CONST64(0x9b05688c2b3e6c1f); in sha512_init()
174 md->state[6] = CONST64(0x1f83d9abfb41bd6b); in sha512_init()
175 md->state[7] = CONST64(0x5be0cd19137e2179); in sha512_init()
181 @param md The hash state
186 int sha512_process(struct sha512_state *md, const unsigned char *in, in sha512_process() argument
191 if (md->curlen >= sizeof(md->buf)) in sha512_process()
195 if (md->curlen == 0 && inlen >= SHA512_BLOCK_SIZE) { in sha512_process()
196 if (sha512_compress(md, (unsigned char *) in) < 0) in sha512_process()
198 md->length += SHA512_BLOCK_SIZE * 8; in sha512_process()
202 n = MIN(inlen, (SHA512_BLOCK_SIZE - md->curlen)); in sha512_process()
203 os_memcpy(md->buf + md->curlen, in, n); in sha512_process()
204 md->curlen += n; in sha512_process()
207 if (md->curlen == SHA512_BLOCK_SIZE) { in sha512_process()
208 if (sha512_compress(md, md->buf) < 0) in sha512_process()
210 md->length += 8 * SHA512_BLOCK_SIZE; in sha512_process()
211 md->curlen = 0; in sha512_process()
222 @param md The hash state
226 int sha512_done(struct sha512_state *md, unsigned char *out) in sha512_done() argument
230 if (md->curlen >= sizeof(md->buf)) in sha512_done()
234 md->length += md->curlen * CONST64(8); in sha512_done()
237 md->buf[md->curlen++] = (unsigned char) 0x80; in sha512_done()
243 if (md->curlen > 112) { in sha512_done()
244 while (md->curlen < 128) { in sha512_done()
245 md->buf[md->curlen++] = (unsigned char) 0; in sha512_done()
247 sha512_compress(md, md->buf); in sha512_done()
248 md->curlen = 0; in sha512_done()
255 while (md->curlen < 120) { in sha512_done()
256 md->buf[md->curlen++] = (unsigned char) 0; in sha512_done()
260 WPA_PUT_BE64(md->buf + 120, md->length); in sha512_done()
261 sha512_compress(md, md->buf); in sha512_done()
265 WPA_PUT_BE64(out + (8 * i), md->state[i]); in sha512_done()