Lines Matching full:md
107 static int sha512_compress(struct sha512_state *md, unsigned char *buf) in sha512_compress() argument
119 S[i] = md->state[i]; in sha512_compress()
148 md->state[i] = md->state[i] + S[i]; in sha512_compress()
158 @param md The hash state you wish to initialize
161 void sha512_init(struct sha512_state *md) in sha512_init() argument
163 md->curlen = 0; in sha512_init()
164 md->length = 0; in sha512_init()
165 md->state[0] = CONST64(0x6a09e667f3bcc908); in sha512_init()
166 md->state[1] = CONST64(0xbb67ae8584caa73b); in sha512_init()
167 md->state[2] = CONST64(0x3c6ef372fe94f82b); in sha512_init()
168 md->state[3] = CONST64(0xa54ff53a5f1d36f1); in sha512_init()
169 md->state[4] = CONST64(0x510e527fade682d1); in sha512_init()
170 md->state[5] = CONST64(0x9b05688c2b3e6c1f); in sha512_init()
171 md->state[6] = CONST64(0x1f83d9abfb41bd6b); in sha512_init()
172 md->state[7] = CONST64(0x5be0cd19137e2179); in sha512_init()
178 @param md The hash state
183 int sha512_process(struct sha512_state *md, const unsigned char *in, in sha512_process() argument
188 if (md->curlen >= sizeof(md->buf)) in sha512_process()
192 if (md->curlen == 0 && inlen >= SHA512_BLOCK_SIZE) { in sha512_process()
193 if (sha512_compress(md, (unsigned char *) in) < 0) in sha512_process()
195 md->length += SHA512_BLOCK_SIZE * 8; in sha512_process()
199 n = MIN(inlen, (SHA512_BLOCK_SIZE - md->curlen)); in sha512_process()
200 os_memcpy(md->buf + md->curlen, in, n); in sha512_process()
201 md->curlen += n; in sha512_process()
204 if (md->curlen == SHA512_BLOCK_SIZE) { in sha512_process()
205 if (sha512_compress(md, md->buf) < 0) in sha512_process()
207 md->length += 8 * SHA512_BLOCK_SIZE; in sha512_process()
208 md->curlen = 0; in sha512_process()
219 @param md The hash state
223 int sha512_done(struct sha512_state *md, unsigned char *out) in sha512_done() argument
227 if (md->curlen >= sizeof(md->buf)) in sha512_done()
231 md->length += md->curlen * CONST64(8); in sha512_done()
234 md->buf[md->curlen++] = (unsigned char) 0x80; in sha512_done()
240 if (md->curlen > 112) { in sha512_done()
241 while (md->curlen < 128) { in sha512_done()
242 md->buf[md->curlen++] = (unsigned char) 0; in sha512_done()
244 sha512_compress(md, md->buf); in sha512_done()
245 md->curlen = 0; in sha512_done()
252 while (md->curlen < 120) { in sha512_done()
253 md->buf[md->curlen++] = (unsigned char) 0; in sha512_done()
257 WPA_PUT_BE64(md->buf + 120, md->length); in sha512_done()
258 sha512_compress(md, md->buf); in sha512_done()
262 WPA_PUT_BE64(out + (8 * i), md->state[i]); in sha512_done()