From 52001875cf7be0f45f015a09bb98d9e07373a9d0 Mon Sep 17 00:00:00 2001 From: Nikola Pavlica Date: Fri, 12 Oct 2018 17:45:09 +0200 Subject: [PATCH] non-x86 support --- resign_linux.sh | 0 source/src/Makefile | 15 +++++++++++++-- source/src/cputype.h | 3 +++ source/src/main.cpp | 13 +++++++++++-- 4 files changed, 27 insertions(+), 4 deletions(-) mode change 100644 => 100755 resign_linux.sh create mode 100644 source/src/cputype.h diff --git a/resign_linux.sh b/resign_linux.sh old mode 100644 new mode 100755 diff --git a/source/src/Makefile b/source/src/Makefile index 4e41853..e27cbea 100644 --- a/source/src/Makefile +++ b/source/src/Makefile @@ -2,10 +2,22 @@ CC=g++ CFLAGS=-pipe -fvisibility=hidden -D_GNU_SOURCE -O3 -static -D_FILE_OFFSET_BITS=64 OS_TARGET=ps3xploit_rifgen_edatresign LDFLAGS=-lcrypto -lssl -OBJS=aes.o aes_omac.o main.o sha1.o util.o pkg2zip_aes.o pkg2zip_aes_x86.o +OBJS=aes.o aes_omac.o main.o sha1.o util.o pkg2zip_aes.o .SILENT: .SUFFIXES: .c .cpp .o +uname_m := $(shell uname -m) + +ifeq ($(uname_m),i386) +OBJS += pkg2zip_aes_x86.o +endif +ifeq ($(uname_m),i686) +OBJS += pkg2zip_aes_x86.o +endif +ifeq ($(uname_m),x86_64) +OBJS += pkg2zip_aes_x86.o +endif + $(OS_TARGET): $(OBJS) ${LINK} if $(CC) $(CFLAGS) $(OBJS) -o $(OS_TARGET) $(LDFLAGS) $(LIBS); then \ @@ -13,7 +25,6 @@ $(OS_TARGET): $(OBJS) else \ ${LINK_FAILED}; \ fi - %aes_x86.o: %aes_x86.c @echo [C] $< diff --git a/source/src/cputype.h b/source/src/cputype.h new file mode 100644 index 0000000..f6171d1 --- /dev/null +++ b/source/src/cputype.h @@ -0,0 +1,3 @@ +#if defined(__i386__)||defined(_M_X86) + #define X86CPU +#endif diff --git a/source/src/main.cpp b/source/src/main.cpp index ad34337..5adf785 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -14,6 +14,7 @@ #define ACT_DAT_KEYBITS 128 #define RIF_KEYBITS 128 #define RAP_KEYBITS 128 +#include "cputype.h" #include "aes.h" #include "util.h" #include "sha1.h" @@ -1041,7 +1042,9 @@ static inline void wbe64(u8 *p, u64 v) } #include -#include "pkg2zip_aes_x86.h" +#ifdef X86CPU + #include "pkg2zip_aes_x86.h" +#endif static void decrypt_debug_pkg_normal(uint8_t *pkg, uint64_t size, uint64_t offset, int file, uint64_t len) { @@ -1105,6 +1108,7 @@ static void decrypt_debug_pkg_normal(uint8_t *pkg, uint64_t size, uint64_t offse munmap(pkg, last_round_size); } +#ifdef X86CPU static void decrypt_debug_pkg_sse(uint8_t *pkg, uint64_t size, uint64_t offset, int file, uint64_t len) { u8 key[0x40]; @@ -1169,17 +1173,22 @@ static void decrypt_debug_pkg_sse(uint8_t *pkg, uint64_t size, uint64_t offset, write(file, pkg, last_round_size); munmap(pkg, last_round_size); } +#endif static void decrypt_debug_pkg(uint8_t *pkg, uint64_t size, uint64_t offset_data, int file, uint64_t len) { + #ifdef X86CPU if(aes128_supported_x86()) { decrypt_debug_pkg_sse(pkg,size,offset_data, file, len); } else { + #endif decrypt_debug_pkg_normal(pkg,size,offset_data, file, len); + #ifdef X86CPU } + #endif } int decrypt_retail_pkg_data(uint8_t *buf, uint64_t size, uint8_t *data_riv, uint8_t *gpkg_key) @@ -1757,4 +1766,4 @@ if((strstr(argv[1], ".rap")) || (strstr(argv[1], ".RAP"))) getchar(); getchar(); return -1; -} \ No newline at end of file +}