not going to need you anymore

This commit is contained in:
Naim2000 2025-01-05 17:54:51 -05:00
parent 20dc7e58c3
commit dda0293603
5 changed files with 33 additions and 187 deletions

View File

@ -1,125 +0,0 @@
/*-------------------------------------------------------------
aes.c -- AES Engine
Copyright (C) 2022
GaryOderNichts
Joris 'DacoTaco' Vermeylen info@dacotaco.com
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
-------------------------------------------------------------*/
#if defined(HW_RVL)
#include <string.h>
#include <gctypes.h>
#include <gcutil.h>
#include <ogc/ipc.h>
#include "aes.h"
#define AES_HEAPSIZE 0x200
#define AES_IOCTLV_ENCRYPT 2
#define AES_IOCTLV_DECRYPT 3
static s32 __aes_fd = -1;
static s32 __aes_hid = -1;
static s32 AES_ExecuteCommand(s32 command, const void* key, u32 key_size, void* iv, u32 iv_size, const void* in_data, void* out_data, u32 data_size)
{
if ((((u32)in_data | (u32)out_data) & 0xF) != 0)
return -4;
if (key_size != 16 || iv_size != 16 || (data_size & 15) != 0)
return -4;
ioctlv* params = (ioctlv*)iosAlloc(__aes_hid, sizeof(ioctlv) * 4);
if (!params)
return -1;
s32 ret = -1;
for (u32 i = 0; i < data_size; i += AES_BLOCK_SIZE) {
u32 size = i+AES_BLOCK_SIZE >= data_size
? data_size - i
: AES_BLOCK_SIZE;
params[0].data = (void*)((u32)in_data + i);
params[0].len = size;
params[1].data = (void*) key;
params[1].len = key_size;
params[2].data = (void*)((u32)out_data + i);
params[2].len = size;
params[3].data = iv;
params[3].len = iv_size;
ret = IOS_Ioctlv(__aes_fd, command, 2, 2, params);
if (ret < 0)
break;
}
iosFree(__aes_hid, params);
return ret;
}
s32 AES_Init(void)
{
if (__aes_fd >= 0)
return -1;
__aes_fd = IOS_Open("/dev/aes", 0);
if (__aes_fd < 0)
return __aes_fd;
//only create heap if it wasn't created yet.
//its never disposed, so only create once.
if(__aes_hid < 0)
__aes_hid = iosCreateHeap(AES_HEAPSIZE);
if (__aes_hid < 0) {
AES_Close();
return __aes_hid;
}
return 0;
}
s32 AES_Close(void)
{
if (__aes_fd < 0)
return -1;
IOS_Close(__aes_fd);
__aes_fd = -1;
return 0;
}
s32 AES_Encrypt(const void* key, u32 key_size, void* iv, u32 iv_size, const void* in_data, void* out_data, u32 data_size)
{
return AES_ExecuteCommand(AES_IOCTLV_ENCRYPT, key, key_size, iv, iv_size, in_data, out_data, data_size);
}
s32 AES_Decrypt(const void* key, u32 key_size, void* iv, u32 iv_size, const void* in_data, void* out_data, u32 data_size)
{
return AES_ExecuteCommand(AES_IOCTLV_DECRYPT, key, key_size, iv, iv_size, in_data, out_data, data_size);
}
#endif

View File

@ -1,53 +0,0 @@
/*-------------------------------------------------------------
aes.h -- AES Engine
Copyright (C) 2022
GaryOderNichts
Joris 'DacoTaco' Vermeylen info@dacotaco.com
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
-------------------------------------------------------------*/
#ifndef __AES_H___
#define __AES_H___
#if defined(HW_RVL)
#include <gctypes.h>
#include <gcutil.h>
#define AES_BLOCK_SIZE 0x10000
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
s32 AES_Init(void);
s32 AES_Close(void);
s32 AES_Decrypt(const void* key, u32 key_size, void* iv, u32 iv_size, const void* in_data, void* out_data, u32 data_size);
s32 AES_Encrypt(const void* key, u32 key_size, void* iv, u32 iv_size, const void* in_data, void* out_data, u32 data_size);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif
#endif

