Home | History | Annotate | Download | only in crypto

Lines Matching refs:md

84 static int sha256_compress(struct sha256_state *md, unsigned char *buf)
92 S[i] = md->state[i];
120 md->state[i] = md->state[i] + S[i];
127 void sha256_init(struct sha256_state *md)
129 md->curlen = 0;
130 md->length = 0;
131 md->state[0] = 0x6A09E667UL;
132 md->state[1] = 0xBB67AE85UL;
133 md->state[2] = 0x3C6EF372UL;
134 md->state[3] = 0xA54FF53AUL;
135 md->state[4] = 0x510E527FUL;
136 md->state[5] = 0x9B05688CUL;
137 md->state[6] = 0x1F83D9ABUL;
138 md->state[7] = 0x5BE0CD19UL;
143 @param md The hash state
148 int sha256_process(struct sha256_state *md, const unsigned char *in,
153 if (md->curlen >= sizeof(md->buf))
157 if (md->curlen == 0 && inlen >= SHA256_BLOCK_SIZE) {
158 if (sha256_compress(md, (unsigned char *) in) < 0)
160 md->length += SHA256_BLOCK_SIZE * 8;
164 n = MIN(inlen, (SHA256_BLOCK_SIZE - md->curlen));
165 os_memcpy(md->buf + md->curlen, in, n);
166 md->curlen += n;
169 if (md->curlen == SHA256_BLOCK_SIZE) {
170 if (sha256_compress(md, md->buf) < 0)
172 md->length += 8 * SHA256_BLOCK_SIZE;
173 md->curlen = 0;
184 @param md The hash state
188 int sha256_done(struct sha256_state *md, unsigned char *out)
192 if (md->curlen >= sizeof(md->buf))
196 md->length += md->curlen * 8;
199 md->buf[md->curlen++] = (unsigned char) 0x80;
205 if (md->curlen > 56) {
206 while (md->curlen < SHA256_BLOCK_SIZE) {
207 md->buf[md->curlen++] = (unsigned char) 0;
209 sha256_compress(md, md->buf);
210 md->curlen = 0;
214 while (md->curlen < 56) {
215 md->buf[md->curlen++] = (unsigned char) 0;
219 WPA_PUT_BE64(md->buf + 56, md->length);
220 sha256_compress(md, md->buf);
224 WPA_PUT_BE32(out + (4 * i), md->state[i]);