summaryrefslogtreecommitdiff
path: root/MPQCryptography.c
diff options
context:
space:
mode:
authoryazoo <yazoo>2008-01-29 07:43:06 +0000
committeryazoo <yazoo>2008-01-29 07:43:06 +0000
commit8522e44467ebcac54201def2c6583639e74e9e24 (patch)
tree9d475da6b178bf96359f06d39773441b76b8d567 /MPQCryptography.c
parent7ecf94d4b339bc2197f449f0f1538f2915313087 (diff)
Portage win32
Diffstat (limited to 'MPQCryptography.c')
-rw-r--r--MPQCryptography.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/MPQCryptography.c b/MPQCryptography.c
index 9791c0a..6c33e55 100644
--- a/MPQCryptography.c
+++ b/MPQCryptography.c
@@ -25,7 +25,12 @@
#endif
#include "MPQCryptography.h"
+
+#ifdef WIN32
+#include "stdint.h"
+#else
#include "inttypes.h"
+#endif
static int crypt_table_initialized = 0;
static uint32_t crypt_table[0x500];
@@ -88,13 +93,13 @@ void __mpqlib_init_cryptography()
void __mpqlib_encrypt(void *_data, uint32_t length, uint32_t key, bool disable_input_swapping)
{
- char * data = (char *) _data;
- assert(crypt_table_initialized);
- assert(data);
-
+ char * data = (char *) _data;
uint32_t *buffer32 = (uint32_t *) data;
uint32_t seed = 0xEEEEEEEE;
uint32_t ch;
+
+ assert(crypt_table_initialized);
+ assert(data);
// Round to 4 bytes
length = length / 4;
@@ -126,13 +131,13 @@ void __mpqlib_encrypt(void *_data, uint32_t length, uint32_t key, bool disable_i
void __mpqlib_decrypt(void *_data, uint32_t length, uint32_t key, bool disable_output_swapping)
{
char * data = (char *) _data;
- assert(crypt_table_initialized);
- assert(data);
-
uint32_t *buffer32 = (uint32_t *) data;
uint32_t seed = 0xEEEEEEEE;
uint32_t ch;
+ assert(crypt_table_initialized);
+ assert(data);
+
// Round to 4 bytes
length = length / 4;
@@ -166,14 +171,14 @@ void __mpqlib_decrypt(void *_data, uint32_t length, uint32_t key, bool disable_o
uint32_t __mpqlib_hash_cstring(const char *string, uint32_t type)
{
- assert(crypt_table_initialized);
- assert(string);
-
uint32_t seed1 = 0x7FED7FED;
uint32_t seed2 = 0xEEEEEEEE;
uint32_t shifted_type = (type << 8);
int32_t ch;
+ assert(crypt_table_initialized);
+ assert(string);
+
while (*string != 0) {
ch = *string++;
if (ch > 0x60 && ch < 0x7b)
@@ -188,14 +193,14 @@ uint32_t __mpqlib_hash_cstring(const char *string, uint32_t type)
uint32_t __mpqlib_hash_data(const char *data, uint32_t length, uint32_t type)
{
- assert(crypt_table_initialized);
- assert(data);
-
uint32_t seed1 = 0x7FED7FED;
uint32_t seed2 = 0xEEEEEEEE;
uint32_t shifted_type = (type << 8);
int32_t ch;
+ assert(crypt_table_initialized);
+ assert(data);
+
while (length > 0) {
ch = *data++;