Lines Matching full:md

85 static void sha256_compress(struct hash_state * md, const unsigned char *buf)  in sha256_compress()  argument
93 S[i] = md->sha256.state[i]; in sha256_compress()
115 md->sha256.state[i] = md->sha256.state[i] + S[i]; in sha256_compress()
119 static void sha256_init(struct hash_state * md) in sha256_init() argument
121 md->sha256.curlen = 0; in sha256_init()
122 md->sha256.length = 0; in sha256_init()
123 md->sha256.state[0] = 0x6A09E667UL; in sha256_init()
124 md->sha256.state[1] = 0xBB67AE85UL; in sha256_init()
125 md->sha256.state[2] = 0x3C6EF372UL; in sha256_init()
126 md->sha256.state[3] = 0xA54FF53AUL; in sha256_init()
127 md->sha256.state[4] = 0x510E527FUL; in sha256_init()
128 md->sha256.state[5] = 0x9B05688CUL; in sha256_init()
129 md->sha256.state[6] = 0x1F83D9ABUL; in sha256_init()
130 md->sha256.state[7] = 0x5BE0CD19UL; in sha256_init()
135 static void sha256_process(struct hash_state * md, const unsigned char *in, unsigned long inlen) in sha256_process() argument
140 if (md->sha256.curlen == 0 && inlen >= SHA256_BLOCKSIZE) { in sha256_process()
141 sha256_compress(md, in); in sha256_process()
142 md->sha256.length += SHA256_BLOCKSIZE * 8; in sha256_process()
146 n = MIN(inlen, (SHA256_BLOCKSIZE - md->sha256.curlen)); in sha256_process()
147 memcpy(md->sha256.buf + md->sha256.curlen, in, (size_t)n); in sha256_process()
148 md->sha256.curlen += n; in sha256_process()
151 if (md->sha256.curlen == SHA256_BLOCKSIZE) { in sha256_process()
152 sha256_compress(md, md->sha256.buf); in sha256_process()
153 md->sha256.length += 8*SHA256_BLOCKSIZE; in sha256_process()
154 md->sha256.curlen = 0; in sha256_process()
161 static void sha256_done(struct hash_state * md, unsigned char *out) in sha256_done() argument
166 md->sha256.length += md->sha256.curlen * 8; in sha256_done()
169 md->sha256.buf[md->sha256.curlen++] = (unsigned char)0x80; in sha256_done()
175 if (md->sha256.curlen > 56) { in sha256_done()
176 while (md->sha256.curlen < 64) { in sha256_done()
177 md->sha256.buf[md->sha256.curlen++] = (unsigned char)0; in sha256_done()
179 sha256_compress(md, md->sha256.buf); in sha256_done()
180 md->sha256.curlen = 0; in sha256_done()
184 while (md->sha256.curlen < 56) { in sha256_done()
185 md->sha256.buf[md->sha256.curlen++] = (unsigned char)0; in sha256_done()
189 STORE64H(md->sha256.length, md->sha256.buf+56); in sha256_done()
190 sha256_compress(md, md->sha256.buf); in sha256_done()
194 STORE32H(md->sha256.state[i], out+(4*i)); in sha256_done()
201 struct hash_state md; in ext2fs_sha256() local
203 sha256_init(&md); in ext2fs_sha256()
204 sha256_process(&md, in, in_size); in ext2fs_sha256()
205 sha256_done(&md, out); in ext2fs_sha256()