Mercurial > hg > orthanc
comparison Resources/ThirdParty/minizip/crypt.h @ 3284:e583bbf6ec6c
upgraded minizip
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 21 Feb 2019 18:04:10 +0100 |
parents | 8811abd6aec9 |
children |
comparison
equal
deleted
inserted
replaced
3283:997db5b2ad50 | 3284:e583bbf6ec6c |
---|---|
30 #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) | 30 #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) |
31 | 31 |
32 /*********************************************************************** | 32 /*********************************************************************** |
33 * Return the next byte in the pseudo-random sequence | 33 * Return the next byte in the pseudo-random sequence |
34 */ | 34 */ |
35 static int decrypt_byte(unsigned long* pkeys, const unsigned long* pcrc_32_tab) | 35 static int decrypt_byte(unsigned long* pkeys, const z_crc_t* pcrc_32_tab) |
36 { | 36 { |
37 unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an | 37 unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an |
38 * unpredictable manner on 16-bit systems; not a problem | 38 * unpredictable manner on 16-bit systems; not a problem |
39 * with any known compiler so far, though */ | 39 * with any known compiler so far, though */ |
40 | 40 |
43 } | 43 } |
44 | 44 |
45 /*********************************************************************** | 45 /*********************************************************************** |
46 * Update the encryption keys with the next byte of plain text | 46 * Update the encryption keys with the next byte of plain text |
47 */ | 47 */ |
48 static int update_keys(unsigned long* pkeys,const unsigned long* pcrc_32_tab,int c) | 48 static int update_keys(unsigned long* pkeys,const z_crc_t* pcrc_32_tab,int c) |
49 { | 49 { |
50 (*(pkeys+0)) = CRC32((*(pkeys+0)), c); | 50 (*(pkeys+0)) = CRC32((*(pkeys+0)), c); |
51 (*(pkeys+1)) += (*(pkeys+0)) & 0xff; | 51 (*(pkeys+1)) += (*(pkeys+0)) & 0xff; |
52 (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; | 52 (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; |
53 { | 53 { |
60 | 60 |
61 /*********************************************************************** | 61 /*********************************************************************** |
62 * Initialize the encryption keys and the random header according to | 62 * Initialize the encryption keys and the random header according to |
63 * the given password. | 63 * the given password. |
64 */ | 64 */ |
65 static void init_keys(const char* passwd,unsigned long* pkeys,const unsigned long* pcrc_32_tab) | 65 static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t* pcrc_32_tab) |
66 { | 66 { |
67 *(pkeys+0) = 305419896L; | 67 *(pkeys+0) = 305419896L; |
68 *(pkeys+1) = 591751049L; | 68 *(pkeys+1) = 591751049L; |
69 *(pkeys+2) = 878082192L; | 69 *(pkeys+2) = 878082192L; |
70 while (*passwd != '\0') { | 70 while (*passwd != '\0') { |
89 | 89 |
90 static int crypthead(const char* passwd, /* password string */ | 90 static int crypthead(const char* passwd, /* password string */ |
91 unsigned char* buf, /* where to write header */ | 91 unsigned char* buf, /* where to write header */ |
92 int bufSize, | 92 int bufSize, |
93 unsigned long* pkeys, | 93 unsigned long* pkeys, |
94 const unsigned long* pcrc_32_tab, | 94 const z_crc_t* pcrc_32_tab, |
95 unsigned long crcForCrypting) | 95 unsigned long crcForCrypting) |
96 { | 96 { |
97 int n; /* index in random header */ | 97 int n; /* index in random header */ |
98 int t; /* temporary */ | 98 int t; /* temporary */ |
99 int c; /* random byte */ | 99 int c; /* random byte */ |