[makerom] Fixed size limitation on NCCH encryption.

This commit is contained in:
jakcron
2015-11-20 03:10:00 +08:00
parent 2dd838b693
commit 7e04a8249e
8 changed files with 36 additions and 28 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ void AesCtrCrypt(u8 *key, u8 *ctr, u8 *input, u8 *output, u64 length, u64 offset
{
u8 stream[16];
aes_context aes;
u64 nc_off = 0;
size_t nc_off = 0;
clrmem(&aes,sizeof(aes_context));
aes_setkey_enc(&aes, key, 128);
+2
View File
@@ -201,6 +201,8 @@
<ClCompile Include="code.c" />
<ClCompile Include="crypto.c" />
<ClCompile Include="ctr_utils.c" />
<ClCompile Include="polarssl\aes.c" />
<ClCompile Include="polarssl\padlock.c" />
<ClCompile Include="romfs_fs.c" />
<ClCompile Include="elf.c" />
<ClCompile Include="exefs.c" />
+6
View File
@@ -473,6 +473,12 @@
<ClCompile Include="romfs_fs.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="polarssl\aes.c">
<Filter>Source Files\polarssl</Filter>
</ClCompile>
<ClCompile Include="polarssl\padlock.c">
<Filter>Source Files\polarssl</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="Makefile">
+11 -11
View File
@@ -1053,7 +1053,7 @@ int GetNcchInfo(ncch_info *info, ncch_hdr *hdr)
info->titleId = u8_to_u64(hdr->titleId,LE);
info->programId = u8_to_u64(hdr->programId,LE);
u32 block_size = GetNcchBlockSize(hdr);
u64 block_size = GetNcchBlockSize(hdr);
info->formatVersion = u8_to_u16(hdr->formatVersion,LE);
if(!IsCfa(hdr)){
@@ -1061,18 +1061,18 @@ int GetNcchInfo(ncch_info *info, ncch_hdr *hdr)
info->exhdrSize = u8_to_u32(hdr->exhdrSize,LE);
info->acexOffset = (info->exhdrOffset + info->exhdrSize);
info->acexSize = sizeof(access_descriptor);
info->plainRegionOffset = (u64)(u8_to_u32(hdr->plainRegionOffset,LE)*block_size);
info->plainRegionSize = (u64)(u8_to_u32(hdr->plainRegionSize,LE)*block_size);
info->plainRegionOffset = ((u64)u8_to_u32(hdr->plainRegionOffset,LE))*block_size;
info->plainRegionSize = ((u64)u8_to_u32(hdr->plainRegionSize,LE))*block_size;
}
info->logoOffset = (u64)(u8_to_u32(hdr->logoOffset,LE)*block_size);
info->logoSize = (u64)(u8_to_u32(hdr->logoSize,LE)*block_size);
info->exefsOffset = (u64)(u8_to_u32(hdr->exefsOffset,LE)*block_size);
info->exefsSize = (u64)(u8_to_u32(hdr->exefsSize,LE)*block_size);
info->exefsHashDataSize = (u64)(u8_to_u32(hdr->exefsHashSize,LE)*block_size);
info->romfsOffset = (u64) (u8_to_u32(hdr->romfsOffset,LE)*block_size);
info->romfsSize = (u64) (u8_to_u32(hdr->romfsSize,LE)*block_size);
info->romfsHashDataSize = (u64)(u8_to_u32(hdr->romfsHashSize,LE)*block_size);
info->logoOffset = ((u64)u8_to_u32(hdr->logoOffset,LE))*block_size;
info->logoSize = ((u64)u8_to_u32(hdr->logoSize,LE))*block_size;
info->exefsOffset = ((u64)u8_to_u32(hdr->exefsOffset,LE))*block_size;
info->exefsSize = ((u64)u8_to_u32(hdr->exefsSize,LE))*block_size;
info->exefsHashDataSize = ((u64)u8_to_u32(hdr->exefsHashSize,LE))*block_size;
info->romfsOffset = ((u64)u8_to_u32(hdr->romfsOffset,LE))*block_size;
info->romfsSize = ((u64)u8_to_u32(hdr->romfsSize,LE))*block_size;
info->romfsHashDataSize = ((u64)u8_to_u32(hdr->romfsHashSize,LE))*block_size;
return 0;
}
+3 -3
View File
@@ -839,14 +839,14 @@ int aes_crypt_cbc( aes_context *ctx,
*/
int aes_crypt_cfb128( aes_context *ctx,
int mode,
size_t length,
uint64_t length,
size_t *iv_off,
unsigned char iv[16],
const unsigned char *input,
unsigned char *output )
{
int c;
size_t n = *iv_off;
size_t n = *iv_off;
if( mode == AES_DECRYPT )
{
@@ -886,7 +886,7 @@ int aes_crypt_cfb128( aes_context *ctx,
* AES-CTR buffer encryption/decryption
*/
int aes_crypt_ctr( aes_context *ctx,
size_t length,
uint64_t length,
size_t *nc_off,
unsigned char nonce_counter[16],
unsigned char stream_block[16],
+3 -3
View File
@@ -116,7 +116,7 @@ int aes_crypt_ecb( aes_context *ctx,
*/
int aes_crypt_cbc( aes_context *ctx,
int mode,
size_t length,
uint64_t length,
unsigned char iv[16],
const unsigned char *input,
unsigned char *output );
@@ -141,7 +141,7 @@ int aes_crypt_cbc( aes_context *ctx,
*/
int aes_crypt_cfb128( aes_context *ctx,
int mode,
size_t length,
uint64_t length,
size_t *iv_off,
unsigned char iv[16],
const unsigned char *input,
@@ -169,7 +169,7 @@ int aes_crypt_cfb128( aes_context *ctx,
* \return 0 if successful
*/
int aes_crypt_ctr( aes_context *ctx,
size_t length,
uint64_t length,
size_t *nc_off,
unsigned char nonce_counter[16],
unsigned char stream_block[16],
+2 -2
View File
@@ -1,5 +1,5 @@
#include "lib.h"
#include "dir.h"
#include "romfs_fs.h"
#include "ncch_build.h"
#include "romfs.h"
@@ -30,4 +30,4 @@ int ImportRomFsBinaryFromFile(romfs_buildctx *ctx)
return INVALID_ROMFS_FILE;
}
return 0;
}
}
+8 -8
View File
@@ -36,12 +36,12 @@ typedef enum
MAX_U64 = 0xffffffffffffffff,
} data_type_max;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef signed char s8;
typedef signed short s16;
typedef signed int s32;
typedef signed long long s64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;