Lines Matching refs:sha1

110 static void sha1_compress(struct sha1_state *sha1, unsigned char *buf)  in sha1_compress()  argument
120 a = sha1->state[0]; in sha1_compress()
121 b = sha1->state[1]; in sha1_compress()
122 c = sha1->state[2]; in sha1_compress()
123 d = sha1->state[3]; in sha1_compress()
124 e = sha1->state[4]; in sha1_compress()
179 sha1->state[0] = sha1->state[0] + a; in sha1_compress()
180 sha1->state[1] = sha1->state[1] + b; in sha1_compress()
181 sha1->state[2] = sha1->state[2] + c; in sha1_compress()
182 sha1->state[3] = sha1->state[3] + d; in sha1_compress()
183 sha1->state[4] = sha1->state[4] + e; in sha1_compress()
191 sha1_init(struct sha1_state *sha1) in sha1_init() argument
193 assert(sha1 != NULL); in sha1_init()
194 sha1->state[0] = 0x67452301UL; in sha1_init()
195 sha1->state[1] = 0xefcdab89UL; in sha1_init()
196 sha1->state[2] = 0x98badcfeUL; in sha1_init()
197 sha1->state[3] = 0x10325476UL; in sha1_init()
198 sha1->state[4] = 0xc3d2e1f0UL; in sha1_init()
199 sha1->curlen = 0; in sha1_init()
200 sha1->length = 0; in sha1_init()
210 sha1_process(struct sha1_state *sha1, in sha1_process() argument
215 assert(sha1 != NULL); in sha1_process()
217 assert(sha1->curlen <= sizeof(sha1->buf)); in sha1_process()
220 if (sha1->curlen == 0 && inlen >= SHA1_BLOCKSIZE) { in sha1_process()
221 sha1_compress(sha1, (unsigned char *)in); in sha1_process()
222 sha1->length += SHA1_BLOCKSIZE * 8; in sha1_process()
226 n = Py_MIN(inlen, (Py_ssize_t)(SHA1_BLOCKSIZE - sha1->curlen)); in sha1_process()
227 memcpy(sha1->buf + sha1->curlen, in, (size_t)n); in sha1_process()
228 sha1->curlen += (SHA1_INT32)n; in sha1_process()
231 if (sha1->curlen == SHA1_BLOCKSIZE) { in sha1_process()
232 sha1_compress(sha1, sha1->buf); in sha1_process()
233 sha1->length += 8*SHA1_BLOCKSIZE; in sha1_process()
234 sha1->curlen = 0; in sha1_process()
246 sha1_done(struct sha1_state *sha1, unsigned char *out) in sha1_done() argument
250 assert(sha1 != NULL); in sha1_done()
252 assert(sha1->curlen < sizeof(sha1->buf)); in sha1_done()
255 sha1->length += sha1->curlen * 8; in sha1_done()
258 sha1->buf[sha1->curlen++] = (unsigned char)0x80; in sha1_done()
264 if (sha1->curlen > 56) { in sha1_done()
265 while (sha1->curlen < 64) { in sha1_done()
266 sha1->buf[sha1->curlen++] = (unsigned char)0; in sha1_done()
268 sha1_compress(sha1, sha1->buf); in sha1_done()
269 sha1->curlen = 0; in sha1_done()
273 while (sha1->curlen < 56) { in sha1_done()
274 sha1->buf[sha1->curlen++] = (unsigned char)0; in sha1_done()
278 STORE64H(sha1->length, sha1->buf+56); in sha1_done()
279 sha1_compress(sha1, sha1->buf); in sha1_done()
283 STORE32H(sha1->state[i], out+(4*i)); in sha1_done()