View File

@ -2,9 +2,9 @@
#include <stdlib.h>
#include <ogcsys.h>
#include <ogc/es.h>
#include <ogc/aes.h>
#include "sys.h"
#include "aes.h"
#include "nand.h"
#include "mini_seeprom.h"
#include "malloc.h"

View File

@ -1,15 +1,15 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ogcsys.h>
#include <malloc.h>
#include <ctype.h>
#include <ogcsys.h>
#include <ogc/aes.h>
#include <wiilight.h>
#include <wiidrc/wiidrc.h>
#include "sys.h"
#include "title.h"
#include "aes.h"
#include "gui.h"
#include "menu.h"
#include "restart.h"

View File

@ -1,14 +1,14 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <ogcsys.h>
#include <ogc/pad.h>
#include <ogc/es.h>
#include <unistd.h>
#include <ogc/aes.h>
#include "sys.h"
#include "title.h"
#include "utils.h"
#include "aes.h"
#include "mini_seeprom.h"
#include "otp.h"
#include "video.h"
@ -83,7 +83,7 @@ u64 be64(const u8 *p)
return ((u64)be32(p) << 32) | be32(p + 4);
}
static inline void DecEncTxtBuffer(char* buffer)
static void DecEncTxtBuffer(char* buffer)
{
u32 key = 0x73B5DBFA;
s32 i;
@ -613,6 +613,7 @@ const char* wad_strerror(int ec)
case -998: return "Skipped";
case -999: return "BRICK BLOCKED";
case -1010: return "Wii System memory full!";
case -1017: return "Invalid argument";
case -1022: return "Content hash mismatch";
case -1035: return "Newer version already installed";
case -1036: return "Needed IOS missing!";
@ -882,7 +883,7 @@ s32 Wad_Install(FILE *fp)
cIOSInfo ios_info;
if (ES_CheckHasKoreanKey() &&
(!Sys_GetcIOSInfo(TITLE_LOWER(tmd_data->sys_version), &ios_info) ||
(!Title_GetcIOSInfo(TITLE_LOWER(tmd_data->sys_version), &ios_info) ||
ios_info.ios_base != 60))
{
printf("\n"
@ -965,6 +966,29 @@ skipChecks:
}
}
#if 0
/* Check available space */
if (TITLE_UPPER(tmd_data->title_id) != 0x1 && TITLE_UPPER(tmd_data->title_id) != 0x00010002)
{
u32 totalContentSize = 0;
for (int i = 0; i < tmd_data->num_contents; i++)
{
tmd_content* content = &tmd_data->contents[i];
if (Title_SharedContentPresent(content, sharedContents, sharedContentsCount))
continue;
totalContentSize += round_up(content->size, 16384);
}
u32 free, user_free, blocks_free, user_blocks_free;
Title_GetFreeSpace(totalContentSize, &free, &user_free);
blocks_free = free / 131072, user_blocks_free = user_free / 131072;
if (totalContentSize > free)
}
#endif
printf("\t\t>> Installing ticket...");
fflush(stdout);
@ -984,7 +1008,7 @@ skipChecks:
goto err;
/* Get list of currently installed shared contents */
Sys_GetSharedContents(&sharedContents, &sharedContentsCount);
Title_GetSharedContents(&sharedContents, &sharedContentsCount);
/* Install contents */
for (cnt = 0; cnt < tmd_data->num_contents; cnt++)
@ -997,7 +1021,7 @@ skipChecks:
/* Encrypted content size */
len = round_up(content->size, 64);
if (Sys_SharedContentPresent(content, sharedContents, sharedContentsCount))
if (Title_SharedContentPresent(content, sharedContents, sharedContentsCount))
{
offset += len;
continue;