Permalink
Browse files

64 bit linux patches from pantufas and David

  • Loading branch information...
1 parent a12727a commit b607c309476dc5474c8761c1512a2d40ecec7814 @kwiirk committed Jun 17, 2009
Showing with 19 additions and 6 deletions.
  1. +3 −0 Makefile
  2. +12 −2 libwbfs/libwbfs_unix.c
  3. +4 −4 libwbfs/rijndael.c
View
@@ -6,7 +6,10 @@ LIBS = -lcrypto
CC = gcc
CFLAGS = -Wall -W -O3 -Ilibwbfs -I.
#CFLAGS = -Wall -m32 -W -ggdb -Ilibwbfs -I.
+
+# manually switch flags if you are on amd64 (should test that in makefile)
LDFLAGS = -m32
+#LDFLAGS = -m64 -L/usr/lib64
VPATH+=libwbfs
OBJS = $(patsubst %,%.o,$(PROGS)) $(COMMON)
View
@@ -126,7 +126,12 @@ static int get_capacity(char *file,u32 *sector_size,u32 *n_sector)
return 0;
}
#if defined(__linux__) || defined(__CYGWIN__)
- ret = ioctl(fd,BLKSSZGET,sector_size);
+ if (sizeof(void *) == 8) {
+ unsigned long long sec_size;
+ ret = ioctl(fd,BLKSSZGET,&sec_size);
+ *sector_size = (unsigned int) sec_size;
+ } else
+ ret = ioctl(fd,BLKSSZGET,sector_size);
#else //__APPLE__
ret = ioctl(fd,DKIOCGETBLOCKSIZE,sector_size);
#endif
@@ -142,7 +147,12 @@ static int get_capacity(char *file,u32 *sector_size,u32 *n_sector)
return 1;
}
#if defined(__linux__) || defined(__CYGWIN__)
- ret = ioctl(fd,BLKGETSIZE,n_sector);
+ if (sizeof(void *) == 8) {
+ unsigned long long n_sec;
+ ret = ioctl(fd,BLKGETSIZE,&n_sec);
+ *n_sector = (unsigned int) n_sec;
+ } else
+ ret = ioctl(fd,BLKGETSIZE,n_sector);
#else //__APPLE__
long long my_n_sector;
ret = ioctl(fd,DKIOCGETBLOCKCOUNT,&my_n_sector);
View
@@ -270,7 +270,7 @@ void encrypt(char *buff)
y[j]=fkey[k++]^ftable[(u8)x[j]]^
ROTL8(ftable[(u8)(x[fi[m]]>>8)])^
ROTL16(ftable[(u8)(x[fi[m+1]]>>16)])^
- ROTL24(ftable[x[fi[m+2]]>>24]);
+ ROTL24(ftable[(u8)(x[fi[m+2]]>>24)]);
}
t=x; x=y; y=t; /* swap pointers */
}
@@ -281,7 +281,7 @@ void encrypt(char *buff)
y[j]=fkey[k++]^(u32)fbsub[(u8)x[j]]^
ROTL8((u32)fbsub[(u8)(x[fi[m]]>>8)])^
ROTL16((u32)fbsub[(u8)(x[fi[m+1]]>>16)])^
- ROTL24((u32)fbsub[x[fi[m+2]]>>24]);
+ ROTL24((u32)fbsub[(u8)(x[fi[m+2]]>>24)]);
}
for (i=j=0;i<Nb;i++,j+=4)
{
@@ -316,7 +316,7 @@ void decrypt(char *buff)
y[j]=rkey[k++]^rtable[(u8)x[j]]^
ROTL8(rtable[(u8)(x[ri[m]]>>8)])^
ROTL16(rtable[(u8)(x[ri[m+1]]>>16)])^
- ROTL24(rtable[x[ri[m+2]]>>24]);
+ ROTL24(rtable[(u8)(x[ri[m+2]]>>24)]);
}
t=x; x=y; y=t; /* swap pointers */
}
@@ -327,7 +327,7 @@ void decrypt(char *buff)
y[j]=rkey[k++]^(u32)rbsub[(u8)x[j]]^
ROTL8((u32)rbsub[(u8)(x[ri[m]]>>8)])^
ROTL16((u32)rbsub[(u8)(x[ri[m+1]]>>16)])^
- ROTL24((u32)rbsub[x[ri[m+2]]>>24]);
+ ROTL24((u32)rbsub[(u8)(x[ri[m+2]]>>24)]);
}
for (i=j=0;i<Nb;i++,j+=4)
{

0 comments on commit b607c30

Please sign in to comment.