mirror of
https://github.com/DarkStore-3DS/Project_CTR.git
synced 2026-07-06 08:49:04 +00:00
[makerom] Fixed size limitation on NCCH encryption.
This commit is contained in:
+1
-1
@@ -35,7 +35,7 @@ void AesCtrCrypt(u8 *key, u8 *ctr, u8 *input, u8 *output, u64 length, u64 offset
|
|||||||
{
|
{
|
||||||
u8 stream[16];
|
u8 stream[16];
|
||||||
aes_context aes;
|
aes_context aes;
|
||||||
u64 nc_off = 0;
|
size_t nc_off = 0;
|
||||||
|
|
||||||
clrmem(&aes,sizeof(aes_context));
|
clrmem(&aes,sizeof(aes_context));
|
||||||
aes_setkey_enc(&aes, key, 128);
|
aes_setkey_enc(&aes, key, 128);
|
||||||
|
|||||||
@@ -201,6 +201,8 @@
|
|||||||
<ClCompile Include="code.c" />
|
<ClCompile Include="code.c" />
|
||||||
<ClCompile Include="crypto.c" />
|
<ClCompile Include="crypto.c" />
|
||||||
<ClCompile Include="ctr_utils.c" />
|
<ClCompile Include="ctr_utils.c" />
|
||||||
|
<ClCompile Include="polarssl\aes.c" />
|
||||||
|
<ClCompile Include="polarssl\padlock.c" />
|
||||||
<ClCompile Include="romfs_fs.c" />
|
<ClCompile Include="romfs_fs.c" />
|
||||||
<ClCompile Include="elf.c" />
|
<ClCompile Include="elf.c" />
|
||||||
<ClCompile Include="exefs.c" />
|
<ClCompile Include="exefs.c" />
|
||||||
|
|||||||
@@ -473,6 +473,12 @@
|
|||||||
<ClCompile Include="romfs_fs.c">
|
<ClCompile Include="romfs_fs.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="Makefile">
|
<None Include="Makefile">
|
||||||
|
|||||||
+11
-11
@@ -1053,7 +1053,7 @@ int GetNcchInfo(ncch_info *info, ncch_hdr *hdr)
|
|||||||
info->titleId = u8_to_u64(hdr->titleId,LE);
|
info->titleId = u8_to_u64(hdr->titleId,LE);
|
||||||
info->programId = u8_to_u64(hdr->programId,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);
|
info->formatVersion = u8_to_u16(hdr->formatVersion,LE);
|
||||||
if(!IsCfa(hdr)){
|
if(!IsCfa(hdr)){
|
||||||
@@ -1061,18 +1061,18 @@ int GetNcchInfo(ncch_info *info, ncch_hdr *hdr)
|
|||||||
info->exhdrSize = u8_to_u32(hdr->exhdrSize,LE);
|
info->exhdrSize = u8_to_u32(hdr->exhdrSize,LE);
|
||||||
info->acexOffset = (info->exhdrOffset + info->exhdrSize);
|
info->acexOffset = (info->exhdrOffset + info->exhdrSize);
|
||||||
info->acexSize = sizeof(access_descriptor);
|
info->acexSize = sizeof(access_descriptor);
|
||||||
info->plainRegionOffset = (u64)(u8_to_u32(hdr->plainRegionOffset,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->plainRegionSize = ((u64)u8_to_u32(hdr->plainRegionSize,LE))*block_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
info->logoOffset = (u64)(u8_to_u32(hdr->logoOffset,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->logoSize = ((u64)u8_to_u32(hdr->logoSize,LE))*block_size;
|
||||||
info->exefsOffset = (u64)(u8_to_u32(hdr->exefsOffset,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->exefsSize = ((u64)u8_to_u32(hdr->exefsSize,LE))*block_size;
|
||||||
info->exefsHashDataSize = (u64)(u8_to_u32(hdr->exefsHashSize,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->romfsOffset = ((u64)u8_to_u32(hdr->romfsOffset,LE))*block_size;
|
||||||
info->romfsSize = (u64) (u8_to_u32(hdr->romfsSize,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->romfsHashDataSize = ((u64)u8_to_u32(hdr->romfsHashSize,LE))*block_size;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -839,14 +839,14 @@ int aes_crypt_cbc( aes_context *ctx,
|
|||||||
*/
|
*/
|
||||||
int aes_crypt_cfb128( aes_context *ctx,
|
int aes_crypt_cfb128( aes_context *ctx,
|
||||||
int mode,
|
int mode,
|
||||||
size_t length,
|
uint64_t length,
|
||||||
size_t *iv_off,
|
size_t *iv_off,
|
||||||
unsigned char iv[16],
|
unsigned char iv[16],
|
||||||
const unsigned char *input,
|
const unsigned char *input,
|
||||||
unsigned char *output )
|
unsigned char *output )
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
size_t n = *iv_off;
|
size_t n = *iv_off;
|
||||||
|
|
||||||
if( mode == AES_DECRYPT )
|
if( mode == AES_DECRYPT )
|
||||||
{
|
{
|
||||||
@@ -886,7 +886,7 @@ int aes_crypt_cfb128( aes_context *ctx,
|
|||||||
* AES-CTR buffer encryption/decryption
|
* AES-CTR buffer encryption/decryption
|
||||||
*/
|
*/
|
||||||
int aes_crypt_ctr( aes_context *ctx,
|
int aes_crypt_ctr( aes_context *ctx,
|
||||||
size_t length,
|
uint64_t length,
|
||||||
size_t *nc_off,
|
size_t *nc_off,
|
||||||
unsigned char nonce_counter[16],
|
unsigned char nonce_counter[16],
|
||||||
unsigned char stream_block[16],
|
unsigned char stream_block[16],
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ int aes_crypt_ecb( aes_context *ctx,
|
|||||||
*/
|
*/
|
||||||
int aes_crypt_cbc( aes_context *ctx,
|
int aes_crypt_cbc( aes_context *ctx,
|
||||||
int mode,
|
int mode,
|
||||||
size_t length,
|
uint64_t length,
|
||||||
unsigned char iv[16],
|
unsigned char iv[16],
|
||||||
const unsigned char *input,
|
const unsigned char *input,
|
||||||
unsigned char *output );
|
unsigned char *output );
|
||||||
@@ -141,7 +141,7 @@ int aes_crypt_cbc( aes_context *ctx,
|
|||||||
*/
|
*/
|
||||||
int aes_crypt_cfb128( aes_context *ctx,
|
int aes_crypt_cfb128( aes_context *ctx,
|
||||||
int mode,
|
int mode,
|
||||||
size_t length,
|
uint64_t length,
|
||||||
size_t *iv_off,
|
size_t *iv_off,
|
||||||
unsigned char iv[16],
|
unsigned char iv[16],
|
||||||
const unsigned char *input,
|
const unsigned char *input,
|
||||||
@@ -169,7 +169,7 @@ int aes_crypt_cfb128( aes_context *ctx,
|
|||||||
* \return 0 if successful
|
* \return 0 if successful
|
||||||
*/
|
*/
|
||||||
int aes_crypt_ctr( aes_context *ctx,
|
int aes_crypt_ctr( aes_context *ctx,
|
||||||
size_t length,
|
uint64_t length,
|
||||||
size_t *nc_off,
|
size_t *nc_off,
|
||||||
unsigned char nonce_counter[16],
|
unsigned char nonce_counter[16],
|
||||||
unsigned char stream_block[16],
|
unsigned char stream_block[16],
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "dir.h"
|
#include "romfs_fs.h"
|
||||||
#include "ncch_build.h"
|
#include "ncch_build.h"
|
||||||
#include "romfs.h"
|
#include "romfs.h"
|
||||||
|
|
||||||
|
|||||||
+8
-8
@@ -36,12 +36,12 @@ typedef enum
|
|||||||
MAX_U64 = 0xffffffffffffffff,
|
MAX_U64 = 0xffffffffffffffff,
|
||||||
} data_type_max;
|
} data_type_max;
|
||||||
|
|
||||||
typedef unsigned char u8;
|
typedef uint8_t u8;
|
||||||
typedef unsigned short u16;
|
typedef uint16_t u16;
|
||||||
typedef unsigned int u32;
|
typedef uint32_t u32;
|
||||||
typedef unsigned long long u64;
|
typedef uint64_t u64;
|
||||||
|
|
||||||
typedef signed char s8;
|
typedef int8_t s8;
|
||||||
typedef signed short s16;
|
typedef int16_t s16;
|
||||||
typedef signed int s32;
|
typedef int32_t s32;
|
||||||
typedef signed long long s64;
|
typedef int64_t s64;
|
||||||
|
|||||||
Reference in New Issue
Block a user