Lines Matching refs:md

110 static int sha512_compress(struct sha512_state *md, unsigned char *buf)
117 S[i] = md->state[i];
146 md->state[i] = md->state[i] + S[i];
155 @param md The hash state you wish to initialize
158 void sha512_init(struct sha512_state *md)
160 md->curlen = 0;
161 md->length = 0;
162 md->state[0] = CONST64(0x6a09e667f3bcc908);
163 md->state[1] = CONST64(0xbb67ae8584caa73b);
164 md->state[2] = CONST64(0x3c6ef372fe94f82b);
165 md->state[3] = CONST64(0xa54ff53a5f1d36f1);
166 md->state[4] = CONST64(0x510e527fade682d1);
167 md->state[5] = CONST64(0x9b05688c2b3e6c1f);
168 md->state[6] = CONST64(0x1f83d9abfb41bd6b);
169 md->state[7] = CONST64(0x5be0cd19137e2179);
175 @param md The hash state
180 int sha512_process(struct sha512_state *md, const unsigned char *in,
185 if (md->curlen >= sizeof(md->buf))
189 if (md->curlen == 0 && inlen >= SHA512_BLOCK_SIZE) {
190 if (sha512_compress(md, (unsigned char *) in) < 0)
192 md->length += SHA512_BLOCK_SIZE * 8;
196 n = MIN(inlen, (SHA512_BLOCK_SIZE - md->curlen));
197 os_memcpy(md->buf + md->curlen, in, n);
198 md->curlen += n;
201 if (md->curlen == SHA512_BLOCK_SIZE) {
202 if (sha512_compress(md, md->buf) < 0)
204 md->length += 8 * SHA512_BLOCK_SIZE;
205 md->curlen = 0;
216 @param md The hash state
220 int sha512_done(struct sha512_state *md, unsigned char *out)
224 if (md->curlen >= sizeof(md->buf))
228 md->length += md->curlen * CONST64(8);
231 md->buf[md->curlen++] = (unsigned char) 0x80;
237 if (md->curlen > 112) {
238 while (md->curlen < 128) {
239 md->buf[md->curlen++] = (unsigned char) 0;
241 sha512_compress(md, md->buf);
242 md->curlen = 0;
249 while (md->curlen < 120) {
250 md->buf[md->curlen++] = (unsigned char) 0;
254 WPA_PUT_BE64(md->buf + 120, md->length);
255 sha512_compress(md, md->buf);
259 WPA_PUT_BE64(out + (8 * i), md->state[i]);