From ef351c70de38dbdfbffb413116d966786feda215 Mon Sep 17 00:00:00 2001 From: Aurora Date: Fri, 30 Sep 2016 01:02:34 +0200 Subject: [PATCH] Minor stuff (3) --- source/crypto.c | 10 +++++----- source/fatfs/ffconf.h | 2 +- source/installer.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/crypto.c b/source/crypto.c index 18294f0..66f3a36 100755 --- a/source/crypto.c +++ b/source/crypto.c @@ -316,7 +316,7 @@ int ctrNandRead(u32 sector, u32 sectorCount, u8 *outbuf) memcpy(tmpCtr, nandCtr, sizeof(nandCtr)); aes_advctr(tmpCtr, ((sector + fatStart) * 0x200) / AES_BLOCK_SIZE, AES_INPUT_BE | AES_INPUT_NORMAL); - //Read + //Read from NAND int result = sdmmc_nand_readsectors(sector + fatStart, sectorCount, outbuf); //Decrypt @@ -330,12 +330,12 @@ void readFirm0(u8 *outbuf, u32 size) { u8 __attribute__((aligned(4))) ctrTmp[sizeof(nandCtr)]; memcpy(ctrTmp, nandCtr, sizeof(nandCtr)); + aes_advctr(ctrTmp, 0x0B130000 / AES_BLOCK_SIZE, AES_INPUT_BE | AES_INPUT_NORMAL); - //Read FIRM0 data + //Read from NAND sdmmc_nand_readsectors(0x0B130000 / 0x200, size / 0x200, outbuf); //Decrypt - aes_advctr(ctrTmp, 0x0B130000 / AES_BLOCK_SIZE, AES_INPUT_BE | AES_INPUT_NORMAL); aes_use_keyslot(0x06); aes(outbuf, outbuf, size / AES_BLOCK_SIZE, ctrTmp, AES_CTR_MODE, AES_INPUT_BE | AES_INPUT_NORMAL); } @@ -345,9 +345,9 @@ void writeFirm(u8 *inbuf, bool isFirm1, u32 size) u32 offset = isFirm1 ? 0x0B530000 : 0x0B130000; u8 __attribute__((aligned(4))) ctrTmp[sizeof(nandCtr)]; memcpy(ctrTmp, nandCtr, sizeof(nandCtr)); - - //Encrypt FIRM data aes_advctr(ctrTmp, offset / AES_BLOCK_SIZE, AES_INPUT_BE | AES_INPUT_NORMAL); + + //Encrypt aes_use_keyslot(0x06); aes(inbuf, inbuf, size / AES_BLOCK_SIZE, ctrTmp, AES_CTR_MODE, AES_INPUT_BE | AES_INPUT_NORMAL); diff --git a/source/fatfs/ffconf.h b/source/fatfs/ffconf.h index 75cfef4..fdcf239 100755 --- a/source/fatfs/ffconf.h +++ b/source/fatfs/ffconf.h @@ -147,7 +147,7 @@ / Drive/Volume Configurations /---------------------------------------------------------------------------*/ -#define _VOLUMES 2 +#define _VOLUMES 1 /* Number of volumes (logical drives) to be used. */ diff --git a/source/installer.c b/source/installer.c index 3a9bce2..72b96b5 100755 --- a/source/installer.c +++ b/source/installer.c @@ -205,7 +205,7 @@ static inline void installer(bool isA9lh, bool isOtpless) *(u32 *)0x80FD0FC = 0xEAFFCBBF; //B 0x80F0000 memcpy((void *)0x80F0000, loader_bin, loader_bin_size); - writeFirm((u8 *)FIRM0_100_OFFSET, false, FIRM0_SIZE); + writeFirm((u8 *)FIRM0_100_OFFSET, false, FIRM0100_SIZE); mcuReboot(); }