Skip to content
Permalink
Browse files

removed mbedtls dep and moved backups to sdmc:/backup/

  • Loading branch information
blawar committed Sep 1, 2019
1 parent d8ec3bf commit d365cb991f29b60169bb5318410c9947e88ccebe
Showing with 11 additions and 41 deletions.
  1. +3 −3 Makefile
  2. +8 −38 source/main.cpp
@@ -37,8 +37,8 @@ DATA := data
INCLUDES := include
EXEFS_SRC := exefs_src
APP_TITLE := Incognito
APP_AUTHOR := Blake Warner
APP_VERSION := 1.3
APP_AUTHOR := blawar
APP_VERSION := 1.4
#ROMFS := romfs

#---------------------------------------------------------------------------------
@@ -56,7 +56,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)

LIBS := -lmbedtls -lmbedx509 -lmbedcrypto -lnx
LIBS := -lnx

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
@@ -1,41 +1,10 @@
#include <string.h>
#include <stdio.h>
#include <switch.h>
#include "mbedtls/sha256.h"
#include <dirent.h>

bool mainMenu();

enum Partitions : u8
{
boot0 = 0,
boot1 = 10,
rawnand = 20,
BCPKG21,
BCPKG22,
BCPKG23,
BCPKG24,
BCPKG25,
BCPKG26,
ProdInfo,
ProdInfoF,
SAFE,
USER,
SYSTEM1,
SYSTEM2
};

int mbedtls_hardware_poll(void *data, unsigned char *output, size_t len, size_t *olen)
{
(void)data;
randomGet(output, len);

if (olen)
{
*olen = len;
}
return 0;
}

bool fileExists(const char* path)
{
FILE* f = fopen(path, "rb");
@@ -53,7 +22,7 @@ class Incognito

Incognito()
{
if (fsOpenBisStorage(&m_sh, Partitions::ProdInfo))
if (fsOpenBisStorage(&m_sh, FsBisStorageId_CalibrationBinary))
{
printf("error: failed to open cal0 partition.\n");
m_open = false;
@@ -86,17 +55,18 @@ class Incognito

char* backupFileName()
{
static char filename[32] = "prodinfo.bin";
static char filename[32] = "sdmc:/backup/prodinfo.bin";

if (!fileExists(filename))
{
mkdir("sdmc:/backup/", 777);
return filename;
}
else
{
for (int i = 0; i < 99; i++)
{
sprintf(filename, "prodinfo.bin.%d", i);
sprintf(filename, "sdmc:/backup/prodinfo.bin.%d", i);

if (!fileExists(filename))
{
@@ -255,7 +225,7 @@ class Incognito
{
u8 hash[0x20];

mbedtls_sha256(buffer, sz, hash, 0);
sha256CalculateHash(hash, buffer, sz);

if (fsStorageWrite(&m_sh, hashOffset, hash, sizeof(hash)))
{
@@ -290,7 +260,7 @@ class Incognito
u8 hash1[0x20];
u8 hash2[0x20];

mbedtls_sha256(buffer, sz, hash1, 0);
sha256CalculateHash(hash1, buffer, sz);

if (fsStorageRead(&m_sh, hashOffset, hash2, sizeof(hash2)))
{
@@ -466,7 +436,7 @@ bool restore()

Incognito incognito;

if (!incognito.import("prodinfo.bin"))
if (!incognito.import("sdmc:/backup/prodinfo.bin"))
{
printf("error: failed to import prodinfo.bin\n");
return end();

0 comments on commit d365cb9

Please sign in to comment.
You can’t perform that action at this time.