Lines Matching refs:md

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