"...Irrlicht/svn:/svn.code.sf.net/p/irrlicht/code/trunk@3208" did not exist on "8f5a1f6f23fefd5b84b889f60a500099b06d452c"
Commit fb49e30c authored by cutealien's avatar cutealien

Fix zip's with passwords on 64-bit systems (thx @ Dr. Gladman for writing the bugfix)


git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4135 dfc29bdd-3216-0410-991c-e03cc46cb475
parent ca65ea3b
......@@ -29,10 +29,12 @@
and/or fitness for purpose.
---------------------------------------------------------------------------
Issue Date: 26/08/2003
Includes a bugfix from Dr Brian Gladman made on 16/04/2012 for compiling on 64-bit
This is an implementation of HMAC, the FIPS standard keyed hash function
*/
#include "hmac.h"
/* initialise the HMAC context to zero */
......@@ -81,8 +83,8 @@ void hmac_sha_data(const unsigned char data[], unsigned long data_len, hmac_ctx
memset(cx->key + cx->klen, 0, HASH_INPUT_SIZE - cx->klen);
/* xor ipad into key value */
for(i = 0; i < (HASH_INPUT_SIZE >> 2); ++i)
((unsigned long*)cx->key)[i] ^= 0x36363636;
for(i = 0; i < HASH_INPUT_SIZE / sizeof(unsigned long); ++i)
((unsigned long*)cx->key)[i] ^= IPAD;
/* and start hash operation */
sha_begin(cx->ctx);
......@@ -109,8 +111,8 @@ void hmac_sha_end(unsigned char mac[], unsigned long mac_len, hmac_ctx cx[1])
sha_end(dig, cx->ctx); /* complete the inner hash */
/* set outer key value using opad and removing ipad */
for(i = 0; i < (HASH_INPUT_SIZE >> 2); ++i)
((unsigned long*)cx->key)[i] ^= 0x36363636 ^ 0x5c5c5c5c;
for(i = 0; i < HASH_INPUT_SIZE / sizeof(unsigned long); ++i)
((unsigned long*)cx->key)[i] ^= OPAD ^ IPAD;
/* perform the outer hash operation */
sha_begin(cx->ctx);
......
......@@ -29,6 +29,7 @@
and/or fitness for purpose.
---------------------------------------------------------------------------
Issue Date: 26/08/2003
Includes a bugfix from Dr Brian Gladman made on 16/04/2012 for compiling on 64-bit
This is an implementation of HMAC, the FIPS standard keyed hash function
*/
......@@ -38,7 +39,7 @@
#include <memory.h>
#define USE_SHA1
#define USE_SHA1 // Irrlicht only cares about SHA1 for now
#if !defined(USE_SHA1) && !defined(USE_SHA256)
#error define USE_SHA1 or USE_SHA256 to set the HMAC hash algorithm
#endif
......@@ -73,9 +74,11 @@
#define HMAC_BAD_MODE -1
#define HMAC_IN_DATA 0xffffffff
#define IPAD (0x36 * (((unsigned long)-1) / 0xff))
#define OPAD (0x5c * (((unsigned long)-1) / 0xff))
typedef struct
{
unsigned char key[HASH_INPUT_SIZE];
{ unsigned char key[HASH_INPUT_SIZE];
sha_ctx ctx[1];
unsigned long klen;
} hmac_ctx;
......@@ -93,4 +96,3 @@ void hmac_sha(const unsigned char key[], unsigned long key_len,
unsigned char mac[], unsigned long mac_len);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment