Useless casts

This commit is contained in:
Aurora 2016-03-25 01:59:12 +01:00
parent 1df402f35d
commit 9c7e70bb81
5 changed files with 23 additions and 23 deletions

View File

@ -320,7 +320,7 @@ void writeFirm(u8 *inbuf, u32 firm, u32 size){
} }
//Setup keyslot 0x11 for key sector de/encryption //Setup keyslot 0x11 for key sector de/encryption
void setupKeyslot0x11(u32 a9lhBoot, const u8 *otp){ void setupKeyslot0x11(u32 a9lhBoot, const void *otp){
u8 shasum[0x20]; u8 shasum[0x20];
u8 keyX[0x10]; u8 keyX[0x10];
u8 keyY[0x10]; u8 keyY[0x10];
@ -349,16 +349,16 @@ void generateSector(u8 *keySector){
} }
//Test the OTP to be correct by verifying key2 //Test the OTP to be correct by verifying key2
u32 testOtp(u32 a9lhBoot, void *tempOffset){ u32 testOtp(u32 a9lhBoot, u8 *tempOffset){
//Read keysector from NAND //Read keysector from NAND
sdmmc_nand_readsectors(0x96, 0x1, (vu8 *)tempOffset); sdmmc_nand_readsectors(0x96, 1, tempOffset);
//Decrypt key2 //Decrypt key2
aes_use_keyslot(0x11); aes_use_keyslot(0x11);
aes((void *)tempOffset + 0x10, (void *)tempOffset + 0x10, 1, NULL, AES_ECB_DECRYPT_MODE, 0); aes(tempOffset + 0x10, tempOffset + 0x10, 1, NULL, AES_ECB_DECRYPT_MODE, 0);
//Test key2 //Test key2
if(memcmp((void *)tempOffset + 0x10, a9lhBoot ? a9lhKey2 : key2, 0x10) != 0) return 0; if(memcmp(tempOffset + 0x10, a9lhBoot ? a9lhKey2 : key2, 0x10) != 0) return 0;
return 1; return 1;
} }

View File

@ -79,7 +79,7 @@
void getNandCTR(void); void getNandCTR(void);
void readFirm0(u8 *outbuf, u32 size); void readFirm0(u8 *outbuf, u32 size);
void writeFirm(u8 *inbuf, u32 offset, u32 size); void writeFirm(u8 *inbuf, u32 offset, u32 size);
void setupKeyslot0x11(u32 a9lhBoot, const u8 *otp); void setupKeyslot0x11(u32 a9lhBoot, const void *otp);
void generateSector(u8 *keySector); void generateSector(u8 *keySector);
u32 testOtp(u32 a9lhBoot, void *tempOffset); u32 testOtp(u32 a9lhBoot, u8 *tempOffset);
u32 verifyHash(const void *data, u32 size, const u8 *hash); u32 verifyHash(const void *data, u32 size, const u8 *hash);

View File

@ -17,7 +17,7 @@ u32 unmountSD(void){
return 1; return 1;
} }
u32 fileRead(u8 *dest, const char *path, u32 size){ u32 fileRead(void *dest, const char *path, u32 size){
FRESULT fr; FRESULT fr;
FIL fp; FIL fp;
unsigned int br = 0; unsigned int br = 0;

View File

@ -8,5 +8,5 @@
u32 mountSD(void); u32 mountSD(void);
u32 unmountSD(void); u32 unmountSD(void);
u32 fileRead(u8 *dest, const char *path, u32 size); u32 fileRead(void *dest, const char *path, u32 size);
u32 fileSize(const char *path); u32 fileSize(const char *path);

View File

@ -47,8 +47,8 @@ static void installStage2(u32 mode){
u32 size = fileSize(path); u32 size = fileSize(path);
if(!size || size > MAX_STAGE2_SIZE) if(!size || size > MAX_STAGE2_SIZE)
shutdown(1, "Error: stage2.bin doesn't exist or exceeds\nmax size"); shutdown(1, "Error: stage2.bin doesn't exist or exceeds\nmax size");
memset((u8 *)STAGE2_OFFSET, 0, MAX_STAGE2_SIZE); memset((void *)STAGE2_OFFSET, 0, MAX_STAGE2_SIZE);
fileRead((u8 *)STAGE2_OFFSET, path, size); fileRead((void *)STAGE2_OFFSET, path, size);
if(mode) return; if(mode) return;
@ -91,16 +91,16 @@ void installer(void){
path = "a9lh/otp.bin"; path = "a9lh/otp.bin";
if(fileSize(path) != 256) if(fileSize(path) != 256)
shutdown(1, "Error: otp.bin doesn't exist or has a wrong size"); shutdown(1, "Error: otp.bin doesn't exist or has a wrong size");
fileRead((u8 *)OTP_OFFSET, path, 256); fileRead((void *)OTP_OFFSET, path, 256);
} }
//Setup the key sector de/encryption with the SHA register or otp.bin //Setup the key sector de/encryption with the SHA register or otp.bin
setupKeyslot0x11(a9lhBoot, (u8 *)OTP_OFFSET); setupKeyslot0x11(a9lhBoot, (void *)OTP_OFFSET);
if(a9lhBoot && !testOtp(a9lhBoot, (void *)TEMP_OFFSET)) if(a9lhBoot && !testOtp(a9lhBoot, (u8 *)TEMP_OFFSET))
shutdown(1, "Error: the OTP hash is invalid"); shutdown(1, "Error: the OTP hash is invalid");
if(!a9lhBoot && console && !testOtp(a9lhBoot, (void *)TEMP_OFFSET)) if(!a9lhBoot && console && !testOtp(a9lhBoot, (u8 *)TEMP_OFFSET))
shutdown(1, "Error: otp.bin is invalid or corrupted"); shutdown(1, "Error: otp.bin is invalid or corrupted");
//Calculate the CTR for the 3DS partitions //Calculate the CTR for the 3DS partitions
@ -115,20 +115,20 @@ void installer(void){
path = "a9lh/secret_sector.bin"; path = "a9lh/secret_sector.bin";
if(fileSize(path) != 0x200) if(fileSize(path) != 0x200)
shutdown(1, "Error: secret_sector.bin doesn't exist or has\na wrong size"); shutdown(1, "Error: secret_sector.bin doesn't exist or has\na wrong size");
fileRead((u8 *)SECTOR_OFFSET, path, 0x200); fileRead((void *)SECTOR_OFFSET, path, 0x200);
if(!verifyHash((u8 *)SECTOR_OFFSET, 0x200, sectorHash)) if(!verifyHash((void *)SECTOR_OFFSET, 0x200, sectorHash))
shutdown(1, "Error: secret_sector.bin is invalid or corrupted"); shutdown(1, "Error: secret_sector.bin is invalid or corrupted");
//Generate and encrypt a per-console A9LH key sector //Generate and encrypt a per-console A9LH key sector
generateSector((void *)SECTOR_OFFSET); generateSector((u8 *)SECTOR_OFFSET);
//Read FIRM0 //Read FIRM0
path = "a9lh/firm0.bin"; path = "a9lh/firm0.bin";
u32 firm0Size = fileSize(path); u32 firm0Size = fileSize(path);
if(!firm0Size) if(!firm0Size)
shutdown(1, "Error: firm0.bin doesn't exist"); shutdown(1, "Error: firm0.bin doesn't exist");
fileRead((u8 *)FIRM0_OFFSET, path, firm0Size); fileRead((void *)FIRM0_OFFSET, path, firm0Size);
if(!verifyHash((u8 *)FIRM0_OFFSET, firm0Size, firm0Hash)) if(!verifyHash((void *)FIRM0_OFFSET, firm0Size, firm0Hash))
shutdown(1, "Error: firm0.bin is invalid or corrupted"); shutdown(1, "Error: firm0.bin is invalid or corrupted");
//Read FIRM1 //Read FIRM1
@ -136,8 +136,8 @@ void installer(void){
u32 firm1Size = fileSize(path); u32 firm1Size = fileSize(path);
if(!firm1Size) if(!firm1Size)
shutdown(1, "Error: firm1.bin doesn't exist"); shutdown(1, "Error: firm1.bin doesn't exist");
fileRead((u8 *)FIRM1_OFFSET, path, firm1Size); fileRead((void *)FIRM1_OFFSET, path, firm1Size);
if(!verifyHash((u8 *)FIRM1_OFFSET, firm1Size, firm1Hash)) if(!verifyHash((void *)FIRM1_OFFSET, firm1Size, firm1Hash))
shutdown(1, "Error: firm1.bin is invalid or corrupted"); shutdown(1, "Error: firm1.bin is invalid or corrupted");
//Inject stage1 //Inject stage1
@ -145,7 +145,7 @@ void installer(void){
u32 size = fileSize(path); u32 size = fileSize(path);
if(!size || size > MAX_STAGE1_SIZE) if(!size || size > MAX_STAGE1_SIZE)
shutdown(1, "Error: stage1.bin doesn't exist or exceeds\nmax size"); shutdown(1, "Error: stage1.bin doesn't exist or exceeds\nmax size");
fileRead((u8 *)STAGE1_OFFSET, path, size); fileRead((void *)STAGE1_OFFSET, path, size);
installStage2(1); installStage2(1);