Workaround for lame compiler bug introduced in "CPU pack" for MSVC6SP5.
[openssl.git] / crypto / aes / aes_core.c
index a9bc1c0de41f35067c683c8ea50d7f00bf65abd2..2f41a825f8d95b8864734d8f81fc850ed41a973d 100644 (file)
 /* Note: rewritten a little bit to provide error control and an OpenSSL-
    compatible API */
 
+#ifndef AES_DEBUG
+# ifndef NDEBUG
+#  define NDEBUG
+# endif
+#endif
 #include <assert.h>
+
 #include <stdlib.h>
 #include <openssl/aes.h>
 #include "aes_locl.h"
@@ -715,16 +721,6 @@ static const u32 rcon[] = {
        0x1B000000, 0x36000000, /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
 };
 
-#define SWAP(x) (_lrotl(x, 8) & 0x00ff00ff | _lrotr(x, 8) & 0xff00ff00)
-
-#ifdef _MSC_VER
-#define GETU32(p) SWAP(*((u32 *)(p)))
-#define PUTU32(ct, st) { *((u32 *)(ct)) = SWAP((st)); }
-#else
-#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ ((u32)(pt)[2] <<  8) ^ ((u32)(pt)[3]))
-#define PUTU32(ct, st) { (ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); (ct)[2] = (u8)((st) >>  8); (ct)[3] = (u8)(st); }
-#endif
-
 /**
  * Expand the cipher key into the encryption key schedule.
  */
@@ -754,7 +750,7 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
        rk[2] = GETU32(userKey +  8);
        rk[3] = GETU32(userKey + 12);
        if (bits == 128) {
-               for (;;) {
+               while (1) {
                        temp  = rk[3];
                        rk[4] = rk[0] ^
                                (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
@@ -774,7 +770,7 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
        rk[4] = GETU32(userKey + 16);
        rk[5] = GETU32(userKey + 20);
        if (bits == 192) {
-               for (;;) {
+               while (1) {
                        temp = rk[ 5];
                        rk[ 6] = rk[ 0] ^
                                (Te4[(temp >> 16) & 0xff] & 0xff000000) ^
@@ -796,7 +792,7 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
        rk[6] = GETU32(userKey + 24);
        rk[7] = GETU32(userKey + 28);
        if (bits == 256) {
-               for (;;) {
+               while (1) {
                        temp = rk[ 7];
                        rk[ 8] = rk[ 0] ^
                                (Te4[(temp >> 16) & 0xff] & 0xff000000) ^