From 6dcbee7f4c21a148bb71a3028ba512ce8ebfb0e6 Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 15 Feb 2018 18:48:31 -0600 Subject: [PATCH] Add more CFGI SecureInfo functions (#393) --- libctru/include/3ds/services/cfgu.h | 12 ++++++++++ libctru/source/services/cfgu.c | 34 +++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/libctru/include/3ds/services/cfgu.h b/libctru/include/3ds/services/cfgu.h index d8db9dd..9dc450c 100644 --- a/libctru/include/3ds/services/cfgu.h +++ b/libctru/include/3ds/services/cfgu.h @@ -194,3 +194,15 @@ Result CFGI_GetLocalFriendCodeSeedData(u8 *data); * @param seed Pointer to write the friend code seed to. */ Result CFGI_GetLocalFriendCodeSeed(u64* seed); + +/** + * @brief Gets the 0x11-byte data following the SecureInfo signature. + * @param data Pointer to output the buffer. (The size must be at least 0x11-bytes) + */ +Result CFGI_GetSecureInfoData(u8 *data); + +/** + * @brief Gets the 0x100-byte RSA-2048 SecureInfo signature. + * @param data Pointer to output the buffer. (The size must be at least 0x100-bytes) + */ +Result CFGI_GetSecureInfoSignature(u8 *data); diff --git a/libctru/source/services/cfgu.c b/libctru/source/services/cfgu.c index cc960bc..0aebac2 100644 --- a/libctru/source/services/cfgu.c +++ b/libctru/source/services/cfgu.c @@ -351,8 +351,8 @@ Result CFGI_GetLocalFriendCodeSeedData(u8 *data) u32 *cmdbuf = getThreadCommandBuffer(); cmdbuf[0] = IPC_MakeHeader(0x404,1,2); // 0x4040042 - cmdbuf[1] = (u32)0x110; - cmdbuf[2] = IPC_Desc_Buffer((u32)0x110, IPC_BUFFER_W); + cmdbuf[1] = 0x110; + cmdbuf[2] = IPC_Desc_Buffer(0x110, IPC_BUFFER_W); cmdbuf[3] = (u32)data; if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret; @@ -373,3 +373,33 @@ Result CFGI_GetLocalFriendCodeSeed(u64* seed) return (Result)cmdbuf[1]; } + +Result CFGI_GetSecureInfoData(u8 *data) +{ + Result ret = 0; + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = IPC_MakeHeader(0x814,1,2); // 0x8140042 + cmdbuf[1] = 0x11; + cmdbuf[2] = IPC_Desc_Buffer(0x11, IPC_BUFFER_W); + cmdbuf[3] = (u32)data; + + if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret; + + return (Result)cmdbuf[1]; +} + +Result CFGI_GetSecureInfoSignature(u8 *data) +{ + Result ret = 0; + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = IPC_MakeHeader(0x815,1,2); // 0x8150042 + cmdbuf[1] = 0x100; + cmdbuf[2] = IPC_Desc_Buffer(0x100, IPC_BUFFER_W); + cmdbuf[3] = (u32)data; + + if(R_FAILED(ret = svcSendSyncRequest(cfguHandle)))return ret; + + return (Result)cmdbuf[1]; +}