mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@163 385bec56-5757-e545-9c3a-d8741f4650f1
This commit is contained in:
parent
4a0d2d1f1f
commit
d63c5f8595
@ -37,10 +37,17 @@
|
||||
#define KEY_LENGTH 2048
|
||||
#define LIST_FILE "sdmc:/csm_list.txt"
|
||||
#define SIGN_FILE "sdmc:/csm_sign.dat"
|
||||
#define PUBK_FILE "sdmc:/csm_key_public.der"
|
||||
//#define PUBK_FILE "sdmc:/csm_key_public.der"
|
||||
#define PRVK_FILE "sdmc:/csm_key_private.der"
|
||||
|
||||
|
||||
extern "C" {
|
||||
extern u8* PUBLIC_KEY_BEGIN[];
|
||||
extern u8* PUBLIC_KEY_END[];
|
||||
|
||||
const void* PUBLIC_KEY = PUBLIC_KEY_BEGIN;
|
||||
}
|
||||
|
||||
demo::RenderSystemDrawing s_RenderSystem;
|
||||
nn::fnd::ExpHeap appHeap;
|
||||
uptr heapForGx;
|
||||
@ -74,7 +81,7 @@ bool ImportFile(nn::fs::MediaType mediaType, wchar_t* filename)
|
||||
|
||||
u8 s_list[200][nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN+1] NN_ATTRIBUTE_ALIGN(32);//シリアルリスト
|
||||
u8 sign[1024*10] NN_ATTRIBUTE_ALIGN(32);//署名
|
||||
u8 key[1024*10] NN_ATTRIBUTE_ALIGN(32);//署名
|
||||
//u8 key[1024*10] NN_ATTRIBUTE_ALIGN(32);//署名
|
||||
u8 serialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN+1];
|
||||
|
||||
bool GetSerial(){
|
||||
@ -137,6 +144,23 @@ bool VeriRsa(u8* src,size_t sz,u8* sig,u8* pub)
|
||||
return res.IsSuccess();
|
||||
}
|
||||
|
||||
bool VeriRsa(u8* src,size_t sz,u8* sig)
|
||||
{
|
||||
nn::crypto::RsaKey key;
|
||||
//nn::crypto::Initialize();
|
||||
nn::ps::CTR::Initialize();
|
||||
nn::Result res = key.InitializePublicKey(PUBLIC_KEY_BEGIN,KEY_LENGTH);
|
||||
NN_LOG("inipubkey desc= %d\n",res.GetDescription());
|
||||
if (res.IsSuccess())
|
||||
{
|
||||
res = nn::ps::CTR::VerifyRsaSha256(src,sz,sig,key);
|
||||
NN_LOG("verisig desc= %d\n",res.GetDescription());
|
||||
}
|
||||
//nn::crypto::Finalize();
|
||||
nn::ps::CTR::Finalize();
|
||||
return res.IsSuccess();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ErrorStop(char *s)
|
||||
@ -264,6 +288,7 @@ void nnMain( void )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fsize = FileRead(SIGN_FILE);
|
||||
if(fsize > 0)//署名リード成功
|
||||
@ -271,16 +296,18 @@ void nnMain( void )
|
||||
if (fsize>sizeof(sign))fsize = sizeof(sign);
|
||||
memcpy(sign,readBuf,fsize);
|
||||
|
||||
fsize = FileRead(PUBK_FILE);
|
||||
if(fsize > 0)//公開鍵リード成功
|
||||
//fsize = FileRead(PUBK_FILE);
|
||||
//if(fsize > 0)//公開鍵リード成功
|
||||
{
|
||||
if (fsize>sizeof(key))fsize = sizeof(key);
|
||||
memcpy(key,readBuf,fsize);
|
||||
//if (fsize>sizeof(key))fsize = sizeof(key);
|
||||
//memcpy(key,readBuf,fsize);
|
||||
|
||||
fsize = FileRead(LIST_FILE);
|
||||
if(fsize > 0)//リストリード成功
|
||||
{
|
||||
if (VeriRsa(readBuf,fsize,sign,key))
|
||||
|
||||
//if (VeriRsa(readBuf,fsize,sign,key))
|
||||
if (VeriRsa(readBuf,fsize,sign))
|
||||
{//署名検証OK
|
||||
int list_ct = 0;
|
||||
n=0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user