NAND暗号化対策(ARM7側AES_Initが必須となる)

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@472 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
yutaka 2008-01-16 08:28:24 +00:00
parent b90147d53c
commit 0a1bc0a0aa
2 changed files with 13 additions and 1 deletions

View File

@ -30,12 +30,14 @@
*---------------------------------------------------------------------------*/ *---------------------------------------------------------------------------*/
void AESi_InitKeysForApp( u8 game_code[4] ) void AESi_InitKeysForApp( u8 game_code[4] )
{ {
AES_Lock();
AES_WaitKey(); AES_WaitKey();
reg_AES_AES_ID_A2 = AES_IDS_ID0_C(game_code); reg_AES_AES_ID_A2 = AES_IDS_ID0_C(game_code);
reg_AES_AES_ID_A3 = AES_IDS_ID0_D(game_code); reg_AES_AES_ID_A3 = AES_IDS_ID0_D(game_code);
reg_AES_AES_ID_B0 = AES_IDS_ID1_A(game_code); reg_AES_AES_ID_B0 = AES_IDS_ID1_A(game_code);
reg_AES_AES_ID_B1 = AES_IDS_ID1_B(game_code); reg_AES_AES_ID_B1 = AES_IDS_ID1_B(game_code);
AES_Unlock();
} }
/*---------------------------------------------------------------------------* /*---------------------------------------------------------------------------*
@ -50,12 +52,14 @@ void AESi_InitKeysForApp( u8 game_code[4] )
*---------------------------------------------------------------------------*/ *---------------------------------------------------------------------------*/
void AESi_InitKeysForHard( u8 fuse[8] ) void AESi_InitKeysForHard( u8 fuse[8] )
{ {
AES_Lock();
AES_WaitKey(); AES_WaitKey();
reg_AES_AES_ID_B2 = *(u32*)&fuse[4]; reg_AES_AES_ID_B2 = *(u32*)&fuse[4];
reg_AES_AES_ID_B3 = *(u32*)&fuse[0]; reg_AES_AES_ID_B3 = *(u32*)&fuse[0];
reg_AES_AES_ID_D0 = *(u32*)&fuse[0]; reg_AES_AES_ID_D0 = *(u32*)&fuse[0];
reg_AES_AES_ID_D3 = *(u32*)&fuse[4]; reg_AES_AES_ID_D3 = *(u32*)&fuse[4];
AES_Unlock();
} }
/*---------------------------------------------------------------------------* /*---------------------------------------------------------------------------*
@ -69,6 +73,7 @@ void AESi_InitKeysForHard( u8 fuse[8] )
*---------------------------------------------------------------------------*/ *---------------------------------------------------------------------------*/
void AESi_ResetAesKey( void ) void AESi_ResetAesKey( void )
{ {
AES_Lock();
AES_WaitKey(); AES_WaitKey();
// set dummy without seed[3] // set dummy without seed[3]
@ -101,6 +106,7 @@ void AESi_ResetAesKey( void )
reg_AES_AES_KEY_D1 = 11; reg_AES_AES_KEY_D1 = 11;
reg_AES_AES_KEY_D2 = 12; reg_AES_AES_KEY_D2 = 12;
reg_AES_AES_KEY_D3 = 12; reg_AES_AES_KEY_D3 = 12;
AES_Unlock();
} }
/*---------------------------------------------------------------------------* /*---------------------------------------------------------------------------*
@ -117,6 +123,7 @@ void AESi_RecvSeed( BOOL developer_encrypt )
AESKey seed; AESKey seed;
// PXI_RecvDataByFifo( PXI_FIFO_TAG_DATA, &seed, AES_BLOCK_SIZE ); // PXI_RecvDataByFifo( PXI_FIFO_TAG_DATA, &seed, AES_BLOCK_SIZE );
PXI_RecvStream( &seed, AES_BLOCK_SIZE ); PXI_RecvStream( &seed, AES_BLOCK_SIZE );
AES_Lock();
AES_WaitKey(); AES_WaitKey();
if ( developer_encrypt ) if ( developer_encrypt )
{ {
@ -126,4 +133,5 @@ void AESi_RecvSeed( BOOL developer_encrypt )
{ {
AES_SetKeySeedA((AESKeySeed*)&seed); // APP AES_SetKeySeedA((AESKeySeed*)&seed); // APP
} }
AES_Unlock();
} }

View File

@ -120,14 +120,19 @@ int FS_OpenSrl( void )
#define DMA_RECV 3 #define DMA_RECV 3
static void CopyWithAes( const void* src, void* dest, u32 size ) static void CopyWithAes( const void* src, void* dest, u32 size )
{ {
AES_Lock();
AES_Reset(); AES_Reset();
AES_Reset(); AES_Reset();
AES_WaitKey();
AES_LoadKey( AES_KEY_SLOT_A );
AES_WaitKey();
AES_DmaSend( DMA_SEND, src, size, NULL, NULL ); AES_DmaSend( DMA_SEND, src, size, NULL, NULL );
AES_DmaRecv( DMA_RECV, dest, size, NULL, NULL ); AES_DmaRecv( DMA_RECV, dest, size, NULL, NULL );
AES_SetCounter( &aesCounter ); AES_SetCounter( &aesCounter );
AES_Run( AES_MODE_CTR, 0, size / AES_BLOCK_SIZE, NULL, NULL ); AES_Run( AES_MODE_CTR, 0, size / AES_BLOCK_SIZE, NULL, NULL );
AES_AddToCounter( &aesCounter, size / AES_BLOCK_SIZE ); AES_AddToCounter( &aesCounter, size / AES_BLOCK_SIZE );
MI_WaitNDma( DMA_RECV ); MI_WaitNDma( DMA_RECV );
AES_Unlock();
} }
static void EnableAes( u32 offset ) static void EnableAes( u32 offset )
@ -154,7 +159,6 @@ static u32 GetTransferSize( u32 offset, u32 size )
{ {
size = aes_end - offset; size = aes_end - offset;
} }
AES_LoadKey( AES_KEY_SLOT_A );
EnableAes( offset ); EnableAes( offset );
} }
else else