| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | /* SHA1 module */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* This module provides an interface to the SHA1 algorithm */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* See below for information about the original code this module was
 | 
					
						
							|  |  |  |    based upon. Additional work performed by: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Andrew Kuchling (amk@amk.ca) | 
					
						
							|  |  |  |    Greg Stein (gstein@lyra.org) | 
					
						
							|  |  |  |    Trevor Perrin (trevp@trevp.net) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Copyright (C) 2005-2007   Gregory P. Smith (greg@krypto.org) | 
					
						
							|  |  |  |    Licensed to PSF under a Contributor Agreement. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* SHA1 objects */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "Python.h"
 | 
					
						
							| 
									
										
										
										
											2009-02-12 07:35:29 +00:00
										 |  |  | #include "hashlib.h"
 | 
					
						
							| 
									
										
										
										
											2015-04-25 23:22:26 +00:00
										 |  |  | #include "pystrhex.h"
 | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | module _sha1 | 
					
						
							|  |  |  | class SHA1Type "SHA1object *" "&PyType_Type" | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | /*[clinic end generated code: output=da39a3ee5e6b4b0d input=3dc9a20d1becb759]*/ | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Some useful types */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #if SIZEOF_INT == 4
 | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  | typedef unsigned int SHA1_INT32;        /* 32-bit integer */ | 
					
						
							| 
									
										
										
										
											2016-09-06 10:46:49 -07:00
										 |  |  | typedef long long SHA1_INT64;        /* 64-bit integer */ | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | #else
 | 
					
						
							|  |  |  | /* not defined. compilation will die. */ | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* The SHA1 block size and message digest sizes, in bytes */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define SHA1_BLOCKSIZE    64
 | 
					
						
							|  |  |  | #define SHA1_DIGESTSIZE   20
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* The structure for storing SHA1 info */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct sha1_state { | 
					
						
							|  |  |  |     SHA1_INT64 length; | 
					
						
							|  |  |  |     SHA1_INT32 state[5], curlen; | 
					
						
							|  |  |  |     unsigned char buf[SHA1_BLOCKSIZE]; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct { | 
					
						
							|  |  |  |     PyObject_HEAD | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     struct sha1_state hash_state; | 
					
						
							|  |  |  | } SHA1object; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-03 23:53:51 +03:00
										 |  |  | #include "clinic/sha1module.c.h"
 | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* ------------------------------------------------------------------------
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This code for the SHA1 algorithm was noted as public domain. The | 
					
						
							|  |  |  |  * original headers are pasted below. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Several changes have been made to make it more compatible with the | 
					
						
							|  |  |  |  * Python environment and desired interface. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* LibTomCrypt, modular cryptographic library -- Tom St Denis
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * LibTomCrypt is a library that provides various cryptographic | 
					
						
							|  |  |  |  * algorithms in a highly modular and flexible manner. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The library is free for all purposes without any express | 
					
						
							|  |  |  |  * guarantee it works. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Tom St Denis, tomstdenis@gmail.com, http://libtom.org
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* rotate the hard way (platform optimizations could be done) */ | 
					
						
							|  |  |  | #define ROL(x, y) ( (((unsigned long)(x)<<(unsigned long)((y)&31)) | (((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL)
 | 
					
						
							|  |  |  | #define ROLc(x, y) ( (((unsigned long)(x)<<(unsigned long)((y)&31)) | (((unsigned long)(x)&0xFFFFFFFFUL)>>(unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Endian Neutral macros that work on all platforms */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define STORE32H(x, y)                                                                     \
 | 
					
						
							|  |  |  |      { (y)[0] = (unsigned char)(((x)>>24)&255); (y)[1] = (unsigned char)(((x)>>16)&255);   \ | 
					
						
							|  |  |  |        (y)[2] = (unsigned char)(((x)>>8)&255); (y)[3] = (unsigned char)((x)&255); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define LOAD32H(x, y)                            \
 | 
					
						
							|  |  |  |      { x = ((unsigned long)((y)[0] & 255)<<24) | \ | 
					
						
							|  |  |  |            ((unsigned long)((y)[1] & 255)<<16) | \ | 
					
						
							|  |  |  |            ((unsigned long)((y)[2] & 255)<<8)  | \ | 
					
						
							|  |  |  |            ((unsigned long)((y)[3] & 255)); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define STORE64H(x, y)                                                                     \
 | 
					
						
							|  |  |  |    { (y)[0] = (unsigned char)(((x)>>56)&255); (y)[1] = (unsigned char)(((x)>>48)&255);     \ | 
					
						
							|  |  |  |      (y)[2] = (unsigned char)(((x)>>40)&255); (y)[3] = (unsigned char)(((x)>>32)&255);     \ | 
					
						
							|  |  |  |      (y)[4] = (unsigned char)(((x)>>24)&255); (y)[5] = (unsigned char)(((x)>>16)&255);     \ | 
					
						
							|  |  |  |      (y)[6] = (unsigned char)(((x)>>8)&255); (y)[7] = (unsigned char)((x)&255); } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* SHA1 macros */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define F0(x,y,z)  (z ^ (x & (y ^ z)))
 | 
					
						
							|  |  |  | #define F1(x,y,z)  (x ^ y ^ z)
 | 
					
						
							|  |  |  | #define F2(x,y,z)  ((x & y) | (z & (x | y)))
 | 
					
						
							|  |  |  | #define F3(x,y,z)  (x ^ y ^ z)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void sha1_compress(struct sha1_state *sha1, unsigned char *buf) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SHA1_INT32 a,b,c,d,e,W[80],i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* copy the state into 512-bits into W[0..15] */ | 
					
						
							|  |  |  |     for (i = 0; i < 16; i++) { | 
					
						
							|  |  |  |         LOAD32H(W[i], buf + (4*i)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* copy state */ | 
					
						
							|  |  |  |     a = sha1->state[0]; | 
					
						
							|  |  |  |     b = sha1->state[1]; | 
					
						
							|  |  |  |     c = sha1->state[2]; | 
					
						
							|  |  |  |     d = sha1->state[3]; | 
					
						
							|  |  |  |     e = sha1->state[4]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* expand it */ | 
					
						
							|  |  |  |     for (i = 16; i < 80; i++) { | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         W[i] = ROL(W[i-3] ^ W[i-8] ^ W[i-14] ^ W[i-16], 1); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* compress */ | 
					
						
							|  |  |  |     /* round one */ | 
					
						
							| 
									
										
										
										
											2010-07-23 15:43:14 +00:00
										 |  |  |     #define FF_0(a,b,c,d,e,i) e = (ROLc(a, 5) + F0(b,c,d) + e + W[i] + 0x5a827999UL); b = ROLc(b, 30);
 | 
					
						
							|  |  |  |     #define FF_1(a,b,c,d,e,i) e = (ROLc(a, 5) + F1(b,c,d) + e + W[i] + 0x6ed9eba1UL); b = ROLc(b, 30);
 | 
					
						
							|  |  |  |     #define FF_2(a,b,c,d,e,i) e = (ROLc(a, 5) + F2(b,c,d) + e + W[i] + 0x8f1bbcdcUL); b = ROLc(b, 30);
 | 
					
						
							|  |  |  |     #define FF_3(a,b,c,d,e,i) e = (ROLc(a, 5) + F3(b,c,d) + e + W[i] + 0xca62c1d6UL); b = ROLc(b, 30);
 | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  |     for (i = 0; i < 20; ) { | 
					
						
							| 
									
										
										
										
											2010-07-23 15:43:14 +00:00
										 |  |  |        FF_0(a,b,c,d,e,i++); | 
					
						
							|  |  |  |        FF_0(e,a,b,c,d,i++); | 
					
						
							|  |  |  |        FF_0(d,e,a,b,c,i++); | 
					
						
							|  |  |  |        FF_0(c,d,e,a,b,i++); | 
					
						
							|  |  |  |        FF_0(b,c,d,e,a,i++); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* round two */ | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |     for (; i < 40; )  { | 
					
						
							| 
									
										
										
										
											2010-07-23 15:43:14 +00:00
										 |  |  |        FF_1(a,b,c,d,e,i++); | 
					
						
							|  |  |  |        FF_1(e,a,b,c,d,i++); | 
					
						
							|  |  |  |        FF_1(d,e,a,b,c,i++); | 
					
						
							|  |  |  |        FF_1(c,d,e,a,b,i++); | 
					
						
							|  |  |  |        FF_1(b,c,d,e,a,i++); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* round three */ | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |     for (; i < 60; )  { | 
					
						
							| 
									
										
										
										
											2010-07-23 15:43:14 +00:00
										 |  |  |        FF_2(a,b,c,d,e,i++); | 
					
						
							|  |  |  |        FF_2(e,a,b,c,d,i++); | 
					
						
							|  |  |  |        FF_2(d,e,a,b,c,i++); | 
					
						
							|  |  |  |        FF_2(c,d,e,a,b,i++); | 
					
						
							|  |  |  |        FF_2(b,c,d,e,a,i++); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* round four */ | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |     for (; i < 80; )  { | 
					
						
							| 
									
										
										
										
											2010-07-23 15:43:14 +00:00
										 |  |  |        FF_3(a,b,c,d,e,i++); | 
					
						
							|  |  |  |        FF_3(e,a,b,c,d,i++); | 
					
						
							|  |  |  |        FF_3(d,e,a,b,c,i++); | 
					
						
							|  |  |  |        FF_3(c,d,e,a,b,i++); | 
					
						
							|  |  |  |        FF_3(b,c,d,e,a,i++); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-23 15:43:14 +00:00
										 |  |  |     #undef FF_0
 | 
					
						
							|  |  |  |     #undef FF_1
 | 
					
						
							|  |  |  |     #undef FF_2
 | 
					
						
							|  |  |  |     #undef FF_3
 | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     /* store */ | 
					
						
							|  |  |  |     sha1->state[0] = sha1->state[0] + a; | 
					
						
							|  |  |  |     sha1->state[1] = sha1->state[1] + b; | 
					
						
							|  |  |  |     sha1->state[2] = sha1->state[2] + c; | 
					
						
							|  |  |  |     sha1->state[3] = sha1->state[3] + d; | 
					
						
							|  |  |  |     sha1->state[4] = sha1->state[4] + e; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |    Initialize the hash state | 
					
						
							|  |  |  |    @param sha1   The hash state you wish to initialize | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2012-06-21 17:05:50 +02:00
										 |  |  | static void | 
					
						
							|  |  |  | sha1_init(struct sha1_state *sha1) | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | { | 
					
						
							|  |  |  |    assert(sha1 != NULL); | 
					
						
							|  |  |  |    sha1->state[0] = 0x67452301UL; | 
					
						
							|  |  |  |    sha1->state[1] = 0xefcdab89UL; | 
					
						
							|  |  |  |    sha1->state[2] = 0x98badcfeUL; | 
					
						
							|  |  |  |    sha1->state[3] = 0x10325476UL; | 
					
						
							|  |  |  |    sha1->state[4] = 0xc3d2e1f0UL; | 
					
						
							|  |  |  |    sha1->curlen = 0; | 
					
						
							|  |  |  |    sha1->length = 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |    Process a block of memory though the hash | 
					
						
							|  |  |  |    @param sha1   The hash state | 
					
						
							|  |  |  |    @param in     The data to hash | 
					
						
							|  |  |  |    @param inlen  The length of the data (octets) | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2012-06-21 17:05:50 +02:00
										 |  |  | static void | 
					
						
							|  |  |  | sha1_process(struct sha1_state *sha1, | 
					
						
							| 
									
										
										
										
											2011-01-04 12:59:15 +00:00
										 |  |  |                   const unsigned char *in, Py_ssize_t inlen) | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-01-04 12:59:15 +00:00
										 |  |  |     Py_ssize_t n; | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     assert(sha1 != NULL); | 
					
						
							|  |  |  |     assert(in != NULL); | 
					
						
							|  |  |  |     assert(sha1->curlen <= sizeof(sha1->buf)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     while (inlen > 0) { | 
					
						
							|  |  |  |         if (sha1->curlen == 0 && inlen >= SHA1_BLOCKSIZE) { | 
					
						
							|  |  |  |            sha1_compress(sha1, (unsigned char *)in); | 
					
						
							|  |  |  |            sha1->length   += SHA1_BLOCKSIZE * 8; | 
					
						
							|  |  |  |            in             += SHA1_BLOCKSIZE; | 
					
						
							|  |  |  |            inlen          -= SHA1_BLOCKSIZE; | 
					
						
							|  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2013-06-04 23:14:37 +02:00
										 |  |  |            n = Py_MIN(inlen, (Py_ssize_t)(SHA1_BLOCKSIZE - sha1->curlen)); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  |            memcpy(sha1->buf + sha1->curlen, in, (size_t)n); | 
					
						
							| 
									
										
										
										
											2012-10-31 00:33:57 +01:00
										 |  |  |            sha1->curlen   += (SHA1_INT32)n; | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  |            in             += n; | 
					
						
							|  |  |  |            inlen          -= n; | 
					
						
							|  |  |  |            if (sha1->curlen == SHA1_BLOCKSIZE) { | 
					
						
							|  |  |  |               sha1_compress(sha1, sha1->buf); | 
					
						
							|  |  |  |               sha1->length += 8*SHA1_BLOCKSIZE; | 
					
						
							|  |  |  |               sha1->curlen = 0; | 
					
						
							|  |  |  |            } | 
					
						
							|  |  |  |        } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |    Terminate the hash to get the digest | 
					
						
							|  |  |  |    @param sha1  The hash state | 
					
						
							|  |  |  |    @param out [out] The destination of the hash (20 bytes) | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2012-06-21 17:05:50 +02:00
										 |  |  | static void | 
					
						
							|  |  |  | sha1_done(struct sha1_state *sha1, unsigned char *out) | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     int i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     assert(sha1 != NULL); | 
					
						
							|  |  |  |     assert(out != NULL); | 
					
						
							|  |  |  |     assert(sha1->curlen < sizeof(sha1->buf)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* increase the length of the message */ | 
					
						
							|  |  |  |     sha1->length += sha1->curlen * 8; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* append the '1' bit */ | 
					
						
							|  |  |  |     sha1->buf[sha1->curlen++] = (unsigned char)0x80; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* if the length is currently above 56 bytes we append zeros
 | 
					
						
							|  |  |  |      * then compress.  Then we can fall back to padding zeros and length | 
					
						
							|  |  |  |      * encoding like normal. | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     if (sha1->curlen > 56) { | 
					
						
							|  |  |  |         while (sha1->curlen < 64) { | 
					
						
							|  |  |  |             sha1->buf[sha1->curlen++] = (unsigned char)0; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         sha1_compress(sha1, sha1->buf); | 
					
						
							|  |  |  |         sha1->curlen = 0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* pad upto 56 bytes of zeroes */ | 
					
						
							|  |  |  |     while (sha1->curlen < 56) { | 
					
						
							|  |  |  |         sha1->buf[sha1->curlen++] = (unsigned char)0; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* store length */ | 
					
						
							|  |  |  |     STORE64H(sha1->length, sha1->buf+56); | 
					
						
							|  |  |  |     sha1_compress(sha1, sha1->buf); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* copy output */ | 
					
						
							|  |  |  |     for (i = 0; i < 5; i++) { | 
					
						
							|  |  |  |         STORE32H(sha1->state[i], out+(4*i)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* .Source: /cvs/libtom/libtomcrypt/src/hashes/sha1.c,v $ */ | 
					
						
							|  |  |  | /* .Revision: 1.10 $ */ | 
					
						
							|  |  |  | /* .Date: 2007/05/12 14:25:28 $ */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * End of copied SHA1 code. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ------------------------------------------------------------------------ | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  | typedef struct { | 
					
						
							|  |  |  |     PyTypeObject* sha1_type; | 
					
						
							|  |  |  | } SHA1State; | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  | static inline SHA1State* | 
					
						
							|  |  |  | sha1_get_state(PyObject *module) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     void *state = PyModule_GetState(module); | 
					
						
							|  |  |  |     assert(state != NULL); | 
					
						
							|  |  |  |     return (SHA1State *)state; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | static SHA1object * | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  | newSHA1object(SHA1State *st) | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  |     return (SHA1object *)PyObject_New(SHA1object, st->sha1_type); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Internal methods for a hash object */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | SHA1_dealloc(PyObject *ptr) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  |     PyTypeObject *tp = Py_TYPE(ptr); | 
					
						
							| 
									
										
										
										
											2020-12-01 10:37:39 +01:00
										 |  |  |     PyObject_Free(ptr); | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  |     Py_DECREF(tp); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* External methods for a hash object */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | SHA1Type.copy | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  |     cls: defining_class | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  | Return a copy of the hash object. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  | SHA1Type_copy_impl(SHA1object *self, PyTypeObject *cls) | 
					
						
							|  |  |  | /*[clinic end generated code: output=b32d4461ce8bc7a7 input=6c22e66fcc34c58e]*/ | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  |     SHA1State *st = PyType_GetModuleState(cls); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  |     SHA1object *newobj; | 
					
						
							|  |  |  |     if ((newobj = newSHA1object(st)) == NULL) | 
					
						
							| 
									
										
										
										
											2013-04-15 21:38:25 -04:00
										 |  |  |         return NULL; | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     newobj->hash_state = self->hash_state; | 
					
						
							|  |  |  |     return (PyObject *)newobj; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | SHA1Type.digest | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-19 23:12:53 +05:30
										 |  |  | Return the digest value as a bytes object. | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | SHA1Type_digest_impl(SHA1object *self) | 
					
						
							| 
									
										
										
										
											2018-10-19 23:12:53 +05:30
										 |  |  | /*[clinic end generated code: output=2f05302a7aa2b5cb input=13824b35407444bd]*/ | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     unsigned char digest[SHA1_DIGESTSIZE]; | 
					
						
							|  |  |  |     struct sha1_state temp; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     temp = self->hash_state; | 
					
						
							|  |  |  |     sha1_done(&temp, digest); | 
					
						
							| 
									
										
										
										
											2008-05-26 13:28:38 +00:00
										 |  |  |     return PyBytes_FromStringAndSize((const char *)digest, SHA1_DIGESTSIZE); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | SHA1Type.hexdigest | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Return the digest value as a string of hexadecimal digits. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | SHA1Type_hexdigest_impl(SHA1object *self) | 
					
						
							| 
									
										
										
										
											2015-04-03 23:53:51 +03:00
										 |  |  | /*[clinic end generated code: output=4161fd71e68c6659 input=97691055c0c74ab0]*/ | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     unsigned char digest[SHA1_DIGESTSIZE]; | 
					
						
							|  |  |  |     struct sha1_state temp; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Get the raw (binary) digest value */ | 
					
						
							|  |  |  |     temp = self->hash_state; | 
					
						
							|  |  |  |     sha1_done(&temp, digest); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-25 23:22:26 +00:00
										 |  |  |     return _Py_strhex((const char *)digest, SHA1_DIGESTSIZE); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | SHA1Type.update | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     obj: object | 
					
						
							|  |  |  |     / | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Update this hash object's state with the provided string. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  | SHA1Type_update(SHA1object *self, PyObject *obj) | 
					
						
							| 
									
										
										
										
											2015-04-03 23:53:51 +03:00
										 |  |  | /*[clinic end generated code: output=d9902f0e5015e9ae input=aad8e07812edbba3]*/ | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2008-08-14 15:52:23 +00:00
										 |  |  |     Py_buffer buf; | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-12 07:35:29 +00:00
										 |  |  |     GET_BUFFER_VIEW_OR_ERROUT(obj, &buf); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-14 15:52:23 +00:00
										 |  |  |     sha1_process(&self->hash_state, buf.buf, buf.len); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-14 15:52:23 +00:00
										 |  |  |     PyBuffer_Release(&buf); | 
					
						
							| 
									
										
										
										
											2017-01-23 09:47:21 +02:00
										 |  |  |     Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyMethodDef SHA1_methods[] = { | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  |     SHA1TYPE_COPY_METHODDEF | 
					
						
							|  |  |  |     SHA1TYPE_DIGEST_METHODDEF | 
					
						
							|  |  |  |     SHA1TYPE_HEXDIGEST_METHODDEF | 
					
						
							|  |  |  |     SHA1TYPE_UPDATE_METHODDEF | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |     {NULL,        NULL}         /* sentinel */ | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | SHA1_get_block_size(PyObject *self, void *closure) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2007-12-02 14:31:20 +00:00
										 |  |  |     return PyLong_FromLong(SHA1_BLOCKSIZE); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | SHA1_get_name(PyObject *self, void *closure) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-08-15 18:31:48 +02:00
										 |  |  |     return PyUnicode_FromStringAndSize("sha1", 4); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							|  |  |  | sha1_get_digest_size(PyObject *self, void *closure) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2007-12-02 14:31:20 +00:00
										 |  |  |     return PyLong_FromLong(SHA1_DIGESTSIZE); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyGetSetDef SHA1_getseters[] = { | 
					
						
							|  |  |  |     {"block_size", | 
					
						
							|  |  |  |      (getter)SHA1_get_block_size, NULL, | 
					
						
							|  |  |  |      NULL, | 
					
						
							|  |  |  |      NULL}, | 
					
						
							|  |  |  |     {"name", | 
					
						
							|  |  |  |      (getter)SHA1_get_name, NULL, | 
					
						
							|  |  |  |      NULL, | 
					
						
							|  |  |  |      NULL}, | 
					
						
							|  |  |  |     {"digest_size", | 
					
						
							|  |  |  |      (getter)sha1_get_digest_size, NULL, | 
					
						
							|  |  |  |      NULL, | 
					
						
							|  |  |  |      NULL}, | 
					
						
							|  |  |  |     {NULL}  /* Sentinel */ | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  | static PyType_Slot sha1_type_slots[] = { | 
					
						
							|  |  |  |     {Py_tp_dealloc, SHA1_dealloc}, | 
					
						
							|  |  |  |     {Py_tp_methods, SHA1_methods}, | 
					
						
							|  |  |  |     {Py_tp_getset, SHA1_getseters}, | 
					
						
							|  |  |  |     {0,0} | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  | static PyType_Spec sha1_type_spec = { | 
					
						
							|  |  |  |     .name = "_sha1.sha1", | 
					
						
							|  |  |  |     .basicsize =  sizeof(SHA1object), | 
					
						
							|  |  |  |     .flags = Py_TPFLAGS_DEFAULT, | 
					
						
							|  |  |  |     .slots = sha1_type_slots | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* The single module-level function: new() */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  | /*[clinic input]
 | 
					
						
							|  |  |  | _sha1.sha1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     string: object(c_default="NULL") = b'' | 
					
						
							| 
									
										
										
										
											2019-09-13 02:30:00 +02:00
										 |  |  |     * | 
					
						
							|  |  |  |     usedforsecurity: bool = True | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | Return a new SHA1 hash object; optionally initialized with a string. | 
					
						
							|  |  |  | [clinic start generated code]*/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject * | 
					
						
							| 
									
										
										
										
											2019-09-13 02:30:00 +02:00
										 |  |  | _sha1_sha1_impl(PyObject *module, PyObject *string, int usedforsecurity) | 
					
						
							|  |  |  | /*[clinic end generated code: output=6f8b3af05126e18e input=bd54b68e2bf36a8a]*/ | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | { | 
					
						
							|  |  |  |     SHA1object *new; | 
					
						
							| 
									
										
										
										
											2008-08-14 15:52:23 +00:00
										 |  |  |     Py_buffer buf; | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  |     if (string) | 
					
						
							|  |  |  |         GET_BUFFER_VIEW_OR_ERROUT(string, &buf); | 
					
						
							| 
									
										
										
										
											2009-02-12 07:35:29 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  |     SHA1State *st = sha1_get_state(module); | 
					
						
							|  |  |  |     if ((new = newSHA1object(st)) == NULL) { | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  |         if (string) | 
					
						
							| 
									
										
										
										
											2009-03-03 07:49:01 +00:00
										 |  |  |             PyBuffer_Release(&buf); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  |         return NULL; | 
					
						
							| 
									
										
										
										
											2009-03-03 07:49:01 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     sha1_init(&new->hash_state); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (PyErr_Occurred()) { | 
					
						
							|  |  |  |         Py_DECREF(new); | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  |         if (string) | 
					
						
							| 
									
										
										
										
											2009-03-03 07:49:01 +00:00
										 |  |  |             PyBuffer_Release(&buf); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  |         return NULL; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  |     if (string) { | 
					
						
							| 
									
										
										
										
											2008-08-14 15:52:23 +00:00
										 |  |  |         sha1_process(&new->hash_state, buf.buf, buf.len); | 
					
						
							| 
									
										
										
										
											2009-03-03 07:49:01 +00:00
										 |  |  |         PyBuffer_Release(&buf); | 
					
						
							| 
									
										
										
										
											2008-08-14 15:52:23 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return (PyObject *)new; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* List of functions exported by this module */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct PyMethodDef SHA1_functions[] = { | 
					
						
							| 
									
										
										
										
											2014-07-27 14:20:23 +02:00
										 |  |  |     _SHA1_SHA1_METHODDEF | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |     {NULL,      NULL}            /* Sentinel */ | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  | static int | 
					
						
							|  |  |  | _sha1_traverse(PyObject *module, visitproc visit, void *arg) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SHA1State *state = sha1_get_state(module); | 
					
						
							|  |  |  |     Py_VISIT(state->sha1_type); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int | 
					
						
							|  |  |  | _sha1_clear(PyObject *module) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SHA1State *state = sha1_get_state(module); | 
					
						
							|  |  |  |     Py_CLEAR(state->sha1_type); | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void | 
					
						
							|  |  |  | _sha1_free(void *module) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     _sha1_clear((PyObject *)module); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int | 
					
						
							|  |  |  | _sha1_exec(PyObject *module) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     SHA1State* st = sha1_get_state(module); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     st->sha1_type = (PyTypeObject *)PyType_FromModuleAndSpec( | 
					
						
							|  |  |  |         module, &sha1_type_spec, NULL); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (st->sha1_type == NULL) { | 
					
						
							|  |  |  |         return -1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     Py_INCREF(st->sha1_type); | 
					
						
							|  |  |  |     if (PyModule_AddObject(module,  | 
					
						
							|  |  |  |                            "SHA1Type", | 
					
						
							|  |  |  |                            (PyObject *)st->sha1_type) < 0) { | 
					
						
							|  |  |  |         Py_DECREF(st->sha1_type); | 
					
						
							|  |  |  |         return -1; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Initialize this module. */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  | static PyModuleDef_Slot _sha1_slots[] = { | 
					
						
							|  |  |  |     {Py_mod_exec, _sha1_exec}, | 
					
						
							|  |  |  |     {0, NULL} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-11 05:26:20 +00:00
										 |  |  | static struct PyModuleDef _sha1module = { | 
					
						
							| 
									
										
										
										
											2010-05-09 15:52:27 +00:00
										 |  |  |         PyModuleDef_HEAD_INIT, | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  |         .m_name = "_sha1", | 
					
						
							|  |  |  |         .m_size = sizeof(SHA1State), | 
					
						
							|  |  |  |         .m_methods = SHA1_functions, | 
					
						
							|  |  |  |         .m_slots = _sha1_slots, | 
					
						
							|  |  |  |         .m_traverse = _sha1_traverse, | 
					
						
							|  |  |  |         .m_clear = _sha1_clear, | 
					
						
							|  |  |  |         .m_free = _sha1_free | 
					
						
							| 
									
										
										
										
											2008-06-11 05:26:20 +00:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | PyMODINIT_FUNC | 
					
						
							| 
									
										
										
										
											2008-06-11 05:26:20 +00:00
										 |  |  | PyInit__sha1(void) | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2020-09-06 05:09:51 -05:00
										 |  |  |     return PyModuleDef_Init(&_sha1module); | 
					
						
							| 
									
										
										
										
											2007-09-09 06:44:34 +00:00
										 |  |  | } |