diff --git a/NNTools.sln b/NNTools.sln
index d196221..b46668d 100644
--- a/NNTools.sln
+++ b/NNTools.sln
@@ -28,10 +28,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpolarssl", "lib\libpolar
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "liblz4", "lib\liblz4\liblz4.vcxproj", "{AB0C3362-63AB-480A-ADBC-2EF7D859778B}"
EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcrypto", "lib\libcrypto\libcrypto.vcxproj", "{6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcompress", "lib\libcompress\libcompress.vcxproj", "{CF01B5B7-730A-447F-9BB2-5EDA9B082177}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libpki", "lib\libpki\libpki.vcxproj", "{B9113734-6E84-44FF-8CF7-58199AA815C5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libes", "lib\libes\libes.vcxproj", "{7BE99936-0D40-410D-944B-4513C2EFF8DC}"
@@ -74,14 +70,6 @@ Global
{AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x64.Build.0 = Release|x64
{AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x86.ActiveCfg = Release|Win32
{AB0C3362-63AB-480A-ADBC-2EF7D859778B}.Release|x86.Build.0 = Release|Win32
- {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Debug|x64.ActiveCfg = Debug|x64
- {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Debug|x64.Build.0 = Debug|x64
- {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Debug|x86.ActiveCfg = Debug|Win32
- {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Debug|x86.Build.0 = Debug|Win32
- {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Release|x64.ActiveCfg = Release|x64
- {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Release|x64.Build.0 = Release|x64
- {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Release|x86.ActiveCfg = Release|Win32
- {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}.Release|x86.Build.0 = Release|Win32
{91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x64.ActiveCfg = Debug|x64
{91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x64.Build.0 = Debug|x64
{91BA9E79-8242-4F7D-B997-0DFEC95EA22B}.Debug|x86.ActiveCfg = Debug|Win32
@@ -98,14 +86,6 @@ Global
{7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x64.Build.0 = Release|x64
{7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x86.ActiveCfg = Release|Win32
{7BE99936-0D40-410D-944B-4513C2EFF8DC}.Release|x86.Build.0 = Release|Win32
- {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Debug|x64.ActiveCfg = Debug|x64
- {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Debug|x64.Build.0 = Debug|x64
- {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Debug|x86.ActiveCfg = Debug|Win32
- {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Debug|x86.Build.0 = Debug|Win32
- {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Release|x64.ActiveCfg = Release|x64
- {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Release|x64.Build.0 = Release|x64
- {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Release|x86.ActiveCfg = Release|Win32
- {CF01B5B7-730A-447F-9BB2-5EDA9B082177}.Release|x86.Build.0 = Release|Win32
{738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x64.ActiveCfg = Debug|x64
{738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x64.Build.0 = Debug|x64
{738CB4FC-CD9E-4B81-A04B-DEADBFA71C63}.Debug|x86.ActiveCfg = Debug|Win32
@@ -138,10 +118,8 @@ Global
{4D27EDB9-5110-44FE-8CE2-D46C5AD3C55B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
{394EFC16-BD3A-4538-B33D-7BA1EDB8DAC1} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
{AB0C3362-63AB-480A-ADBC-2EF7D859778B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
- {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
{91BA9E79-8242-4F7D-B997-0DFEC95EA22B} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
{7BE99936-0D40-410D-944B-4513C2EFF8DC} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
- {CF01B5B7-730A-447F-9BB2-5EDA9B082177} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
{738CB4FC-CD9E-4B81-A04B-DEADBFA71C63} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
{B9113734-6E84-44FF-8CF7-58199AA815C5} = {170B4A09-1B67-4A62-93AB-116EBCFF4A8C}
{AF09FA96-4463-417D-8FE6-526063F41349} = {E0863FCC-8E72-490D-BE1B-458F12CA8298}
diff --git a/lib/libcompress/libcompress.vcxproj b/lib/libcompress/libcompress.vcxproj
deleted file mode 100644
index 56a6671..0000000
--- a/lib/libcompress/libcompress.vcxproj
+++ /dev/null
@@ -1,133 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- 15.0
- {CF01B5B7-730A-447F-9BB2-5EDA9B082177}
- libcompress
- 10.0.16299.0
-
-
-
- StaticLibrary
- true
- v141
- MultiByte
-
-
- StaticLibrary
- false
- v141
- true
- MultiByte
-
-
- StaticLibrary
- true
- v141
- MultiByte
-
-
- StaticLibrary
- false
- v141
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Level3
- Disabled
- true
- true
- ..\libcompress\include;..\liblz4\include;
-
-
-
-
- Level3
- Disabled
- true
- true
- ..\libcompress\include;..\liblz4\include;
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- true
- ..\libcompress\include;..\liblz4\include;
-
-
- true
- true
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- true
- ..\libcompress\include;..\liblz4\include;
-
-
- true
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/lib/libcompress/libcompress.vcxproj.filters b/lib/libcompress/libcompress.vcxproj.filters
deleted file mode 100644
index ef951e4..0000000
--- a/lib/libcompress/libcompress.vcxproj.filters
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;ipp;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Header Files
-
-
-
-
- Source Files
-
-
-
-
-
-
\ No newline at end of file
diff --git a/lib/libcompress/libcompress.vcxproj.user b/lib/libcompress/libcompress.vcxproj.user
deleted file mode 100644
index be25078..0000000
--- a/lib/libcompress/libcompress.vcxproj.user
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/lib/libcompress/makefile b/lib/libcompress/makefile
deleted file mode 100644
index 3f009cb..0000000
--- a/lib/libcompress/makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-# Sources
-SRC_DIR = source
-OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c)))
-
-# External dependencies
-DEPENDS = lz4
-LIB_DIR = ..
-INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include")
-
-# Compiler Settings
-CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value
-CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value
-ARFLAGS = cr -o
-ifeq ($(OS),Windows_NT)
- # Windows Only Flags/Libs
- CC = x86_64-w64-mingw32-gcc
- CXX = x86_64-w64-mingw32-g++
- CFLAGS += -Wno-unused-but-set-variable
- CXXFLAGS += -Wno-unused-but-set-variable
-else
- UNAME = $(shell uname -s)
- ifeq ($(UNAME), Darwin)
- # MacOS Only Flags/Libs
- CFLAGS += -Wno-unused-private-field
- CXXFLAGS += -Wno-unused-private-field
- ARFLAGS = rc
- else
- # *nix Only Flags/Libs
- CFLAGS += -Wno-unused-but-set-variable
- CXXFLAGS += -Wno-unused-but-set-variable
- endif
-
-endif
-
-# Output
-OUTPUT = $(shell basename $(CURDIR)).a
-
-main: build
-
-rebuild: clean build
-
-build: $(OBJS)
- ar $(ARFLAGS) $(OUTPUT) $(OBJS)
-
-clean:
- rm -rf $(OUTPUT) $(OBJS)
\ No newline at end of file
diff --git a/lib/libcompress/source/lz4_wrapper.cpp b/lib/libcompress/source/lz4_wrapper.cpp
deleted file mode 100644
index 68b773c..0000000
--- a/lib/libcompress/source/lz4_wrapper.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include
-#include
-
-void compress::lz4::compressData(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t dst_capacity, uint32_t& compressed_size)
-{
- compressed_size = LZ4_compress_default((const char*)src, (char*)dst, (int)src_len, (int)dst_capacity);
-}
-
-void compress::lz4::decompressData(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t dst_capacity, uint32_t& decompressed_size)
-{
- decompressed_size = LZ4_decompress_safe((const char*)src, (char*)dst, (int)src_len, (int)dst_capacity);
-}
-
-
\ No newline at end of file
diff --git a/lib/libcrypto/libcrypto.vcxproj b/lib/libcrypto/libcrypto.vcxproj
deleted file mode 100644
index c401526..0000000
--- a/lib/libcrypto/libcrypto.vcxproj
+++ /dev/null
@@ -1,139 +0,0 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- 15.0
- {6ADBB60D-DBA0-411D-BD2D-A355EF8E0FE1}
- 10.0.15063.0
-
-
-
- StaticLibrary
- true
- v141
- MultiByte
-
-
- StaticLibrary
- false
- v141
- true
- MultiByte
-
-
- StaticLibrary
- true
- v141
- MultiByte
-
-
- StaticLibrary
- false
- v141
- true
- MultiByte
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Level3
- Disabled
- true
- ..\libfnd\include;..\libcrypto\include;..\libpolarssl\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
-
-
-
-
- Level3
- Disabled
- true
- ..\libfnd\include;..\libcrypto\include;..\libpolarssl\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- ..\libfnd\include;..\libcrypto\include;..\libpolarssl\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
-
-
- true
- true
-
-
-
-
- Level3
- MaxSpeed
- true
- true
- true
- ..\libfnd\include;..\libcrypto\include;..\libpolarssl\include;
- _MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
-
-
- true
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/lib/libcrypto/libcrypto.vcxproj.filters b/lib/libcrypto/libcrypto.vcxproj.filters
deleted file mode 100644
index 3c65bd5..0000000
--- a/lib/libcrypto/libcrypto.vcxproj.filters
+++ /dev/null
@@ -1,51 +0,0 @@
-
-
-
-
- {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
- cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
-
-
- {93995380-89BD-4b04-88EB-625FBE52EBFB}
- h;hh;hpp;hxx;hm;inl;inc;xsd
-
-
- {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
- rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
-
-
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
- Header Files
-
-
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
- Source Files
-
-
-
-
-
-
\ No newline at end of file
diff --git a/lib/libcrypto/libcrypto.vcxproj.user b/lib/libcrypto/libcrypto.vcxproj.user
deleted file mode 100644
index be25078..0000000
--- a/lib/libcrypto/libcrypto.vcxproj.user
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/lib/libcrypto/makefile b/lib/libcrypto/makefile
deleted file mode 100644
index f41f545..0000000
--- a/lib/libcrypto/makefile
+++ /dev/null
@@ -1,45 +0,0 @@
-# Sources
-SRC_DIR = source
-OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c)))
-
-# External dependencies
-DEPENDS = fnd polarssl
-LIB_DIR = ..
-INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include")
-
-# Compiler Settings
-CXXFLAGS = -std=c++11 $(INCS) -D__STDC_FORMAT_MACROS -Wall -Wno-unused-value
-CFLAGS = -std=c11 $(INCS) -Wall -Wno-unused-value
-ARFLAGS = cr -o
-ifeq ($(OS),Windows_NT)
- # Windows Only Flags/Libs
- CC = x86_64-w64-mingw32-gcc
- CXX = x86_64-w64-mingw32-g++
- CFLAGS += -Wno-unused-but-set-variable
- CXXFLAGS += -Wno-unused-but-set-variable
-else
- UNAME = $(shell uname -s)
- ifeq ($(UNAME), Darwin)
- # MacOS Only Flags/Libs
- CFLAGS += -arch x86_64 -Wno-unused-private-field
- CXXFLAGS += -arch x86_64 -Wno-unused-private-field
- ARFLAGS = rc
- else
- # *nix Only Flags/Libs
- CFLAGS += -Wno-unused-but-set-variable
- CXXFLAGS += -Wno-unused-but-set-variable
- endif
-endif
-
-# Output
-OUTPUT = $(shell basename $(CURDIR)).a
-
-main: build
-
-rebuild: clean build
-
-build: $(OBJS)
- ar $(ARFLAGS) $(OUTPUT) $(OBJS)
-
-clean:
- rm -rf $(OUTPUT) $(OBJS)
\ No newline at end of file
diff --git a/lib/libcrypto/source/base64_wrapper.cpp b/lib/libcrypto/source/base64_wrapper.cpp
deleted file mode 100644
index 1bc6f66..0000000
--- a/lib/libcrypto/source/base64_wrapper.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#include
-#include
-
-size_t crypto::base64::B64_GetEncodeLen(const uint8_t* src, size_t slen)
-{
- size_t dlen = 0;
-
- base64_encode(nullptr, &dlen, src, slen);
-
- return dlen;
-}
-
-void crypto::base64::B64_Encode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen)
-{
- base64_encode(dst, &dlen, src, slen);
-}
-
-size_t crypto::base64::B64_GetDecodeLen(const uint8_t* src, size_t slen)
-{
- size_t dlen = 0;
-
- base64_decode(nullptr, &dlen, src, slen);
-
- return dlen;
-}
-
-void crypto::base64::B64_Decode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen)
-{
- base64_decode(dst, &dlen, src, slen);
-}
\ No newline at end of file
diff --git a/lib/libcrypto/source/sha_wrapper.cpp b/lib/libcrypto/source/sha_wrapper.cpp
deleted file mode 100644
index c625c95..0000000
--- a/lib/libcrypto/source/sha_wrapper.cpp
+++ /dev/null
@@ -1,15 +0,0 @@
-#include
-#include
-#include
-
-using namespace crypto::sha;
-
-void crypto::sha::Sha1(const uint8_t* in, uint64_t size, uint8_t hash[kSha1HashLen])
-{
- sha1(in, size, hash);
-}
-
-void crypto::sha::Sha256(const uint8_t* in, uint64_t size, uint8_t hash[kSha256HashLen])
-{
- sha2(in, size, hash, false);
-}
\ No newline at end of file
diff --git a/lib/libes/include/nn/es/ticket.h b/lib/libes/include/nn/es/ticket.h
index ffb483b..d2e953d 100644
--- a/lib/libes/include/nn/es/ticket.h
+++ b/lib/libes/include/nn/es/ticket.h
@@ -1,7 +1,7 @@
#pragma once
#include
#include
-#include
+#include
namespace nn
{
@@ -44,7 +44,7 @@ namespace es
static const size_t kIssuerSize = 0x40;
static const byte_t kFormatVersion = 2;
- static const size_t kEncTitleKeySize = crypto::rsa::kRsa2048Size;
+ static const size_t kEncTitleKeySize = fnd::rsa::kRsa2048Size;
static const size_t kReservedRegionSize = 8;
static const size_t kRightsIdSize = 16;
}
diff --git a/lib/libes/libes.vcxproj b/lib/libes/libes.vcxproj
index 2c3482d..9c25a22 100644
--- a/lib/libes/libes.vcxproj
+++ b/lib/libes/libes.vcxproj
@@ -73,7 +73,7 @@
Level3
Disabled
true
- ..\libfnd\include;..\libcrypto\include;..\libes\include;
+ ..\libfnd\include;..\libes\include;
_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
@@ -82,7 +82,7 @@
Level3
Disabled
true
- ..\libfnd\include;..\libcrypto\include;..\libes\include;
+ ..\libfnd\include;..\libes\include;
_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
@@ -93,7 +93,7 @@
true
true
true
- ..\libfnd\include;..\libcrypto\include;..\libes\include;
+ ..\libfnd\include;..\libes\include;
_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
@@ -108,7 +108,7 @@
true
true
true
- ..\libfnd\include;..\libcrypto\include;..\libes\include;
+ ..\libfnd\include;..\libes\include;
_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
diff --git a/lib/libcrypto/include/crypto/aes.h b/lib/libfnd/include/fnd/aes.h
similarity index 99%
rename from lib/libcrypto/include/crypto/aes.h
rename to lib/libfnd/include/fnd/aes.h
index eb78ade..2c3016f 100644
--- a/lib/libcrypto/include/crypto/aes.h
+++ b/lib/libfnd/include/fnd/aes.h
@@ -2,7 +2,7 @@
#include
#include
-namespace crypto
+namespace fnd
{
namespace aes
{
diff --git a/lib/libcrypto/include/crypto/base64.h b/lib/libfnd/include/fnd/base64.h
similarity index 95%
rename from lib/libcrypto/include/crypto/base64.h
rename to lib/libfnd/include/fnd/base64.h
index 67c6ecd..f9bbc08 100644
--- a/lib/libcrypto/include/crypto/base64.h
+++ b/lib/libfnd/include/fnd/base64.h
@@ -2,7 +2,7 @@
#include
#include
-namespace crypto
+namespace fnd
{
namespace base64
{
diff --git a/lib/libcrypto/include/crypto/ecdsa.h b/lib/libfnd/include/fnd/ecdsa.h
similarity index 98%
rename from lib/libcrypto/include/crypto/ecdsa.h
rename to lib/libfnd/include/fnd/ecdsa.h
index 70f2803..e06880e 100644
--- a/lib/libcrypto/include/crypto/ecdsa.h
+++ b/lib/libfnd/include/fnd/ecdsa.h
@@ -2,7 +2,7 @@
#include
#include
-namespace crypto
+namespace fnd
{
namespace ecdsa
{
diff --git a/lib/libcompress/include/compress/lz4.h b/lib/libfnd/include/fnd/lz4.h
similarity index 94%
rename from lib/libcompress/include/compress/lz4.h
rename to lib/libfnd/include/fnd/lz4.h
index 482ee64..2d76857 100644
--- a/lib/libcompress/include/compress/lz4.h
+++ b/lib/libfnd/include/fnd/lz4.h
@@ -1,7 +1,7 @@
#pragma once
#include
-namespace compress
+namespace fnd
{
namespace lz4
{
diff --git a/lib/libcrypto/include/crypto/rsa.h b/lib/libfnd/include/fnd/rsa.h
similarity index 99%
rename from lib/libcrypto/include/crypto/rsa.h
rename to lib/libfnd/include/fnd/rsa.h
index 6588e8c..455fd21 100644
--- a/lib/libcrypto/include/crypto/rsa.h
+++ b/lib/libfnd/include/fnd/rsa.h
@@ -1,9 +1,9 @@
#pragma once
#include
#include
-#include
+#include
-namespace crypto
+namespace fnd
{
namespace rsa
{
diff --git a/lib/libcrypto/include/crypto/sha.h b/lib/libfnd/include/fnd/sha.h
similarity index 99%
rename from lib/libcrypto/include/crypto/sha.h
rename to lib/libfnd/include/fnd/sha.h
index fdd11ea..55d042d 100644
--- a/lib/libcrypto/include/crypto/sha.h
+++ b/lib/libfnd/include/fnd/sha.h
@@ -2,7 +2,7 @@
#include
#include
-namespace crypto
+namespace fnd
{
namespace sha
{
diff --git a/lib/libfnd/makefile b/lib/libfnd/makefile
index d453126..73af097 100644
--- a/lib/libfnd/makefile
+++ b/lib/libfnd/makefile
@@ -3,7 +3,7 @@ SRC_DIR = source
OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c)))
# External dependencies
-DEPENDS =
+DEPENDS = polarssl lz4
LIB_DIR = ..
INCS = -I"include" $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include")
diff --git a/lib/libcrypto/source/aes_wrapper.cpp b/lib/libfnd/source/aes_wrapper.cpp
similarity index 70%
rename from lib/libcrypto/source/aes_wrapper.cpp
rename to lib/libfnd/source/aes_wrapper.cpp
index 43f37d7..0013dce 100644
--- a/lib/libcrypto/source/aes_wrapper.cpp
+++ b/lib/libfnd/source/aes_wrapper.cpp
@@ -1,7 +1,7 @@
-#include
+#include
#include
-using namespace crypto::aes;
+using namespace fnd::aes;
inline void XorBlock(const uint8_t a[kAesBlockSize], const uint8_t b[kAesBlockSize], uint8_t out[kAesBlockSize])
{
@@ -16,7 +16,7 @@ inline void putbe32(uint8_t* data, uint32_t val) { data[0] = val >> 24; data[1]
-void crypto::aes::AesEcbDecrypt(const uint8_t * in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t * out)
+void fnd::aes::AesEcbDecrypt(const uint8_t * in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t * out)
{
aes_context ctx;
aes_setkey_dec(&ctx, key, 128);
@@ -28,7 +28,7 @@ void crypto::aes::AesEcbDecrypt(const uint8_t * in, uint64_t size, const uint8_t
}
-void crypto::aes::AesEcbEncrypt(const uint8_t * in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t * out)
+void fnd::aes::AesEcbEncrypt(const uint8_t * in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t * out)
{
aes_context ctx;
aes_setkey_enc(&ctx, key, 128);
@@ -38,7 +38,7 @@ void crypto::aes::AesEcbEncrypt(const uint8_t * in, uint64_t size, const uint8_t
}
}
-void crypto::aes::AesCtr(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t ctr[kAesBlockSize], uint8_t* out)
+void fnd::aes::AesCtr(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t ctr[kAesBlockSize], uint8_t* out)
{
aes_context ctx;
uint8_t block[kAesBlockSize] = { 0 };
@@ -48,7 +48,7 @@ void crypto::aes::AesCtr(const uint8_t* in, uint64_t size, const uint8_t key[kAe
aes_crypt_ctr(&ctx, size, &counterOffset, ctr, block, in, out);
}
-void crypto::aes::AesIncrementCounter(const uint8_t in[kAesBlockSize], size_t block_num, uint8_t out[kAesBlockSize])
+void fnd::aes::AesIncrementCounter(const uint8_t in[kAesBlockSize], size_t block_num, uint8_t out[kAesBlockSize])
{
memcpy(out, in, kAesBlockSize);
@@ -78,21 +78,21 @@ void crypto::aes::AesIncrementCounter(const uint8_t in[kAesBlockSize], size_t bl
putbe32(&out[12], ctr[0]);
}
-void crypto::aes::AesCbcDecrypt(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t iv[kAesBlockSize], uint8_t* out)
+void fnd::aes::AesCbcDecrypt(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t iv[kAesBlockSize], uint8_t* out)
{
aes_context ctx;
aes_setkey_dec(&ctx, key, 128);
aes_crypt_cbc(&ctx, AES_DECRYPT, size, iv, in, out);
}
-void crypto::aes::AesCbcEncrypt(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t iv[kAesBlockSize], uint8_t* out)
+void fnd::aes::AesCbcEncrypt(const uint8_t* in, uint64_t size, const uint8_t key[kAes128KeySize], uint8_t iv[kAesBlockSize], uint8_t* out)
{
aes_context ctx;
aes_setkey_enc(&ctx, key, 128);
aes_crypt_cbc(&ctx, AES_ENCRYPT, size, iv, in, out);
}
-void crypto::aes::AesXtsDecryptSector(const uint8_t * in, uint64_t sector_size, const uint8_t key1[kAes128KeySize], const uint8_t key2[kAes128KeySize], uint8_t tweak[kAesBlockSize], uint8_t * out)
+void fnd::aes::AesXtsDecryptSector(const uint8_t * in, uint64_t sector_size, const uint8_t key1[kAes128KeySize], const uint8_t key2[kAes128KeySize], uint8_t tweak[kAesBlockSize], uint8_t * out)
{
aes_context data_ctx;
aes_setkey_dec(&data_ctx, key1, 128);
@@ -116,7 +116,7 @@ void crypto::aes::AesXtsDecryptSector(const uint8_t * in, uint64_t sector_size,
}
}
-void crypto::aes::AesXtsEncryptSector(const uint8_t * in, uint64_t sector_size, const uint8_t key1[kAes128KeySize], const uint8_t key2[kAes128KeySize], uint8_t tweak[kAesBlockSize], uint8_t * out)
+void fnd::aes::AesXtsEncryptSector(const uint8_t * in, uint64_t sector_size, const uint8_t key1[kAes128KeySize], const uint8_t key2[kAes128KeySize], uint8_t tweak[kAesBlockSize], uint8_t * out)
{
aes_context data_ctx;
aes_setkey_enc(&data_ctx, key1, 128);
@@ -140,13 +140,13 @@ void crypto::aes::AesXtsEncryptSector(const uint8_t * in, uint64_t sector_size,
}
}
-void crypto::aes::AesXtsMakeTweak(uint8_t tweak[kAesBlockSize], size_t block_index)
+void fnd::aes::AesXtsMakeTweak(uint8_t tweak[kAesBlockSize], size_t block_index)
{
memset(tweak, 0, kAesBlockSize);
AesIncrementCounter(tweak, block_index, tweak);
}
-void crypto::aes::GaloisFunc(uint8_t x[kAesBlockSize])
+void fnd::aes::GaloisFunc(uint8_t x[kAesBlockSize])
{
uint8_t t = x[15];
diff --git a/lib/libfnd/source/base64_wrapper.cpp b/lib/libfnd/source/base64_wrapper.cpp
new file mode 100644
index 0000000..cd3e48b
--- /dev/null
+++ b/lib/libfnd/source/base64_wrapper.cpp
@@ -0,0 +1,30 @@
+#include
+#include
+
+size_t fnd::base64::B64_GetEncodeLen(const uint8_t* src, size_t slen)
+{
+ size_t dlen = 0;
+
+ base64_encode(nullptr, &dlen, src, slen);
+
+ return dlen;
+}
+
+void fnd::base64::B64_Encode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen)
+{
+ base64_encode(dst, &dlen, src, slen);
+}
+
+size_t fnd::base64::B64_GetDecodeLen(const uint8_t* src, size_t slen)
+{
+ size_t dlen = 0;
+
+ base64_decode(nullptr, &dlen, src, slen);
+
+ return dlen;
+}
+
+void fnd::base64::B64_Decode(const uint8_t* src, size_t slen, uint8_t* dst, size_t dlen)
+{
+ base64_decode(dst, &dlen, src, slen);
+}
\ No newline at end of file
diff --git a/lib/libfnd/source/lz4_wrapper.cpp b/lib/libfnd/source/lz4_wrapper.cpp
new file mode 100644
index 0000000..7dee71e
--- /dev/null
+++ b/lib/libfnd/source/lz4_wrapper.cpp
@@ -0,0 +1,14 @@
+#include
+#include
+
+void fnd::lz4::compressData(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t dst_capacity, uint32_t& compressed_size)
+{
+ compressed_size = LZ4_compress_default((const char*)src, (char*)dst, (int)src_len, (int)dst_capacity);
+}
+
+void fnd::lz4::decompressData(const uint8_t* src, uint32_t src_len, uint8_t* dst, uint32_t dst_capacity, uint32_t& decompressed_size)
+{
+ decompressed_size = LZ4_decompress_safe((const char*)src, (char*)dst, (int)src_len, (int)dst_capacity);
+}
+
+
\ No newline at end of file
diff --git a/lib/libcrypto/source/rsa_wrapper.cpp b/lib/libfnd/source/rsa_wrapper.cpp
similarity index 77%
rename from lib/libcrypto/source/rsa_wrapper.cpp
rename to lib/libfnd/source/rsa_wrapper.cpp
index dc2fefc..197a813 100644
--- a/lib/libcrypto/source/rsa_wrapper.cpp
+++ b/lib/libfnd/source/rsa_wrapper.cpp
@@ -1,9 +1,9 @@
-#include
+#include
#include
#include
-using namespace crypto::rsa;
-using namespace crypto::sha;
+using namespace fnd::rsa;
+using namespace fnd::sha;
int getWrappedHashType(HashType type)
{
@@ -57,7 +57,7 @@ uint32_t getWrappedHashSize(HashType type)
return size;
}
-int crypto::rsa::pkcs::rsaSign(const sRsa1024Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa1024Size])
+int fnd::rsa::pkcs::rsaSign(const sRsa1024Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa1024Size])
{
int ret;
rsa_context ctx;
@@ -74,7 +74,7 @@ int crypto::rsa::pkcs::rsaSign(const sRsa1024Key & key, HashType hash_type, cons
return ret;
}
-int crypto::rsa::pkcs::rsaVerify(const sRsa1024Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa1024Size])
+int fnd::rsa::pkcs::rsaVerify(const sRsa1024Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa1024Size])
{
static const uint8_t public_exponent[3] = { 0x01, 0x00, 0x01 };
@@ -93,7 +93,7 @@ int crypto::rsa::pkcs::rsaVerify(const sRsa1024Key & key, HashType hash_type, co
return ret;
}
-int crypto::rsa::pkcs::rsaSign(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa2048Size])
+int fnd::rsa::pkcs::rsaSign(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa2048Size])
{
int ret;
rsa_context ctx;
@@ -110,7 +110,7 @@ int crypto::rsa::pkcs::rsaSign(const sRsa2048Key & key, HashType hash_type, cons
return ret;
}
-int crypto::rsa::pkcs::rsaVerify(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa2048Size])
+int fnd::rsa::pkcs::rsaVerify(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa2048Size])
{
static const uint8_t public_exponent[3] = { 0x01, 0x00, 0x01 };
@@ -129,7 +129,7 @@ int crypto::rsa::pkcs::rsaVerify(const sRsa2048Key & key, HashType hash_type, co
return ret;
}
-int crypto::rsa::pkcs::rsaSign(const sRsa4096Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa4096Size])
+int fnd::rsa::pkcs::rsaSign(const sRsa4096Key & key, HashType hash_type, const uint8_t * hash, uint8_t signature[kRsa4096Size])
{
int ret;
rsa_context ctx;
@@ -146,7 +146,7 @@ int crypto::rsa::pkcs::rsaSign(const sRsa4096Key & key, HashType hash_type, cons
return ret;
}
-int crypto::rsa::pkcs::rsaVerify(const sRsa4096Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa4096Size])
+int fnd::rsa::pkcs::rsaVerify(const sRsa4096Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa4096Size])
{
static const uint8_t public_exponent[3] = { 0x01, 0x00, 0x01 };
@@ -165,7 +165,7 @@ int crypto::rsa::pkcs::rsaVerify(const sRsa4096Key & key, HashType hash_type, co
return ret;
}
-int crypto::rsa::pss::rsaVerify(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa2048Size])
+int fnd::rsa::pss::rsaVerify(const sRsa2048Key & key, HashType hash_type, const uint8_t * hash, const uint8_t signature[kRsa2048Size])
{
static const uint8_t public_exponent[3] = { 0x01, 0x00, 0x01 };
diff --git a/lib/libfnd/source/sha_wrapper.cpp b/lib/libfnd/source/sha_wrapper.cpp
new file mode 100644
index 0000000..a1c7eb4
--- /dev/null
+++ b/lib/libfnd/source/sha_wrapper.cpp
@@ -0,0 +1,15 @@
+#include
+#include
+#include
+
+using namespace fnd::sha;
+
+void fnd::sha::Sha1(const uint8_t* in, uint64_t size, uint8_t hash[kSha1HashLen])
+{
+ sha1(in, size, hash);
+}
+
+void fnd::sha::Sha256(const uint8_t* in, uint64_t size, uint8_t hash[kSha256HashLen])
+{
+ sha2(in, size, hash, false);
+}
\ No newline at end of file
diff --git a/lib/libhac-hb/libhac-hb.vcxproj b/lib/libhac-hb/libhac-hb.vcxproj
index 06ec389..bcee07e 100644
--- a/lib/libhac-hb/libhac-hb.vcxproj
+++ b/lib/libhac-hb/libhac-hb.vcxproj
@@ -77,7 +77,7 @@
true
true
true
- ..\libfnd\include;..\libcrypto\include;..\libhac\include;..\libhac-hb\include;
+ ..\libfnd\include;..\libhac\include;..\libhac-hb\include;
true
@@ -90,7 +90,7 @@
Disabled
true
true
- ..\libfnd\include;..\libcrypto\include;..\libhac\include;..\libhac-hb\include;
+ ..\libfnd\include;..\libhac\include;..\libhac-hb\include;
@@ -99,7 +99,7 @@
Disabled
true
true
- ..\libfnd\include;..\libcrypto\include;..\libhac\include;..\libhac-hb\include;
+ ..\libfnd\include;..\libhac\include;..\libhac-hb\include;
@@ -110,7 +110,7 @@
true
true
true
- ..\libfnd\include;..\libcrypto\include;..\libhac\include;..\libhac-hb\include;
+ ..\libfnd\include;..\libhac\include;..\libhac-hb\include;
true
diff --git a/lib/libhac/include/nn/hac/AccessControlInfoDescBinary.h b/lib/libhac/include/nn/hac/AccessControlInfoDescBinary.h
index f42b195..df7b004 100644
--- a/lib/libhac/include/nn/hac/AccessControlInfoDescBinary.h
+++ b/lib/libhac/include/nn/hac/AccessControlInfoDescBinary.h
@@ -50,14 +50,14 @@ namespace hac
void fromBytes(const byte_t* data, size_t len);
const fnd::Vec& getBytes() const;
- void generateSignature(const crypto::rsa::sRsa2048Key& key);
- void validateSignature(const crypto::rsa::sRsa2048Key& key) const;
+ void generateSignature(const fnd::rsa::sRsa2048Key& key);
+ void validateSignature(const fnd::rsa::sRsa2048Key& key) const;
// variables
void clear();
- const crypto::rsa::sRsa2048Key& getNcaHeaderSignature2Key() const;
- void setNcaHeaderSignature2Key(const crypto::rsa::sRsa2048Key& key);
+ const fnd::rsa::sRsa2048Key& getNcaHeaderSignature2Key() const;
+ void setNcaHeaderSignature2Key(const fnd::rsa::sRsa2048Key& key);
const fnd::List& getFlagList() const;
void setFlagList(const fnd::List& flags);
@@ -80,7 +80,7 @@ namespace hac
fnd::Vec mRawBinary;
// variables
- crypto::rsa::sRsa2048Key mNcaHeaderSignature2Key;
+ fnd::rsa::sRsa2048Key mNcaHeaderSignature2Key;
fnd::List mFlags;
sProgramIdRestrict mProgramIdRestrict;
nn::hac::FileSystemAccessControlBinary mFileSystemAccessControl;
diff --git a/lib/libhac/include/nn/hac/AesKeygen.h b/lib/libhac/include/nn/hac/AesKeygen.h
index 8d30eba..e3caef6 100644
--- a/lib/libhac/include/nn/hac/AesKeygen.h
+++ b/lib/libhac/include/nn/hac/AesKeygen.h
@@ -1,7 +1,7 @@
#pragma once
#include
#include
-#include
+#include
namespace nn
{
diff --git a/lib/libhac/include/nn/hac/ContentMetaBinary.h b/lib/libhac/include/nn/hac/ContentMetaBinary.h
index 2b44913..e742a6f 100644
--- a/lib/libhac/include/nn/hac/ContentMetaBinary.h
+++ b/lib/libhac/include/nn/hac/ContentMetaBinary.h
@@ -14,7 +14,7 @@ namespace hac
public:
struct ContentInfo
{
- crypto::sha::sSha256Hash hash;
+ fnd::sha::sSha256Hash hash;
byte_t nca_id[cnmt::kContentIdLen];
size_t size;
cnmt::ContentType type;
diff --git a/lib/libhac/include/nn/hac/HierarchicalIntegrityHeader.h b/lib/libhac/include/nn/hac/HierarchicalIntegrityHeader.h
index e8c9a3a..953b225 100644
--- a/lib/libhac/include/nn/hac/HierarchicalIntegrityHeader.h
+++ b/lib/libhac/include/nn/hac/HierarchicalIntegrityHeader.h
@@ -2,7 +2,7 @@
#include
#include
#include
-#include
+#include
namespace nn
{
@@ -54,8 +54,8 @@ namespace hac
const fnd::List& getLayerInfo() const;
void setLayerInfo(const fnd::List& layer_info);
- const fnd::List& getMasterHashList() const;
- void setMasterHashList(const fnd::List& master_hash_list);
+ const fnd::List& getMasterHashList() const;
+ void setMasterHashList(const fnd::List& master_hash_list);
private:
const std::string kModuleName = "HIERARCHICAL_INTEGRITY_HEADER";
@@ -64,7 +64,7 @@ namespace hac
// data
fnd::List mLayerInfo;
- fnd::List mMasterHashList;
+ fnd::List mMasterHashList;
};
}
}
\ No newline at end of file
diff --git a/lib/libhac/include/nn/hac/HierarchicalSha256Header.h b/lib/libhac/include/nn/hac/HierarchicalSha256Header.h
index eea54be..fe38b87 100644
--- a/lib/libhac/include/nn/hac/HierarchicalSha256Header.h
+++ b/lib/libhac/include/nn/hac/HierarchicalSha256Header.h
@@ -48,8 +48,8 @@ namespace hac
// variables
void clear();
- const crypto::sha::sSha256Hash& getMasterHash() const;
- void setMasterHash(const crypto::sha::sSha256Hash& master_hash);
+ const fnd::sha::sSha256Hash& getMasterHash() const;
+ void setMasterHash(const fnd::sha::sSha256Hash& master_hash);
size_t getHashBlockSize() const;
void setHashBlockSize(size_t hash_block_size);
@@ -63,7 +63,7 @@ namespace hac
fnd::Vec mRawBinary;
// data
- crypto::sha::sSha256Hash mMasterHash;
+ fnd::sha::sSha256Hash mMasterHash;
size_t mHashBlockSize;
fnd::List mLayerInfo;
};
diff --git a/lib/libhac/include/nn/hac/NcaHeader.h b/lib/libhac/include/nn/hac/NcaHeader.h
index f08ed53..5793ed2 100644
--- a/lib/libhac/include/nn/hac/NcaHeader.h
+++ b/lib/libhac/include/nn/hac/NcaHeader.h
@@ -22,7 +22,7 @@ namespace hac
byte_t index;
uint64_t offset;
uint64_t size;
- crypto::sha::sSha256Hash hash;
+ fnd::sha::sSha256Hash hash;
const sPartition& operator=(const sPartition& other)
{
@@ -88,8 +88,8 @@ namespace hac
void setRightsId(const byte_t* rights_id);
const fnd::List& getPartitions() const;
void setPartitions(const fnd::List& partitions);
- const fnd::List& getEncAesKeys() const;
- void setEncAesKeys(const fnd::List& keys);
+ const fnd::List& getEncAesKeys() const;
+ void setEncAesKeys(const fnd::List& keys);
private:
const std::string kModuleName = "NCA_HEADER";
@@ -109,7 +109,7 @@ namespace hac
uint32_t mSdkAddonVersion;
byte_t mRightsId[nca::kRightsIdLen];
fnd::List mPartitions;
- fnd::List mEncAesKeys;
+ fnd::List mEncAesKeys;
uint64_t blockNumToSize(uint32_t block_num) const;
uint32_t sizeToBlockNum(uint64_t real_size) const;
diff --git a/lib/libhac/include/nn/hac/NcaUtils.h b/lib/libhac/include/nn/hac/NcaUtils.h
index b3b14a6..0b4da75 100644
--- a/lib/libhac/include/nn/hac/NcaUtils.h
+++ b/lib/libhac/include/nn/hac/NcaUtils.h
@@ -9,7 +9,7 @@ namespace hac
{
public:
static inline size_t sectorToOffset(size_t sector_index) { return sector_index * nn::hac::nca::kSectorSize; }
- static void decryptNcaHeader(const byte_t* src, byte_t* dst, const crypto::aes::sAesXts128Key& key);
+ static void decryptNcaHeader(const byte_t* src, byte_t* dst, const fnd::aes::sAesXts128Key& key);
static byte_t getMasterKeyRevisionFromKeyGeneration(byte_t key_generation);
static void getNcaPartitionAesCtr(const nn::hac::sNcaFsHeader* hdr, byte_t* ctr);
};
diff --git a/lib/libhac/include/nn/hac/NsoHeader.h b/lib/libhac/include/nn/hac/NsoHeader.h
index 1593c7e..dbf08b6 100644
--- a/lib/libhac/include/nn/hac/NsoHeader.h
+++ b/lib/libhac/include/nn/hac/NsoHeader.h
@@ -60,7 +60,7 @@ namespace hac
sLayout memory_layout;
bool is_compressed;
bool is_hashed;
- crypto::sha::sSha256Hash hash;
+ fnd::sha::sSha256Hash hash;
void operator=(const sCodeSegment& other)
{
diff --git a/lib/libhac/include/nn/hac/PfsHeader.h b/lib/libhac/include/nn/hac/PfsHeader.h
index 4eab512..f3556f3 100644
--- a/lib/libhac/include/nn/hac/PfsHeader.h
+++ b/lib/libhac/include/nn/hac/PfsHeader.h
@@ -25,7 +25,7 @@ namespace hac
size_t offset;
size_t size;
size_t hash_protected_size;
- crypto::sha::sSha256Hash hash;
+ fnd::sha::sSha256Hash hash;
sFile& operator=(const sFile& other)
{
@@ -84,7 +84,7 @@ namespace hac
void setFsType(FsType type);
const fnd::List& getFileList() const;
void addFile(const std::string& name, size_t size);
- void addFile(const std::string& name, size_t size, size_t hash_protected_size, const crypto::sha::sSha256Hash& hash);
+ void addFile(const std::string& name, size_t size, size_t hash_protected_size, const fnd::sha::sSha256Hash& hash);
private:
const std::string kModuleName = "PFS_HEADER";
diff --git a/lib/libhac/include/nn/hac/XciHeader.h b/lib/libhac/include/nn/hac/XciHeader.h
index 89ff730..8ed9d4c 100644
--- a/lib/libhac/include/nn/hac/XciHeader.h
+++ b/lib/libhac/include/nn/hac/XciHeader.h
@@ -43,16 +43,16 @@ namespace hac
void setPackageId(uint64_t id);
uint32_t getValidDataEndPage() const;
void setValidDataEndPage(uint32_t page);
- const crypto::aes::sAesIvCtr& getAesCbcIv() const;
- void setAesCbcIv(const crypto::aes::sAesIvCtr& iv);
+ const fnd::aes::sAesIvCtr& getAesCbcIv() const;
+ void setAesCbcIv(const fnd::aes::sAesIvCtr& iv);
uint64_t getPartitionFsAddress() const;
void setPartitionFsAddress(uint64_t address);
uint64_t getPartitionFsSize() const;
void setPartitionFsSize(uint64_t size);
- const crypto::sha::sSha256Hash& getPartitionFsHash() const;
- void setPartitionFsHash(const crypto::sha::sSha256Hash& hash);
- const crypto::sha::sSha256Hash& getInitialDataHash() const;
- void setInitialDataHash(const crypto::sha::sSha256Hash& hash);
+ const fnd::sha::sSha256Hash& getPartitionFsHash() const;
+ void setPartitionFsHash(const fnd::sha::sSha256Hash& hash);
+ const fnd::sha::sSha256Hash& getInitialDataHash() const;
+ void setInitialDataHash(const fnd::sha::sSha256Hash& hash);
uint32_t getSelSec() const;
void setSelSec(uint32_t sel_sec);
uint32_t getSelT1Key() const;
@@ -101,11 +101,11 @@ namespace hac
byte_t mFlags;
uint64_t mPackageId;
uint32_t mValidDataEndPage;
- crypto::aes::sAesIvCtr mAesCbcIv;
+ fnd::aes::sAesIvCtr mAesCbcIv;
uint64_t mPartitionFsHeaderAddress;
uint64_t mPartitionFsHeaderSize;
- crypto::sha::sSha256Hash mPartitionFsHeaderHash;
- crypto::sha::sSha256Hash mInitialDataHash;
+ fnd::sha::sSha256Hash mPartitionFsHeaderHash;
+ fnd::sha::sSha256Hash mInitialDataHash;
uint32_t mSelSec;
uint32_t mSelT1Key;
uint32_t mSelKey;
diff --git a/lib/libhac/include/nn/hac/aci.h b/lib/libhac/include/nn/hac/aci.h
index e426469..55742e1 100644
--- a/lib/libhac/include/nn/hac/aci.h
+++ b/lib/libhac/include/nn/hac/aci.h
@@ -1,6 +1,6 @@
#pragma once
#include
-#include
+#include
#include
namespace nn
@@ -39,8 +39,8 @@ namespace hac
struct sAciDescHeader
{
- byte_t signature[crypto::rsa::kRsa2048Size];
- byte_t nca_rsa_signature2_modulus[crypto::rsa::kRsa2048Size];
+ byte_t signature[fnd::rsa::kRsa2048Size];
+ byte_t nca_rsa_signature2_modulus[fnd::rsa::kRsa2048Size];
le_uint32_t st_magic;
le_uint32_t signed_size;
byte_t reserved_00[0x4];
diff --git a/lib/libhac/include/nn/hac/cnmt.h b/lib/libhac/include/nn/hac/cnmt.h
index ededd0b..f7c8eb3 100644
--- a/lib/libhac/include/nn/hac/cnmt.h
+++ b/lib/libhac/include/nn/hac/cnmt.h
@@ -1,6 +1,6 @@
#pragma once
#include
-#include
+#include
namespace nn
{
@@ -83,7 +83,7 @@ namespace hac
struct sContentInfo
{
- crypto::sha::sSha256Hash content_hash;
+ fnd::sha::sSha256Hash content_hash;
byte_t content_id[cnmt::kContentIdLen];
le_uint32_t size_lower;
le_uint16_t size_higher;
diff --git a/lib/libhac/include/nn/hac/hierarchicalsha256.h b/lib/libhac/include/nn/hac/hierarchicalsha256.h
index e392c8c..fd424bb 100644
--- a/lib/libhac/include/nn/hac/hierarchicalsha256.h
+++ b/lib/libhac/include/nn/hac/hierarchicalsha256.h
@@ -1,6 +1,6 @@
#pragma once
#include
-#include
+#include
namespace nn
{
@@ -15,7 +15,7 @@ namespace hac
#pragma pack(push,1)
struct sHierarchicalSha256Header
{
- crypto::sha::sSha256Hash master_hash;
+ fnd::sha::sSha256Hash master_hash;
le_uint32_t hash_block_size;
le_uint32_t layer_num;
struct sLayer
diff --git a/lib/libhac/include/nn/hac/kc.h b/lib/libhac/include/nn/hac/kc.h
index e4f5949..e15d487 100644
--- a/lib/libhac/include/nn/hac/kc.h
+++ b/lib/libhac/include/nn/hac/kc.h
@@ -1,6 +1,6 @@
#pragma once
#include
-#include
+#include
#include
namespace nn
diff --git a/lib/libhac/include/nn/hac/nca.h b/lib/libhac/include/nn/hac/nca.h
index 3a3207c..4dac6f0 100644
--- a/lib/libhac/include/nn/hac/nca.h
+++ b/lib/libhac/include/nn/hac/nca.h
@@ -1,8 +1,8 @@
#pragma once
#include
-#include
-#include
-#include
+#include
+#include
+#include
#include
namespace nn
@@ -108,8 +108,8 @@ namespace hac
byte_t enabled;
byte_t reserved[7];
} partition[nca::kPartitionNum];
- crypto::sha::sSha256Hash partition_hash[nca::kPartitionNum];
- crypto::aes::sAes128Key enc_aes_key[nca::kAesKeyNum];
+ fnd::sha::sSha256Hash partition_hash[nca::kPartitionNum];
+ fnd::aes::sAes128Key enc_aes_key[nca::kAesKeyNum];
};
struct sNcaFsHeader
@@ -126,8 +126,8 @@ namespace hac
struct sNcaHeaderBlock
{
- byte_t signature_main[crypto::rsa::kRsa2048Size];
- byte_t signature_acid[crypto::rsa::kRsa2048Size];
+ byte_t signature_main[fnd::rsa::kRsa2048Size];
+ byte_t signature_acid[fnd::rsa::kRsa2048Size];
sNcaHeader header;
sNcaFsHeader fs_header[nn::hac::nca::kPartitionNum];
};
diff --git a/lib/libhac/include/nn/hac/nrr.h b/lib/libhac/include/nn/hac/nrr.h
index eae5180..452cc71 100644
--- a/lib/libhac/include/nn/hac/nrr.h
+++ b/lib/libhac/include/nn/hac/nrr.h
@@ -1,6 +1,6 @@
#pragma once
#include
-#include
+#include
#include
namespace nn
@@ -17,8 +17,8 @@ namespace hac
{
le_uint64_t application_id_mask;
le_uint64_t application_id_pattern;
- byte_t nrr_body_modulus[crypto::rsa::kRsa2048Size];
- byte_t nrr_cert_signature[crypto::rsa::kRsa2048Size];
+ byte_t nrr_body_modulus[fnd::rsa::kRsa2048Size];
+ byte_t nrr_cert_signature[fnd::rsa::kRsa2048Size];
};
struct sNrrHeader
@@ -26,7 +26,7 @@ namespace hac
le_uint32_t st_magic;
byte_t reserved_0[28];
sNrrCertificate certificate;
- byte_t nrr_body_signature[crypto::rsa::kRsa2048Size];
+ byte_t nrr_body_signature[fnd::rsa::kRsa2048Size];
le_uint64_t application_id;
le_uint32_t size;
byte_t reserved_1[4];
diff --git a/lib/libhac/include/nn/hac/nso.h b/lib/libhac/include/nn/hac/nso.h
index 4223b37..1b4a10b 100644
--- a/lib/libhac/include/nn/hac/nso.h
+++ b/lib/libhac/include/nn/hac/nso.h
@@ -1,6 +1,6 @@
#pragma once
#include
-#include
+#include
#include
namespace nn
@@ -58,9 +58,9 @@ namespace hac
sNsoSection embedded;
sNsoSection dyn_str;
sNsoSection dyn_sym;
- crypto::sha::sSha256Hash text_hash;
- crypto::sha::sSha256Hash ro_hash;
- crypto::sha::sSha256Hash data_hash;
+ fnd::sha::sSha256Hash text_hash;
+ fnd::sha::sSha256Hash ro_hash;
+ fnd::sha::sSha256Hash data_hash;
};
#pragma pack(pop)
diff --git a/lib/libhac/include/nn/hac/pfs.h b/lib/libhac/include/nn/hac/pfs.h
index 18f4e5c..4b7d189 100644
--- a/lib/libhac/include/nn/hac/pfs.h
+++ b/lib/libhac/include/nn/hac/pfs.h
@@ -1,5 +1,5 @@
#include
-#include
+#include
#include
namespace nn
@@ -37,7 +37,7 @@ namespace hac
le_uint32_t name_offset;
le_uint32_t hash_protected_size;
byte_t padding[8];
- crypto::sha::sSha256Hash hash;
+ fnd::sha::sSha256Hash hash;
}; // sizeof(0x40)
#pragma pack(pop)
}
diff --git a/lib/libhac/include/nn/hac/xci.h b/lib/libhac/include/nn/hac/xci.h
index 79be4d9..a995fa4 100644
--- a/lib/libhac/include/nn/hac/xci.h
+++ b/lib/libhac/include/nn/hac/xci.h
@@ -1,9 +1,9 @@
#pragma once
#include
#include
-#include
-#include
-#include
+#include
+#include
+#include
#include
namespace nn
@@ -80,11 +80,11 @@ namespace hac
le_uint64_t package_id;
le_uint32_t valid_data_end_page;
byte_t reserved_00[4];
- crypto::aes::sAesIvCtr aescbc_iv;
+ fnd::aes::sAesIvCtr aescbc_iv;
le_uint64_t partition_fs_header_address;
le_uint64_t partition_fs_header_size;
- crypto::sha::sSha256Hash partition_fs_header_hash;
- crypto::sha::sSha256Hash initial_data_hash;
+ fnd::sha::sSha256Hash partition_fs_header_hash;
+ fnd::sha::sSha256Hash initial_data_hash;
le_uint32_t sel_sec;
le_uint32_t sel_t1_key;
le_uint32_t sel_key;
@@ -107,7 +107,7 @@ namespace hac
struct sXciHeaderPage
{
- byte_t signature[crypto::rsa::kRsa2048Size];
+ byte_t signature[fnd::rsa::kRsa2048Size];
sXciHeader header;
}; // sizeof() = 512 (1 page)
@@ -124,8 +124,8 @@ namespace hac
{
sInitialData initial_data; // AES128-CCM encrypted {titlekey[16]}
byte_t encrypted_00[xci::kPageSize * 6]; // AES128-CTR encrypted {titlekey[16]}
- byte_t encrypted_00_aesctr_data[crypto::rsa::kRsa2048Size]; // RSA2048-OAEP-SHA256 encrypted AES-CTR data used for encrypted_00 {key[16],iv[16]}
- byte_t reserved[xci::kPageSize - crypto::rsa::kRsa2048Size];
+ byte_t encrypted_00_aesctr_data[fnd::rsa::kRsa2048Size]; // RSA2048-OAEP-SHA256 encrypted AES-CTR data used for encrypted_00 {key[16],iv[16]}
+ byte_t reserved[xci::kPageSize - fnd::rsa::kRsa2048Size];
}; // sizeof() = 512*8 (8 pages)
#pragma pack(pop)
diff --git a/lib/libhac/libhac.vcxproj b/lib/libhac/libhac.vcxproj
index 3ea2410..3ff63ae 100644
--- a/lib/libhac/libhac.vcxproj
+++ b/lib/libhac/libhac.vcxproj
@@ -175,7 +175,7 @@
Level3
Disabled
true
- ..\libfnd\include;..\libcrypto\include;..\libhac\include;
+ ..\libfnd\include;..\libhac\include;
_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
@@ -184,7 +184,7 @@
Level3
Disabled
true
- ..\libfnd\include;..\libcrypto\include;..\libhac\include;
+ ..\libfnd\include;..\libhac\include;
_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
@@ -195,7 +195,7 @@
true
true
true
- ..\libfnd\include;..\libcrypto\include;..\libhac\include;
+ ..\libfnd\include;..\libhac\include;
_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
@@ -210,7 +210,7 @@
true
true
true
- ..\libfnd\include;..\libcrypto\include;..\libhac\include;
+ ..\libfnd\include;..\libhac\include;
_MBCS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
diff --git a/lib/libhac/source/AccessControlInfoDescBinary.cpp b/lib/libhac/source/AccessControlInfoDescBinary.cpp
index d7c24d4..50ac86e 100644
--- a/lib/libhac/source/AccessControlInfoDescBinary.cpp
+++ b/lib/libhac/source/AccessControlInfoDescBinary.cpp
@@ -66,13 +66,13 @@ void nn::hac::AccessControlInfoDescBinary::toBytes()
sAciDescHeader* hdr = (sAciDescHeader*)mRawBinary.data();
// set rsa modulus
- memcpy(hdr->nca_rsa_signature2_modulus, mNcaHeaderSignature2Key.modulus, crypto::rsa::kRsa2048Size);
+ memcpy(hdr->nca_rsa_signature2_modulus, mNcaHeaderSignature2Key.modulus, fnd::rsa::kRsa2048Size);
// set type
hdr->st_magic = aci::kAciDescStructMagic;
// set "acid size"
- hdr->signed_size = (uint32_t)(total_size - crypto::rsa::kRsa2048Size);
+ hdr->signed_size = (uint32_t)(total_size - fnd::rsa::kRsa2048Size);
// set flags
uint32_t flags = 0;
@@ -128,7 +128,7 @@ void nn::hac::AccessControlInfoDescBinary::fromBytes(const byte_t* data, size_t
memcpy(mRawBinary.data(), data, mRawBinary.size());
// save variables
- memcpy(mNcaHeaderSignature2Key.modulus, hdr.nca_rsa_signature2_modulus, crypto::rsa::kRsa2048Size);
+ memcpy(mNcaHeaderSignature2Key.modulus, hdr.nca_rsa_signature2_modulus, fnd::rsa::kRsa2048Size);
for (size_t i = 0; i < 32; i++)
{
@@ -149,29 +149,29 @@ const fnd::Vec& nn::hac::AccessControlInfoDescBinary::getBytes() const
return mRawBinary;
}
-void nn::hac::AccessControlInfoDescBinary::generateSignature(const crypto::rsa::sRsa2048Key& key)
+void nn::hac::AccessControlInfoDescBinary::generateSignature(const fnd::rsa::sRsa2048Key& key)
{
if (mRawBinary.size() == 0)
toBytes();
- byte_t hash[crypto::sha::kSha256HashLen];
- crypto::sha::Sha256(mRawBinary.data() + crypto::rsa::kRsa2048Size, mRawBinary.size() - crypto::rsa::kRsa2048Size, hash);
+ byte_t hash[fnd::sha::kSha256HashLen];
+ fnd::sha::Sha256(mRawBinary.data() + fnd::rsa::kRsa2048Size, mRawBinary.size() - fnd::rsa::kRsa2048Size, hash);
- if (crypto::rsa::pkcs::rsaSign(key, crypto::sha::HASH_SHA256, hash, mRawBinary.data()) != 0)
+ if (fnd::rsa::pkcs::rsaSign(key, fnd::sha::HASH_SHA256, hash, mRawBinary.data()) != 0)
{
throw fnd::Exception(kModuleName, "Failed to sign Access Control Info Desc");
}
}
-void nn::hac::AccessControlInfoDescBinary::validateSignature(const crypto::rsa::sRsa2048Key& key) const
+void nn::hac::AccessControlInfoDescBinary::validateSignature(const fnd::rsa::sRsa2048Key& key) const
{
if (mRawBinary.size() == 0)
throw fnd::Exception(kModuleName, "No Access Control Info Desc binary exists to verify");
- byte_t hash[crypto::sha::kSha256HashLen];
- crypto::sha::Sha256(mRawBinary.data() + crypto::rsa::kRsa2048Size, mRawBinary.size() - crypto::rsa::kRsa2048Size, hash);
+ byte_t hash[fnd::sha::kSha256HashLen];
+ fnd::sha::Sha256(mRawBinary.data() + fnd::rsa::kRsa2048Size, mRawBinary.size() - fnd::rsa::kRsa2048Size, hash);
- if (crypto::rsa::pss::rsaVerify(key, crypto::sha::HASH_SHA256, hash, mRawBinary.data()) != 0)
+ if (fnd::rsa::pss::rsaVerify(key, fnd::sha::HASH_SHA256, hash, mRawBinary.data()) != 0)
{
throw fnd::Exception(kModuleName, "Failed to verify Access Control Info Desc");
}
@@ -189,12 +189,12 @@ void nn::hac::AccessControlInfoDescBinary::clear()
mKernelCapabilities.clear();
}
-const crypto::rsa::sRsa2048Key& nn::hac::AccessControlInfoDescBinary::getNcaHeaderSignature2Key() const
+const fnd::rsa::sRsa2048Key& nn::hac::AccessControlInfoDescBinary::getNcaHeaderSignature2Key() const
{
return mNcaHeaderSignature2Key;
}
-void nn::hac::AccessControlInfoDescBinary::setNcaHeaderSignature2Key(const crypto::rsa::sRsa2048Key& key)
+void nn::hac::AccessControlInfoDescBinary::setNcaHeaderSignature2Key(const fnd::rsa::sRsa2048Key& key)
{
mNcaHeaderSignature2Key = key;
}
diff --git a/lib/libhac/source/AesKeygen.cpp b/lib/libhac/source/AesKeygen.cpp
index 7233394..12d7878 100644
--- a/lib/libhac/source/AesKeygen.cpp
+++ b/lib/libhac/source/AesKeygen.cpp
@@ -2,18 +2,18 @@
void nn::hac::AesKeygen::generateKey(byte_t* dst, const byte_t* src, const byte_t* src_key)
{
- crypto::aes::AesEcbDecrypt(src, sizeof(crypto::aes::sAes128Key), src_key, dst);
+ fnd::aes::AesEcbDecrypt(src, sizeof(fnd::aes::sAes128Key), src_key, dst);
}
void nn::hac::AesKeygen::generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src1_key)
{
- crypto::aes::sAes128Key src2_key;
+ fnd::aes::sAes128Key src2_key;
generateKey(src2_key.key, src1, src1_key);
generateKey(dst, src2, src2_key.key);
}
void nn::hac::AesKeygen::generateKey(byte_t* dst, const byte_t* src1, const byte_t* src2, const byte_t* src3, const byte_t* src1_key)
{
- crypto::aes::sAes128Key src3_key;
+ fnd::aes::sAes128Key src3_key;
generateKey(src3_key.key, src1, src2, src1_key);
generateKey(dst, src3, src3_key.key);
}
\ No newline at end of file
diff --git a/lib/libhac/source/HierarchicalIntegrityHeader.cpp b/lib/libhac/source/HierarchicalIntegrityHeader.cpp
index 3075a1c..c842a4e 100644
--- a/lib/libhac/source/HierarchicalIntegrityHeader.cpp
+++ b/lib/libhac/source/HierarchicalIntegrityHeader.cpp
@@ -98,8 +98,8 @@ void nn::hac::HierarchicalIntegrityHeader::fromBytes(const byte_t* data, size_t
}
// save hash list
- const crypto::sha::sSha256Hash* hash_list = (const crypto::sha::sSha256Hash*)(mRawBinary.data() + master_hash_offset);
- for (size_t i = 0; i < hdr->master_hash_size.get()/sizeof(crypto::sha::sSha256Hash); i++)
+ const fnd::sha::sSha256Hash* hash_list = (const fnd::sha::sSha256Hash*)(mRawBinary.data() + master_hash_offset);
+ for (size_t i = 0; i < hdr->master_hash_size.get()/sizeof(fnd::sha::sSha256Hash); i++)
{
mMasterHashList.addElement(hash_list[i]);
}
@@ -126,12 +126,12 @@ void nn::hac::HierarchicalIntegrityHeader::setLayerInfo(const fnd::List&
mLayerInfo = layer_info;
}
-const fnd::List& nn::hac::HierarchicalIntegrityHeader::getMasterHashList() const
+const fnd::List& nn::hac::HierarchicalIntegrityHeader::getMasterHashList() const
{
return mMasterHashList;
}
-void nn::hac::HierarchicalIntegrityHeader::setMasterHashList(const fnd::List& master_hash_list)
+void nn::hac::HierarchicalIntegrityHeader::setMasterHashList(const fnd::List& master_hash_list)
{
mMasterHashList = master_hash_list;
}
\ No newline at end of file
diff --git a/lib/libhac/source/HierarchicalSha256Header.cpp b/lib/libhac/source/HierarchicalSha256Header.cpp
index 6b3f42c..e959f0b 100644
--- a/lib/libhac/source/HierarchicalSha256Header.cpp
+++ b/lib/libhac/source/HierarchicalSha256Header.cpp
@@ -76,17 +76,17 @@ const fnd::Vec& nn::hac::HierarchicalSha256Header::getBytes() const
void nn::hac::HierarchicalSha256Header::clear()
{
- memset(mMasterHash.bytes, 0, sizeof(crypto::sha::sSha256Hash));
+ memset(mMasterHash.bytes, 0, sizeof(fnd::sha::sSha256Hash));
mHashBlockSize = 0;
mLayerInfo.clear();
}
-const crypto::sha::sSha256Hash & nn::hac::HierarchicalSha256Header::getMasterHash() const
+const fnd::sha::sSha256Hash & nn::hac::HierarchicalSha256Header::getMasterHash() const
{
return mMasterHash;
}
-void nn::hac::HierarchicalSha256Header::setMasterHash(const crypto::sha::sSha256Hash & master_hash)
+void nn::hac::HierarchicalSha256Header::setMasterHash(const fnd::sha::sSha256Hash & master_hash)
{
mMasterHash = master_hash;
}
diff --git a/lib/libhac/source/NcaHeader.cpp b/lib/libhac/source/NcaHeader.cpp
index 4a546da..12edd1d 100644
--- a/lib/libhac/source/NcaHeader.cpp
+++ b/lib/libhac/source/NcaHeader.cpp
@@ -306,12 +306,12 @@ void nn::hac::NcaHeader::setPartitions(const fnd::List& nn::hac::NcaHeader::getEncAesKeys() const
+const fnd::List& nn::hac::NcaHeader::getEncAesKeys() const
{
return mEncAesKeys;
}
-void nn::hac::NcaHeader::setEncAesKeys(const fnd::List& keys)
+void nn::hac::NcaHeader::setEncAesKeys(const fnd::List& keys)
{
mEncAesKeys = keys;
}
diff --git a/lib/libhac/source/NcaUtils.cpp b/lib/libhac/source/NcaUtils.cpp
index 12f78c1..9b71878 100644
--- a/lib/libhac/source/NcaUtils.cpp
+++ b/lib/libhac/source/NcaUtils.cpp
@@ -1,21 +1,21 @@
#include
-void nn::hac::NcaUtils::decryptNcaHeader(const byte_t* src, byte_t* dst, const crypto::aes::sAesXts128Key& key)
+void nn::hac::NcaUtils::decryptNcaHeader(const byte_t* src, byte_t* dst, const fnd::aes::sAesXts128Key& key)
{
- byte_t tweak[crypto::aes::kAesBlockSize];
+ byte_t tweak[fnd::aes::kAesBlockSize];
// decrypt main header
byte_t raw_hdr[nn::hac::nca::kSectorSize];
- crypto::aes::AesXtsMakeTweak(tweak, 1);
- crypto::aes::AesXtsDecryptSector(src + sectorToOffset(1), nn::hac::nca::kSectorSize, key.key[0], key.key[1], tweak, raw_hdr);
+ fnd::aes::AesXtsMakeTweak(tweak, 1);
+ fnd::aes::AesXtsDecryptSector(src + sectorToOffset(1), nn::hac::nca::kSectorSize, key.key[0], key.key[1], tweak, raw_hdr);
bool useNca2SectorIndex = ((nn::hac::sNcaHeader*)(raw_hdr))->st_magic.get() == nn::hac::nca::kNca2StructMagic;
// decrypt whole header
for (size_t i = 0; i < nn::hac::nca::kHeaderSectorNum; i++)
{
- crypto::aes::AesXtsMakeTweak(tweak, (i > 1 && useNca2SectorIndex)? 0 : i);
- crypto::aes::AesXtsDecryptSector(src + sectorToOffset(i), nn::hac::nca::kSectorSize, key.key[0], key.key[1], tweak, dst + sectorToOffset(i));
+ fnd::aes::AesXtsMakeTweak(tweak, (i > 1 && useNca2SectorIndex)? 0 : i);
+ fnd::aes::AesXtsDecryptSector(src + sectorToOffset(i), nn::hac::nca::kSectorSize, key.key[0], key.key[1], tweak, dst + sectorToOffset(i));
}
}
diff --git a/lib/libhac/source/PfsHeader.cpp b/lib/libhac/source/PfsHeader.cpp
index 7923992..14cd2ec 100644
--- a/lib/libhac/source/PfsHeader.cpp
+++ b/lib/libhac/source/PfsHeader.cpp
@@ -222,7 +222,7 @@ void nn::hac::PfsHeader::addFile(const std::string & name, size_t size)
mFileList.addElement({ name, 0, size, 0 });
}
-void nn::hac::PfsHeader::addFile(const std::string & name, size_t size, size_t hash_protected_size, const crypto::sha::sSha256Hash& hash)
+void nn::hac::PfsHeader::addFile(const std::string & name, size_t size, size_t hash_protected_size, const fnd::sha::sSha256Hash& hash)
{
mFileList.addElement({ name, 0, size, hash_protected_size, hash });
}
diff --git a/lib/libhac/source/XciHeader.cpp b/lib/libhac/source/XciHeader.cpp
index 390f529..e786a7f 100644
--- a/lib/libhac/source/XciHeader.cpp
+++ b/lib/libhac/source/XciHeader.cpp
@@ -119,7 +119,7 @@ void nn::hac::XciHeader::fromBytes(const byte_t* data, size_t len)
mFlags = hdr->flags;
mPackageId = hdr->package_id.get();
mValidDataEndPage = hdr->valid_data_end_page.get();
- for (size_t i = 0; i < crypto::aes::kAesBlockSize; i++)
+ for (size_t i = 0; i < fnd::aes::kAesBlockSize; i++)
mAesCbcIv.iv[i] = hdr->aescbc_iv.iv[15-i];
mPartitionFsHeaderAddress = hdr->partition_fs_header_address.get();
mPartitionFsHeaderSize = hdr->partition_fs_header_size.get();
@@ -277,12 +277,12 @@ void nn::hac::XciHeader::setValidDataEndPage(uint32_t page)
mValidDataEndPage = page;
}
-const crypto::aes::sAesIvCtr& nn::hac::XciHeader::getAesCbcIv() const
+const fnd::aes::sAesIvCtr& nn::hac::XciHeader::getAesCbcIv() const
{
return mAesCbcIv;
}
-void nn::hac::XciHeader::setAesCbcIv(const crypto::aes::sAesIvCtr& iv)
+void nn::hac::XciHeader::setAesCbcIv(const fnd::aes::sAesIvCtr& iv)
{
mAesCbcIv = iv;
}
@@ -307,22 +307,22 @@ void nn::hac::XciHeader::setPartitionFsSize(uint64_t size)
mPartitionFsHeaderSize = size;
}
-const crypto::sha::sSha256Hash& nn::hac::XciHeader::getPartitionFsHash() const
+const fnd::sha::sSha256Hash& nn::hac::XciHeader::getPartitionFsHash() const
{
return mPartitionFsHeaderHash;
}
-void nn::hac::XciHeader::setPartitionFsHash(const crypto::sha::sSha256Hash& hash)
+void nn::hac::XciHeader::setPartitionFsHash(const fnd::sha::sSha256Hash& hash)
{
mPartitionFsHeaderHash = hash;
}
-const crypto::sha::sSha256Hash& nn::hac::XciHeader::getInitialDataHash() const
+const fnd::sha::sSha256Hash& nn::hac::XciHeader::getInitialDataHash() const
{
return mInitialDataHash;
}
-void nn::hac::XciHeader::setInitialDataHash(const crypto::sha::sSha256Hash& hash)
+void nn::hac::XciHeader::setInitialDataHash(const fnd::sha::sSha256Hash& hash)
{
mInitialDataHash = hash;
}
diff --git a/lib/libhac/source/XciUtils.cpp b/lib/libhac/source/XciUtils.cpp
index 40aa00a..1954699 100644
--- a/lib/libhac/source/XciUtils.cpp
+++ b/lib/libhac/source/XciUtils.cpp
@@ -10,7 +10,7 @@ void nn::hac::XciUtils::getXciHeaderAesIv(const nn::hac::sXciHeader* hdr, byte_t
void nn::hac::XciUtils::decryptXciHeader(const byte_t* src, byte_t* dst, const byte_t* key)
{
- byte_t iv[crypto::aes::kAesBlockSize];
+ byte_t iv[fnd::aes::kAesBlockSize];
getXciHeaderAesIv((const nn::hac::sXciHeader*)src, iv);
@@ -18,5 +18,5 @@ void nn::hac::XciUtils::decryptXciHeader(const byte_t* src, byte_t* dst, const b
memcpy(dst, src, nn::hac::xci::kHeaderEncOffset);
// decrypt encrypted data
- crypto::aes::AesCbcDecrypt(src + nn::hac::xci::kHeaderEncOffset, nn::hac::xci::kHeaderEncSize, key, iv, dst + nn::hac::xci::kHeaderEncOffset);
+ fnd::aes::AesCbcDecrypt(src + nn::hac::xci::kHeaderEncOffset, nn::hac::xci::kHeaderEncSize, key, iv, dst + nn::hac::xci::kHeaderEncOffset);
}
\ No newline at end of file
diff --git a/lib/libpki/include/nn/pki/CertificateBody.h b/lib/libpki/include/nn/pki/CertificateBody.h
index 497cca1..ea9042a 100644
--- a/lib/libpki/include/nn/pki/CertificateBody.h
+++ b/lib/libpki/include/nn/pki/CertificateBody.h
@@ -38,14 +38,14 @@ namespace pki
uint32_t getCertId() const;
void setCertId(uint32_t id);
- const crypto::rsa::sRsa4096Key& getRsa4098PublicKey() const;
- void setRsa4098PublicKey(const crypto::rsa::sRsa4096Key& key);
+ const fnd::rsa::sRsa4096Key& getRsa4098PublicKey() const;
+ void setRsa4098PublicKey(const fnd::rsa::sRsa4096Key& key);
- const crypto::rsa::sRsa2048Key& getRsa2048PublicKey() const;
- void setRsa2048PublicKey(const crypto::rsa::sRsa2048Key& key);
+ const fnd::rsa::sRsa2048Key& getRsa2048PublicKey() const;
+ void setRsa2048PublicKey(const fnd::rsa::sRsa2048Key& key);
- const crypto::ecdsa::sEcdsa240Point& getEcdsa240PublicKey() const;
- void setEcdsa240PublicKey(const crypto::ecdsa::sEcdsa240Point& key);
+ const fnd::ecdsa::sEcdsa240Point& getEcdsa240PublicKey() const;
+ void setEcdsa240PublicKey(const fnd::ecdsa::sEcdsa240Point& key);
private:
const std::string kModuleName = "CERTIFICATE_BODY";
@@ -59,9 +59,9 @@ namespace pki
uint32_t mCertId;
cert::PublicKeyType mPublicKeyType;
- crypto::rsa::sRsa4096Key mRsa4096PublicKey;
- crypto::rsa::sRsa2048Key mRsa2048PublicKey;
- crypto::ecdsa::sEcdsa240Point mEcdsa240PublicKey;
+ fnd::rsa::sRsa4096Key mRsa4096PublicKey;
+ fnd::rsa::sRsa2048Key mRsa2048PublicKey;
+ fnd::ecdsa::sEcdsa240Point mEcdsa240PublicKey;
};
}
}
\ No newline at end of file
diff --git a/lib/libpki/include/nn/pki/SignUtils.h b/lib/libpki/include/nn/pki/SignUtils.h
index 873ff41..c3035fd 100644
--- a/lib/libpki/include/nn/pki/SignUtils.h
+++ b/lib/libpki/include/nn/pki/SignUtils.h
@@ -1,6 +1,6 @@
#pragma once
#include
-#include
+#include
namespace nn
{
diff --git a/lib/libpki/include/nn/pki/cert.h b/lib/libpki/include/nn/pki/cert.h
index 1fd7a1b..fc2ea54 100644
--- a/lib/libpki/include/nn/pki/cert.h
+++ b/lib/libpki/include/nn/pki/cert.h
@@ -1,9 +1,9 @@
#pragma once
#include
#include
-#include
-#include
-#include
+#include
+#include
+#include
namespace nn
{
@@ -32,21 +32,21 @@ namespace pki
struct sRsa4096PublicKeyBlock
{
- byte_t modulus[crypto::rsa::kRsa4096Size];
- byte_t public_exponent[crypto::rsa::kRsaPublicExponentSize];
+ byte_t modulus[fnd::rsa::kRsa4096Size];
+ byte_t public_exponent[fnd::rsa::kRsaPublicExponentSize];
byte_t padding[0x34];
};
struct sRsa2048PublicKeyBlock
{
- byte_t modulus[crypto::rsa::kRsa2048Size];
- byte_t public_exponent[crypto::rsa::kRsaPublicExponentSize];
+ byte_t modulus[fnd::rsa::kRsa2048Size];
+ byte_t public_exponent[fnd::rsa::kRsaPublicExponentSize];
byte_t padding[0x34];
};
struct sEcdsa240PublicKeyBlock
{
- crypto::ecdsa::sEcdsa240Point public_key;
+ fnd::ecdsa::sEcdsa240Point public_key;
byte_t padding[0x3C];
};
#pragma pack(pop)
diff --git a/lib/libpki/include/nn/pki/sign.h b/lib/libpki/include/nn/pki/sign.h
index 7d31f35..bc89d01 100644
--- a/lib/libpki/include/nn/pki/sign.h
+++ b/lib/libpki/include/nn/pki/sign.h
@@ -1,9 +1,9 @@
#pragma once
#include
#include
-#include
-#include
-#include
+#include
+#include
+#include
namespace nn
{
@@ -43,14 +43,14 @@ namespace pki
struct sRsa4096SignBlock
{
be_uint32_t sign_type;
- byte_t signature[crypto::rsa::kRsa4096Size];
+ byte_t signature[fnd::rsa::kRsa4096Size];
byte_t padding[0x3C];
};
struct sRsa2048SignBlock
{
be_uint32_t sign_type;
- byte_t signature[crypto::rsa::kRsa2048Size];
+ byte_t signature[fnd::rsa::kRsa2048Size];
byte_t padding[0x3C];
};
diff --git a/lib/libpki/libpki.vcxproj b/lib/libpki/libpki.vcxproj
index ef497f5..f638e1e 100644
--- a/lib/libpki/libpki.vcxproj
+++ b/lib/libpki/libpki.vcxproj
@@ -77,7 +77,7 @@
true
true
true
- ..\libfnd\include;..\libcrypto\include;..\libpki\include;
+ ..\libfnd\include;..\libpki\include;
_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
@@ -91,7 +91,7 @@
Disabled
true
true
- ..\libfnd\include;..\libcrypto\include;..\libpki\include;
+ ..\libfnd\include;..\libpki\include;
_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
@@ -101,7 +101,7 @@
Disabled
true
true
- ..\libfnd\include;..\libcrypto\include;..\libpki\include;
+ ..\libfnd\include;..\libpki\include;
_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
@@ -113,7 +113,7 @@
true
true
true
- ..\libfnd\include;..\libcrypto\include;..\libpki\include;
+ ..\libfnd\include;..\libpki\include;
_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)
diff --git a/lib/libpki/source/CertificateBody.cpp b/lib/libpki/source/CertificateBody.cpp
index bcf3d03..2c2b8c6 100644
--- a/lib/libpki/source/CertificateBody.cpp
+++ b/lib/libpki/source/CertificateBody.cpp
@@ -168,9 +168,9 @@ void nn::pki::CertificateBody::clear()
mCertId = 0;
mPublicKeyType = cert::RSA2048;
- memset(&mRsa4096PublicKey, 0, sizeof(crypto::rsa::sRsa4096Key));
- memset(&mRsa2048PublicKey, 0, sizeof(crypto::rsa::sRsa2048Key));
- memset(&mEcdsa240PublicKey, 0, sizeof(crypto::ecdsa::sEcdsa240Point));
+ memset(&mRsa4096PublicKey, 0, sizeof(fnd::rsa::sRsa4096Key));
+ memset(&mRsa2048PublicKey, 0, sizeof(fnd::rsa::sRsa2048Key));
+ memset(&mEcdsa240PublicKey, 0, sizeof(fnd::ecdsa::sEcdsa240Point));
}
const std::string& nn::pki::CertificateBody::getIssuer() const
@@ -223,32 +223,32 @@ void nn::pki::CertificateBody::setCertId(uint32_t id)
mCertId = id;
}
-const crypto::rsa::sRsa4096Key& nn::pki::CertificateBody::getRsa4098PublicKey() const
+const fnd::rsa::sRsa4096Key& nn::pki::CertificateBody::getRsa4098PublicKey() const
{
return mRsa4096PublicKey;
}
-void nn::pki::CertificateBody::setRsa4098PublicKey(const crypto::rsa::sRsa4096Key& key)
+void nn::pki::CertificateBody::setRsa4098PublicKey(const fnd::rsa::sRsa4096Key& key)
{
mRsa4096PublicKey = key;
}
-const crypto::rsa::sRsa2048Key& nn::pki::CertificateBody::getRsa2048PublicKey() const
+const fnd::rsa::sRsa2048Key& nn::pki::CertificateBody::getRsa2048PublicKey() const
{
return mRsa2048PublicKey;
}
-void nn::pki::CertificateBody::setRsa2048PublicKey(const crypto::rsa::sRsa2048Key& key)
+void nn::pki::CertificateBody::setRsa2048PublicKey(const fnd::rsa::sRsa2048Key& key)
{
mRsa2048PublicKey = key;
}
-const crypto::ecdsa::sEcdsa240Point& nn::pki::CertificateBody::getEcdsa240PublicKey() const
+const fnd::ecdsa::sEcdsa240Point& nn::pki::CertificateBody::getEcdsa240PublicKey() const
{
return mEcdsa240PublicKey;
}
-void nn::pki::CertificateBody::setEcdsa240PublicKey(const crypto::ecdsa::sEcdsa240Point& key)
+void nn::pki::CertificateBody::setEcdsa240PublicKey(const fnd::ecdsa::sEcdsa240Point& key)
{
mEcdsa240PublicKey = key;
}
\ No newline at end of file
diff --git a/lib/libpki/source/SignatureBlock.cpp b/lib/libpki/source/SignatureBlock.cpp
index b25944a..1088ea4 100644
--- a/lib/libpki/source/SignatureBlock.cpp
+++ b/lib/libpki/source/SignatureBlock.cpp
@@ -40,12 +40,12 @@ void nn::pki::SignatureBlock::toBytes()
case (sign::SIGN_ID_RSA4096_SHA1):
case (sign::SIGN_ID_RSA4096_SHA256):
totalSize = sizeof(sRsa4096SignBlock);
- sigSize = crypto::rsa::kRsa4096Size;
+ sigSize = fnd::rsa::kRsa4096Size;
break;
case (sign::SIGN_ID_RSA2048_SHA1):
case (sign::SIGN_ID_RSA2048_SHA256):
totalSize = sizeof(sRsa2048SignBlock);
- sigSize = crypto::rsa::kRsa2048Size;
+ sigSize = fnd::rsa::kRsa2048Size;
break;
case (sign::SIGN_ID_ECDSA240_SHA1):
case (sign::SIGN_ID_ECDSA240_SHA256):
@@ -83,12 +83,12 @@ void nn::pki::SignatureBlock::fromBytes(const byte_t* src, size_t size)
case (sign::SIGN_ID_RSA4096_SHA1):
case (sign::SIGN_ID_RSA4096_SHA256):
totalSize = sizeof(sRsa4096SignBlock);
- sigSize = crypto::rsa::kRsa4096Size;
+ sigSize = fnd::rsa::kRsa4096Size;
break;
case (sign::SIGN_ID_RSA2048_SHA1):
case (sign::SIGN_ID_RSA2048_SHA256):
totalSize = sizeof(sRsa2048SignBlock);
- sigSize = crypto::rsa::kRsa2048Size;
+ sigSize = fnd::rsa::kRsa2048Size;
break;
case (sign::SIGN_ID_ECDSA240_SHA1):
case (sign::SIGN_ID_ECDSA240_SHA256):
@@ -106,12 +106,12 @@ void nn::pki::SignatureBlock::fromBytes(const byte_t* src, size_t size)
case (sign::SIGN_ID_RSA4096_SHA1):
case (sign::SIGN_ID_RSA4096_SHA256):
totalSize = sizeof(sRsa4096SignBlock);
- sigSize = crypto::rsa::kRsa4096Size;
+ sigSize = fnd::rsa::kRsa4096Size;
break;
case (sign::SIGN_ID_RSA2048_SHA1):
case (sign::SIGN_ID_RSA2048_SHA256):
totalSize = sizeof(sRsa2048SignBlock);
- sigSize = crypto::rsa::kRsa2048Size;
+ sigSize = fnd::rsa::kRsa2048Size;
break;
case (sign::SIGN_ID_ECDSA240_SHA1):
case (sign::SIGN_ID_ECDSA240_SHA256):
diff --git a/makefile b/makefile
index 3435159..ee116a5 100644
--- a/makefile
+++ b/makefile
@@ -3,7 +3,7 @@ LIB_DIR = $(PROJECT_DIR)/lib
PROGRAM_DIR = $(PROJECT_DIR)/programs
BIN_DIR = $(PROJECT_DIR)/bin
-LIBS = libpolarssl liblz4 libfnd libcrypto libcompress libes libpki libhac libhac-hb
+LIBS = libpolarssl liblz4 libfnd libes libpki libhac libhac-hb
PROGS = nstool
main: build
diff --git a/programs/nstool/makefile b/programs/nstool/makefile
index a20fbb5..d73e3b4 100644
--- a/programs/nstool/makefile
+++ b/programs/nstool/makefile
@@ -3,7 +3,7 @@ SRC_DIR = source
OBJS = $(foreach dir,$(SRC_DIR),$(subst .cpp,.o,$(wildcard $(dir)/*.cpp))) $(foreach dir,$(SRC_DIR),$(subst .c,.o,$(wildcard $(dir)/*.c)))
# External dependencies
-DEPENDS = hac-hb hac es pki crypto compress fnd polarssl lz4
+DEPENDS = hac-hb hac es pki fnd polarssl lz4
LIB_DIR = ../../lib
LIBS = $(foreach dep,$(DEPENDS), -L"$(LIB_DIR)/lib$(dep)" -l$(dep))
INCS = $(foreach dep,$(DEPENDS), -I"$(LIB_DIR)/lib$(dep)/include")
diff --git a/programs/nstool/nstool.vcxproj b/programs/nstool/nstool.vcxproj
index 9110d28..8e10e2d 100644
--- a/programs/nstool/nstool.vcxproj
+++ b/programs/nstool/nstool.vcxproj
@@ -90,7 +90,7 @@
true
_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include
+ ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include
Console
@@ -105,7 +105,7 @@
true
WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include
+ ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include
Console
@@ -122,7 +122,7 @@
true
WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include
+ ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include
Console
@@ -141,7 +141,7 @@
true
NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
true
- ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libcompress\include;..\..\lib\libcrypto\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include
+ ..\..\lib\libpki\include;..\..\lib\libes\include;..\..\lib\libfnd\include;..\..\lib\libhac\include;..\..\lib\libhac-hb\include
Console
@@ -157,12 +157,6 @@
{AB0C3362-63AB-480A-ADBC-2EF7D859778B}
-
- {cf01b5b7-730a-447f-9bb2-5eda9b082177}
-
-
- {6adbb60d-dba0-411d-bd2d-a355ef8e0fe1}
-
{7be99936-0d40-410d-944b-4513c2eff8dc}
diff --git a/programs/nstool/source/AesCtrWrappedIFile.cpp b/programs/nstool/source/AesCtrWrappedIFile.cpp
index 4dd5c05..06ea584 100644
--- a/programs/nstool/source/AesCtrWrappedIFile.cpp
+++ b/programs/nstool/source/AesCtrWrappedIFile.cpp
@@ -1,6 +1,6 @@
#include "AesCtrWrappedIFile.h"
-AesCtrWrappedIFile::AesCtrWrappedIFile(fnd::IFile* file, bool ownIfile, const crypto::aes::sAes128Key& key, const crypto::aes::sAesIvCtr& ctr) :
+AesCtrWrappedIFile::AesCtrWrappedIFile(fnd::IFile* file, bool ownIfile, const fnd::aes::sAes128Key& key, const fnd::aes::sAesIvCtr& ctr) :
mOwnIFile(ownIfile),
mFile(file),
mKey(key),
@@ -47,8 +47,8 @@ void AesCtrWrappedIFile::read(byte_t* out, size_t len)
mFile->seek(read_pos);
mFile->read(mCache.data(), kCacheSizeAllocSize);
- crypto::aes::AesIncrementCounter(mBaseCtr.iv, read_pos>>4, mCurrentCtr.iv);
- crypto::aes::AesCtr(mCache.data(), kCacheSizeAllocSize, mKey.key, mCurrentCtr.iv, mCache.data());
+ fnd::aes::AesIncrementCounter(mBaseCtr.iv, read_pos>>4, mCurrentCtr.iv);
+ fnd::aes::AesCtr(mCache.data(), kCacheSizeAllocSize, mKey.key, mCurrentCtr.iv, mCache.data());
memcpy(out + (i * kCacheSize), mCache.data() + (mFileOffset & 0xf), read_len);
}
@@ -78,8 +78,8 @@ void AesCtrWrappedIFile::write(const byte_t* in, size_t len)
memcpy(mCache.data() + (mFileOffset & 0xf), in + (i * kCacheSize), write_len);
- crypto::aes::AesIncrementCounter(mBaseCtr.iv, write_pos>>4, mCurrentCtr.iv);
- crypto::aes::AesCtr(mCache.data(), kCacheSizeAllocSize, mKey.key, mCurrentCtr.iv, mCache.data());
+ fnd::aes::AesIncrementCounter(mBaseCtr.iv, write_pos>>4, mCurrentCtr.iv);
+ fnd::aes::AesCtr(mCache.data(), kCacheSizeAllocSize, mKey.key, mCurrentCtr.iv, mCache.data());
mFile->seek(write_pos);
mFile->write(mCache.data(), kCacheSizeAllocSize);
@@ -91,7 +91,7 @@ void AesCtrWrappedIFile::write(const byte_t* in, size_t len)
for (size_t i = 0; i < (len / kAesCtrScratchSize); i++)
{
memcpy(mScratch.data() + mBlockOffset, out + (i * kAesCtrScratchSize), kAesCtrScratchSize);
- crypto::aes::AesCtr(mScratch.data(), kAesCtrScratchAllocSize, mKey.key, mCurrentCtr.iv, mScratch.data());
+ fnd::aes::AesCtr(mScratch.data(), kAesCtrScratchAllocSize, mKey.key, mCurrentCtr.iv, mScratch.data());
mFile->write(mScratch.data() + mBlockOffset, kAesCtrScratchSize);
}
@@ -100,7 +100,7 @@ void AesCtrWrappedIFile::write(const byte_t* in, size_t len)
size_t write_len = len % kAesCtrScratchSize;
size_t write_pos = ((len / kAesCtrScratchSize) * kAesCtrScratchSize);
memcpy(mScratch.data() + mBlockOffset, out + write_pos, write_len);
- crypto::aes::AesCtr(mScratch.data(), kAesCtrScratchAllocSize, mKey.key, mCurrentCtr.iv, mScratch.data());
+ fnd::aes::AesCtr(mScratch.data(), kAesCtrScratchAllocSize, mKey.key, mCurrentCtr.iv, mScratch.data());
mFile->write(mScratch.data() + mBlockOffset, write_len);
}
*/
diff --git a/programs/nstool/source/AesCtrWrappedIFile.h b/programs/nstool/source/AesCtrWrappedIFile.h
index dbbd3e0..1703bc8 100644
--- a/programs/nstool/source/AesCtrWrappedIFile.h
+++ b/programs/nstool/source/AesCtrWrappedIFile.h
@@ -1,11 +1,11 @@
#include
#include
-#include
+#include
class AesCtrWrappedIFile : public fnd::IFile
{
public:
- AesCtrWrappedIFile(fnd::IFile* file, bool ownIfile, const crypto::aes::sAes128Key& key, const crypto::aes::sAesIvCtr& ctr);
+ AesCtrWrappedIFile(fnd::IFile* file, bool ownIfile, const fnd::aes::sAes128Key& key, const fnd::aes::sAesIvCtr& ctr);
~AesCtrWrappedIFile();
size_t size();
@@ -17,12 +17,12 @@ public:
private:
const std::string kModuleName = "AesCtrWrappedIFile";
static const size_t kCacheSize = 0x10000;
- static const size_t kCacheSizeAllocSize = kCacheSize + crypto::aes::kAesBlockSize;
+ static const size_t kCacheSizeAllocSize = kCacheSize + fnd::aes::kAesBlockSize;
bool mOwnIFile;
fnd::IFile* mFile;
- crypto::aes::sAes128Key mKey;
- crypto::aes::sAesIvCtr mBaseCtr, mCurrentCtr;
+ fnd::aes::sAes128Key mKey;
+ fnd::aes::sAesIvCtr mBaseCtr, mCurrentCtr;
size_t mFileOffset;
fnd::Vec mCache;
diff --git a/programs/nstool/source/EsTikProcess.cpp b/programs/nstool/source/EsTikProcess.cpp
index 9f98521..cec162a 100644
--- a/programs/nstool/source/EsTikProcess.cpp
+++ b/programs/nstool/source/EsTikProcess.cpp
@@ -83,12 +83,12 @@ void EsTikProcess::verifyTicket()
switch (nn::pki::sign::getHashAlgo(mTik.getSignature().getSignType()))
{
case (nn::pki::sign::HASH_ALGO_SHA1):
- tik_hash.alloc(crypto::sha::kSha1HashLen);
- crypto::sha::Sha1(mTik.getBody().getBytes().data(), mTik.getBody().getBytes().size(), tik_hash.data());
+ tik_hash.alloc(fnd::sha::kSha1HashLen);
+ fnd::sha::Sha1(mTik.getBody().getBytes().data(), mTik.getBody().getBytes().size(), tik_hash.data());
break;
case (nn::pki::sign::HASH_ALGO_SHA256):
- tik_hash.alloc(crypto::sha::kSha256HashLen);
- crypto::sha::Sha256(mTik.getBody().getBytes().data(), mTik.getBody().getBytes().size(), tik_hash.data());
+ tik_hash.alloc(fnd::sha::kSha256HashLen);
+ fnd::sha::Sha256(mTik.getBody().getBytes().data(), mTik.getBody().getBytes().size(), tik_hash.data());
break;
}
@@ -124,7 +124,7 @@ void EsTikProcess::displayTicket()
std::cout << " EncMode: " << getTitleKeyPersonalisationStr(body.getTitleKeyEncType()) << std::endl;
std::cout << " KeyGeneration: " << std::dec << (uint32_t)body.getCommonKeyId() << std::endl;
std::cout << " Data:" << std::endl;
- size_t size = body.getTitleKeyEncType() == nn::es::ticket::RSA2048 ? crypto::rsa::kRsa2048Size : crypto::aes::kAes128KeySize;
+ size_t size = body.getTitleKeyEncType() == nn::es::ticket::RSA2048 ? fnd::rsa::kRsa2048Size : fnd::aes::kAes128KeySize;
fnd::SimpleTextOutput::hexDump(body.getEncTitleKey(), size, 0x10, 6);
printf(" Version: v%d.%d.%d", _SPLIT_VER(body.getTicketVersion()));
diff --git a/programs/nstool/source/HashTreeMeta.cpp b/programs/nstool/source/HashTreeMeta.cpp
index 4822164..3276d41 100644
--- a/programs/nstool/source/HashTreeMeta.cpp
+++ b/programs/nstool/source/HashTreeMeta.cpp
@@ -72,12 +72,12 @@ void HashTreeMeta::setDataLayer(const sLayer& data_info)
mDataLayer = data_info;
}
-const fnd::List& HashTreeMeta::getMasterHashList() const
+const fnd::List& HashTreeMeta::getMasterHashList() const
{
return mMasterHashList;
}
-void HashTreeMeta::setMasterHashList(const fnd::List& master_hash_list)
+void HashTreeMeta::setMasterHashList(const fnd::List& master_hash_list)
{
mMasterHashList = master_hash_list;
}
diff --git a/programs/nstool/source/HashTreeMeta.h b/programs/nstool/source/HashTreeMeta.h
index ecdbdda..1568b5e 100644
--- a/programs/nstool/source/HashTreeMeta.h
+++ b/programs/nstool/source/HashTreeMeta.h
@@ -50,8 +50,8 @@ public:
const sLayer& getDataLayer() const;
void setDataLayer(const sLayer& data_info);
- const fnd::List& getMasterHashList() const;
- void setMasterHashList(const fnd::List& master_hash_list);
+ const fnd::List& getMasterHashList() const;
+ void setMasterHashList(const fnd::List& master_hash_list);
bool getAlignHashToBlock() const;
void setAlignHashToBlock(bool doAlign);
@@ -60,7 +60,7 @@ private:
// data
fnd::List mLayerInfo;
sLayer mDataLayer;
- fnd::List mMasterHashList;
+ fnd::List mMasterHashList;
bool mDoAlignHashToBlock;
void importHierarchicalIntergityHeader(const nn::hac::HierarchicalIntegrityHeader& hdr);
diff --git a/programs/nstool/source/HashTreeWrappedIFile.cpp b/programs/nstool/source/HashTreeWrappedIFile.cpp
index e8e5140..3b147e9 100644
--- a/programs/nstool/source/HashTreeWrappedIFile.cpp
+++ b/programs/nstool/source/HashTreeWrappedIFile.cpp
@@ -96,16 +96,16 @@ void HashTreeWrappedIFile::write(const byte_t* out, size_t offset, size_t len)
void HashTreeWrappedIFile::initialiseDataLayer(const HashTreeMeta& hdr)
{
- crypto::sha::sSha256Hash hash;
+ fnd::sha::sSha256Hash hash;
fnd::Vec cur, prev;
mAlignHashCalcToBlock = hdr.getAlignHashToBlock();
// copy master hash into prev
- prev.alloc(sizeof(crypto::sha::sSha256Hash) * hdr.getMasterHashList().size());
+ prev.alloc(sizeof(fnd::sha::sSha256Hash) * hdr.getMasterHashList().size());
for (size_t i = 0; i < hdr.getMasterHashList().size(); i++)
{
- ((crypto::sha::sSha256Hash*)prev.data())[i] = hdr.getMasterHashList()[i];
+ ((fnd::sha::sSha256Hash*)prev.data())[i] = hdr.getMasterHashList()[i];
}
// check each hash layer
@@ -125,8 +125,8 @@ void HashTreeWrappedIFile::initialiseDataLayer(const HashTreeMeta& hdr)
for (size_t j = 0; j < cur.size() / layer.block_size; j++)
{
validate_size = mAlignHashCalcToBlock? layer.block_size : _MIN(layer.size - (j * layer.block_size), layer.block_size);
- crypto::sha::Sha256(cur.data() + (j * layer.block_size), validate_size, hash.bytes);
- if (hash.compare(prev.data() + j * sizeof(crypto::sha::sSha256Hash)) == false)
+ fnd::sha::Sha256(cur.data() + (j * layer.block_size), validate_size, hash.bytes);
+ if (hash.compare(prev.data() + j * sizeof(fnd::sha::sSha256Hash)) == false)
{
mErrorSs << "Hash tree layer verification failed (layer: " << i << ", block: " << j << ")";
throw fnd::Exception(kModuleName, mErrorSs.str());
@@ -138,8 +138,8 @@ void HashTreeWrappedIFile::initialiseDataLayer(const HashTreeMeta& hdr)
}
// save last layer as hash table for data layer
- crypto::sha::sSha256Hash* hash_list = (crypto::sha::sSha256Hash*)prev.data();
- for (size_t i = 0; i < prev.size() / sizeof(crypto::sha::sSha256Hash); i++)
+ fnd::sha::sSha256Hash* hash_list = (fnd::sha::sSha256Hash*)prev.data();
+ for (size_t i = 0; i < prev.size() / sizeof(fnd::sha::sSha256Hash); i++)
{
mDataHashLayer.addElement(hash_list[i]);
}
@@ -161,7 +161,7 @@ void HashTreeWrappedIFile::initialiseDataLayer(const HashTreeMeta& hdr)
void HashTreeWrappedIFile::readData(size_t block_offset, size_t block_num)
{
mData->seek(block_offset * mDataBlockSize);
- crypto::sha::sSha256Hash hash;
+ fnd::sha::sSha256Hash hash;
// determine read size
size_t read_len = 0;
@@ -194,7 +194,7 @@ void HashTreeWrappedIFile::readData(size_t block_offset, size_t block_num)
for (size_t i = 0; i < block_num; i++)
{
validate_size = mAlignHashCalcToBlock? mDataBlockSize : _MIN(read_len - (i * mDataBlockSize), mDataBlockSize);
- crypto::sha::Sha256(mCache.data() + (i * mDataBlockSize), validate_size, hash.bytes);
+ fnd::sha::Sha256(mCache.data() + (i * mDataBlockSize), validate_size, hash.bytes);
if (hash != mDataHashLayer[block_offset + i])
{
mErrorSs << "Hash tree layer verification failed (layer: data, block: " << (block_offset + i) << " ( " << i << "/" << block_num-1 << " ), offset: 0x" << std::hex << ((block_offset + i) * mDataBlockSize) << ", size: 0x" << std::hex << validate_size <<")";
diff --git a/programs/nstool/source/HashTreeWrappedIFile.h b/programs/nstool/source/HashTreeWrappedIFile.h
index fa65e13..6e97181 100644
--- a/programs/nstool/source/HashTreeWrappedIFile.h
+++ b/programs/nstool/source/HashTreeWrappedIFile.h
@@ -2,7 +2,7 @@
#include
#include
#include
-#include
+#include
#include "HashTreeMeta.h"
@@ -30,7 +30,7 @@ private:
fnd::IFile* mData;
size_t mDataOffset;
size_t mDataBlockSize;
- fnd::List mDataHashLayer;
+ fnd::List mDataHashLayer;
bool mAlignHashCalcToBlock;
fnd::Vec mCache;
diff --git a/programs/nstool/source/NcaProcess.cpp b/programs/nstool/source/NcaProcess.cpp
index bf7838b..bfc9f3f 100644
--- a/programs/nstool/source/NcaProcess.cpp
+++ b/programs/nstool/source/NcaProcess.cpp
@@ -265,7 +265,7 @@ void NcaProcess::process()
nn::hac::NcaUtils::decryptNcaHeader((byte_t*)&mHdrBlock, (byte_t*)&mHdrBlock, mKeyset->nca.header_key);
// generate header hash
- crypto::sha::Sha256((byte_t*)&mHdrBlock.header, sizeof(nn::hac::sNcaHeader), mHdrHash.bytes);
+ fnd::sha::Sha256((byte_t*)&mHdrBlock.header, sizeof(nn::hac::sNcaHeader), mHdrHash.bytes);
// proccess main header
mHdr.fromBytes((byte_t*)&mHdrBlock.header, sizeof(nn::hac::sNcaHeader));
@@ -341,9 +341,9 @@ void NcaProcess::setListFs(bool list_fs)
void NcaProcess::generateNcaBodyEncryptionKeys()
{
// create zeros key
- crypto::aes::sAes128Key zero_aesctr_key;
+ fnd::aes::sAes128Key zero_aesctr_key;
memset(zero_aesctr_key.key, 0, sizeof(zero_aesctr_key));
- crypto::aes::sAesXts128Key zero_aesxts_key;
+ fnd::aes::sAesXts128Key zero_aesxts_key;
memset(zero_aesxts_key.key, 0, sizeof(zero_aesxts_key));
// get key data from header
@@ -398,8 +398,8 @@ void NcaProcess::generateNcaBodyEncryptionKeys()
// otherwise decrypt key area
else
{
- crypto::aes::sAes128Key keak_aesctr_key = zero_aesctr_key;
- crypto::aes::sAesXts128Key keak_aesxts_key = zero_aesxts_key;
+ fnd::aes::sAes128Key keak_aesctr_key = zero_aesctr_key;
+ fnd::aes::sAesXts128Key keak_aesxts_key = zero_aesxts_key;
for (size_t i = 0; i < mBodyKeys.keak_list.size(); i++)
{
if (mBodyKeys.keak_list[i].index == nn::hac::nca::KEY_AESCTR && mBodyKeys.keak_list[i].decrypted)
@@ -408,11 +408,11 @@ void NcaProcess::generateNcaBodyEncryptionKeys()
}
else if (mBodyKeys.keak_list[i].index == nn::hac::nca::KEY_AESXTS_0 && mBodyKeys.keak_list[i].decrypted)
{
- memcpy(keak_aesxts_key.key[0], mBodyKeys.keak_list[i].dec.key, sizeof(crypto::aes::sAes128Key));
+ memcpy(keak_aesxts_key.key[0], mBodyKeys.keak_list[i].dec.key, sizeof(fnd::aes::sAes128Key));
}
else if (mBodyKeys.keak_list[i].index == nn::hac::nca::KEY_AESXTS_1 && mBodyKeys.keak_list[i].decrypted)
{
- memcpy(keak_aesxts_key.key[1], mBodyKeys.keak_list[i].dec.key, sizeof(crypto::aes::sAes128Key));
+ memcpy(keak_aesxts_key.key[1], mBodyKeys.keak_list[i].dec.key, sizeof(fnd::aes::sAes128Key));
}
}
@@ -472,8 +472,8 @@ void NcaProcess::generatePartitionConfiguration()
sPartitionInfo& info = mPartitions[partition.index];
// validate header hash
- crypto::sha::sSha256Hash calc_hash;
- crypto::sha::Sha256((const byte_t*)&mHdrBlock.fs_header[partition.index], sizeof(nn::hac::sNcaFsHeader), calc_hash.bytes);
+ fnd::sha::sSha256Hash calc_hash;
+ fnd::sha::Sha256((const byte_t*)&mHdrBlock.fs_header[partition.index], sizeof(nn::hac::sNcaFsHeader), calc_hash.bytes);
if (calc_hash.compare(partition.hash) == false)
{
error.clear();
@@ -570,7 +570,7 @@ void NcaProcess::generatePartitionConfiguration()
void NcaProcess::validateNcaSignatures()
{
// validate signature[0]
- if (crypto::rsa::pss::rsaVerify(mKeyset->nca.header_sign_key, crypto::sha::HASH_SHA256, mHdrHash.bytes, mHdrBlock.signature_main) != 0)
+ if (fnd::rsa::pss::rsaVerify(mKeyset->nca.header_sign_key, fnd::sha::HASH_SHA256, mHdrHash.bytes, mHdrBlock.signature_main) != 0)
{
printf("[WARNING] NCA Header Main Signature: FAIL \n");
}
@@ -597,7 +597,7 @@ void NcaProcess::validateNcaSignatures()
npdm.setCliOutputMode(0);
npdm.process();
- if (crypto::rsa::pss::rsaVerify(npdm.getNpdmBinary().getAcid().getNcaHeaderSignature2Key(), crypto::sha::HASH_SHA256, mHdrHash.bytes, mHdrBlock.signature_acid) != 0)
+ if (fnd::rsa::pss::rsaVerify(npdm.getNpdmBinary().getAcid().getNcaHeaderSignature2Key(), fnd::sha::HASH_SHA256, mHdrHash.bytes, mHdrBlock.signature_acid) != 0)
{
printf("[WARNING] NCA Header ACID Signature: FAIL \n");
}
@@ -686,9 +686,9 @@ void NcaProcess::displayHeader()
if (info.enc_type == nn::hac::nca::CRYPT_AESCTR)
{
printf(" AES-CTR: ");
- crypto::aes::sAesIvCtr ctr;
- crypto::aes::AesIncrementCounter(info.aes_ctr.iv, info.offset>>4, ctr.iv);
- fnd::SimpleTextOutput::hexDump(ctr.iv, sizeof(crypto::aes::sAesIvCtr));
+ fnd::aes::sAesIvCtr ctr;
+ fnd::aes::AesIncrementCounter(info.aes_ctr.iv, info.offset>>4, ctr.iv);
+ fnd::SimpleTextOutput::hexDump(ctr.iv, sizeof(fnd::aes::sAesIvCtr));
}
if (info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_INTERGRITY)
{
@@ -712,7 +712,7 @@ void NcaProcess::displayHeader()
for (size_t j = 0; j < hash_hdr.getMasterHashList().size(); j++)
{
printf(" Master Hash %d: ", (int)j);
- fnd::SimpleTextOutput::hexDump(hash_hdr.getMasterHashList()[j].bytes, sizeof(crypto::sha::sSha256Hash));
+ fnd::SimpleTextOutput::hexDump(hash_hdr.getMasterHashList()[j].bytes, sizeof(fnd::sha::sSha256Hash));
}
}
else if (info.hash_type == nn::hac::nca::HASH_HIERARCHICAL_SHA256)
@@ -720,7 +720,7 @@ void NcaProcess::displayHeader()
HashTreeMeta& hash_hdr = info.hash_tree_meta;
printf(" HierarchicalSha256 Header:\n");
printf(" Master Hash: ");
- fnd::SimpleTextOutput::hexDump(hash_hdr.getMasterHashList()[0].bytes, sizeof(crypto::sha::sSha256Hash));
+ fnd::SimpleTextOutput::hexDump(hash_hdr.getMasterHashList()[0].bytes, sizeof(fnd::sha::sSha256Hash));
printf(" HashBlockSize: 0x%" PRIx32 "\n", (uint32_t)hash_hdr.getDataLayer().block_size);
//printf(" LayerNum: %d\n", hash_hdr.getLayerInfo().size());
printf(" Hash Layer:\n");
diff --git a/programs/nstool/source/NcaProcess.h b/programs/nstool/source/NcaProcess.h
index d79ab5a..e21ded8 100644
--- a/programs/nstool/source/NcaProcess.h
+++ b/programs/nstool/source/NcaProcess.h
@@ -50,7 +50,7 @@ private:
// data
nn::hac::sNcaHeaderBlock mHdrBlock;
- crypto::sha::sSha256Hash mHdrHash;
+ fnd::sha::sSha256Hash mHdrHash;
nn::hac::NcaHeader mHdr;
// crypto
@@ -60,8 +60,8 @@ private:
{
byte_t index;
bool decrypted;
- crypto::aes::sAes128Key enc;
- crypto::aes::sAes128Key dec;
+ fnd::aes::sAes128Key enc;
+ fnd::aes::sAes128Key dec;
void operator=(const sKeyAreaKey& other)
{
@@ -86,8 +86,8 @@ private:
};
fnd::List keak_list;
- sOptional aes_ctr;
- sOptional aes_xts;
+ sOptional aes_ctr;
+ sOptional aes_xts;
} mBodyKeys;
struct sPartitionInfo
@@ -102,7 +102,7 @@ private:
nn::hac::nca::HashType hash_type;
nn::hac::nca::EncryptionType enc_type;
HashTreeMeta hash_tree_meta;
- crypto::aes::sAesIvCtr aes_ctr;
+ fnd::aes::sAesIvCtr aes_ctr;
} mPartitions[nn::hac::nca::kPartitionNum];
void generateNcaBodyEncryptionKeys();
diff --git a/programs/nstool/source/NroProcess.cpp b/programs/nstool/source/NroProcess.cpp
index 694ad38..3beb776 100644
--- a/programs/nstool/source/NroProcess.cpp
+++ b/programs/nstool/source/NroProcess.cpp
@@ -1,6 +1,6 @@
#include
#include
-#include
+#include
#include
#include "OffsetAdjustedIFile.h"
#include "NroProcess.h"
diff --git a/programs/nstool/source/NsoProcess.cpp b/programs/nstool/source/NsoProcess.cpp
index 3f5653f..3113be5 100644
--- a/programs/nstool/source/NsoProcess.cpp
+++ b/programs/nstool/source/NsoProcess.cpp
@@ -1,6 +1,6 @@
#include
#include
-#include
+#include
#include "OffsetAdjustedIFile.h"
#include "NsoProcess.h"
@@ -89,7 +89,7 @@ void NsoProcess::importCodeSegments()
{
fnd::Vec scratch;
uint32_t decompressed_len;
- crypto::sha::sSha256Hash calc_hash;
+ fnd::sha::sSha256Hash calc_hash;
// process text segment
if (mHdr.getTextSegmentInfo().is_compressed)
@@ -97,7 +97,7 @@ void NsoProcess::importCodeSegments()
scratch.alloc(mHdr.getTextSegmentInfo().file_layout.size);
mFile->read(scratch.data(), mHdr.getTextSegmentInfo().file_layout.offset, scratch.size());
mTextBlob.alloc(mHdr.getTextSegmentInfo().memory_layout.size);
- compress::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mTextBlob.data(), (uint32_t)mTextBlob.size(), decompressed_len);
+ fnd::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mTextBlob.data(), (uint32_t)mTextBlob.size(), decompressed_len);
if (decompressed_len != mTextBlob.size())
{
throw fnd::Exception(kModuleName, "NSO text segment failed to decompress");
@@ -110,7 +110,7 @@ void NsoProcess::importCodeSegments()
}
if (mHdr.getTextSegmentInfo().is_hashed)
{
- crypto::sha::Sha256(mTextBlob.data(), mTextBlob.size(), calc_hash.bytes);
+ fnd::sha::Sha256(mTextBlob.data(), mTextBlob.size(), calc_hash.bytes);
if (calc_hash != mHdr.getTextSegmentInfo().hash)
{
throw fnd::Exception(kModuleName, "NSO text segment failed SHA256 verification");
@@ -123,7 +123,7 @@ void NsoProcess::importCodeSegments()
scratch.alloc(mHdr.getRoSegmentInfo().file_layout.size);
mFile->read(scratch.data(), mHdr.getRoSegmentInfo().file_layout.offset, scratch.size());
mRoBlob.alloc(mHdr.getRoSegmentInfo().memory_layout.size);
- compress::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mRoBlob.data(), (uint32_t)mRoBlob.size(), decompressed_len);
+ fnd::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mRoBlob.data(), (uint32_t)mRoBlob.size(), decompressed_len);
if (decompressed_len != mRoBlob.size())
{
throw fnd::Exception(kModuleName, "NSO ro segment failed to decompress");
@@ -136,7 +136,7 @@ void NsoProcess::importCodeSegments()
}
if (mHdr.getRoSegmentInfo().is_hashed)
{
- crypto::sha::Sha256(mRoBlob.data(), mRoBlob.size(), calc_hash.bytes);
+ fnd::sha::Sha256(mRoBlob.data(), mRoBlob.size(), calc_hash.bytes);
if (calc_hash != mHdr.getRoSegmentInfo().hash)
{
throw fnd::Exception(kModuleName, "NSO ro segment failed SHA256 verification");
@@ -149,7 +149,7 @@ void NsoProcess::importCodeSegments()
scratch.alloc(mHdr.getDataSegmentInfo().file_layout.size);
mFile->read(scratch.data(), mHdr.getDataSegmentInfo().file_layout.offset, scratch.size());
mDataBlob.alloc(mHdr.getDataSegmentInfo().memory_layout.size);
- compress::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mDataBlob.data(), (uint32_t)mDataBlob.size(), decompressed_len);
+ fnd::lz4::decompressData(scratch.data(), (uint32_t)scratch.size(), mDataBlob.data(), (uint32_t)mDataBlob.size(), decompressed_len);
if (decompressed_len != mDataBlob.size())
{
throw fnd::Exception(kModuleName, "NSO data segment failed to decompress");
@@ -162,7 +162,7 @@ void NsoProcess::importCodeSegments()
}
if (mHdr.getDataSegmentInfo().is_hashed)
{
- crypto::sha::Sha256(mDataBlob.data(), mDataBlob.size(), calc_hash.bytes);
+ fnd::sha::Sha256(mDataBlob.data(), mDataBlob.size(), calc_hash.bytes);
if (calc_hash != mHdr.getDataSegmentInfo().hash)
{
throw fnd::Exception(kModuleName, "NSO data segment failed SHA256 verification");
diff --git a/programs/nstool/source/PfsProcess.cpp b/programs/nstool/source/PfsProcess.cpp
index 646f83f..c44fca0 100644
--- a/programs/nstool/source/PfsProcess.cpp
+++ b/programs/nstool/source/PfsProcess.cpp
@@ -142,13 +142,13 @@ bool PfsProcess::validateHeaderMagic(const nn::hac::sPfsHeader* hdr)
void PfsProcess::validateHfs()
{
- crypto::sha::sSha256Hash hash;
+ fnd::sha::sSha256Hash hash;
const fnd::List& file = mPfs.getFileList();
for (size_t i = 0; i < file.size(); i++)
{
mCache.alloc(file[i].hash_protected_size);
mFile->read(mCache.data(), file[i].offset, file[i].hash_protected_size);
- crypto::sha::Sha256(mCache.data(), file[i].hash_protected_size, hash.bytes);
+ fnd::sha::Sha256(mCache.data(), file[i].hash_protected_size, hash.bytes);
if (hash != file[i].hash)
{
printf("[WARNING] HFS0 %s%s%s: FAIL (bad hash)\n", !mMountName.empty()? mMountName.c_str() : "", (!mMountName.empty() && mMountName.at(mMountName.length()-1) != '/' )? "/" : "", file[i].name.c_str());
diff --git a/programs/nstool/source/PkiCertProcess.cpp b/programs/nstool/source/PkiCertProcess.cpp
index 5de3e01..db7c629 100644
--- a/programs/nstool/source/PkiCertProcess.cpp
+++ b/programs/nstool/source/PkiCertProcess.cpp
@@ -123,25 +123,25 @@ void PkiCertProcess::displayCert(const nn::pki::SignedData> old_certs = mCertificateBank;
@@ -58,12 +58,12 @@ void PkiValidator::addCertificate(const nn::pki::SignedData& PkiValidator::getCert(const
throw fnd::Exception(kModuleName, "Issuer certificate does not exist");
}
-crypto::sha::HashType PkiValidator::getCryptoHashAlgoFromEsSignHashAlgo(nn::pki::sign::HashAlgo hash_algo) const
+fnd::sha::HashType PkiValidator::getCryptoHashAlgoFromEsSignHashAlgo(nn::pki::sign::HashAlgo hash_algo) const
{
- crypto::sha::HashType hash_type = crypto::sha::HASH_SHA1;
+ fnd::sha::HashType hash_type = fnd::sha::HASH_SHA1;
switch (hash_algo)
{
case (nn::pki::sign::HASH_ALGO_SHA1):
- hash_type = crypto::sha::HASH_SHA1;
+ hash_type = fnd::sha::HASH_SHA1;
break;
case (nn::pki::sign::HASH_ALGO_SHA256):
- hash_type = crypto::sha::HASH_SHA256;
+ hash_type = fnd::sha::HASH_SHA256;
break;
};
diff --git a/programs/nstool/source/PkiValidator.h b/programs/nstool/source/PkiValidator.h
index 1183c80..6ef0bd2 100644
--- a/programs/nstool/source/PkiValidator.h
+++ b/programs/nstool/source/PkiValidator.h
@@ -2,7 +2,7 @@
#include
#include
#include
-#include
+#include
#include
#include
#include
@@ -12,7 +12,7 @@ class PkiValidator
public:
PkiValidator();
- void setRootKey(const crypto::rsa::sRsa4096Key& root_key);
+ void setRootKey(const fnd::rsa::sRsa4096Key& root_key);
void addCertificates(const fnd::List>& certs);
void addCertificate(const nn::pki::SignedData& cert);
void clearCertificates();
@@ -23,12 +23,12 @@ private:
const std::string kModuleName = "NNPkiValidator";
- crypto::rsa::sRsa4096Key mRootKey;
+ fnd::rsa::sRsa4096Key mRootKey;
fnd::List> mCertificateBank;
void makeCertIdent(const nn::pki::SignedData& cert, std::string& ident) const;
void makeCertIdent(const std::string& issuer, const std::string& subject, std::string& ident) const;
bool doesCertExist(const std::string& ident) const;
const nn::pki::SignedData& getCert(const std::string& ident) const;
- crypto::sha::HashType getCryptoHashAlgoFromEsSignHashAlgo(nn::pki::sign::HashAlgo hash_algo) const;
+ fnd::sha::HashType getCryptoHashAlgoFromEsSignHashAlgo(nn::pki::sign::HashAlgo hash_algo) const;
};
\ No newline at end of file
diff --git a/programs/nstool/source/UserSettings.cpp b/programs/nstool/source/UserSettings.cpp
index 0c0cf06..936ac00 100644
--- a/programs/nstool/source/UserSettings.cpp
+++ b/programs/nstool/source/UserSettings.cpp
@@ -385,10 +385,10 @@ void UserSettings::populateCmdArgs(const std::vector& arg_list, sCm
void UserSettings::populateKeyset(sCmdArgs& args)
{
- crypto::aes::sAes128Key zeros_aes_key;
- crypto::aes::sAesXts128Key zeros_aes_xts_key;
- memset((void*)&zeros_aes_key, 0, sizeof(crypto::aes::sAes128Key));
- memset((void*)&zeros_aes_xts_key, 0, sizeof(crypto::aes::sAesXts128Key));
+ fnd::aes::sAes128Key zeros_aes_key;
+ fnd::aes::sAesXts128Key zeros_aes_xts_key;
+ memset((void*)&zeros_aes_key, 0, sizeof(fnd::aes::sAes128Key));
+ memset((void*)&zeros_aes_xts_key, 0, sizeof(fnd::aes::sAesXts128Key));
memset((void*)&mKeyset, 0, sizeof(sKeyset));
fnd::ResourceFileReader res;
@@ -446,14 +446,14 @@ void UserSettings::populateKeyset(sCmdArgs& args)
// sources
- crypto::aes::sAes128Key master_key[kMasterKeyNum] = { zeros_aes_key };
- crypto::aes::sAes128Key package2_key_source = zeros_aes_key;
- crypto::aes::sAes128Key ticket_titlekek_source = zeros_aes_key;
- crypto::aes::sAes128Key key_area_key_source[3] = { zeros_aes_key, zeros_aes_key, zeros_aes_key };
- crypto::aes::sAes128Key aes_kek_generation_source = zeros_aes_key;
- crypto::aes::sAes128Key aes_key_generation_source = zeros_aes_key;
- crypto::aes::sAes128Key nca_header_kek_source = zeros_aes_key;
- crypto::aes::sAesXts128Key nca_header_key_source = zeros_aes_xts_key;
+ fnd::aes::sAes128Key master_key[kMasterKeyNum] = { zeros_aes_key };
+ fnd::aes::sAes128Key package2_key_source = zeros_aes_key;
+ fnd::aes::sAes128Key ticket_titlekek_source = zeros_aes_key;
+ fnd::aes::sAes128Key key_area_key_source[3] = { zeros_aes_key, zeros_aes_key, zeros_aes_key };
+ fnd::aes::sAes128Key aes_kek_generation_source = zeros_aes_key;
+ fnd::aes::sAes128Key aes_key_generation_source = zeros_aes_key;
+ fnd::aes::sAes128Key nca_header_kek_source = zeros_aes_key;
+ fnd::aes::sAesXts128Key nca_header_key_source = zeros_aes_xts_key;
#define _CONCAT_2_STRINGS(str1, str2) ((str1) + "_" + (str2))
@@ -509,44 +509,44 @@ void UserSettings::populateKeyset(sCmdArgs& args)
_SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase, kKeyStr), mKeyset.xci.header_key.key, 0x10);
// store rsa keys
- _SAVE_KEYDATA(_CONCAT_2_STRINGS(kNcaHeaderBase[1], kRsaKeySuffix[0]), mKeyset.nca.header_sign_key.priv_exponent, crypto::rsa::kRsa2048Size);
- _SAVE_KEYDATA(_CONCAT_2_STRINGS(kNcaHeaderBase[1], kRsaKeySuffix[1]), mKeyset.nca.header_sign_key.modulus, crypto::rsa::kRsa2048Size);
+ _SAVE_KEYDATA(_CONCAT_2_STRINGS(kNcaHeaderBase[1], kRsaKeySuffix[0]), mKeyset.nca.header_sign_key.priv_exponent, fnd::rsa::kRsa2048Size);
+ _SAVE_KEYDATA(_CONCAT_2_STRINGS(kNcaHeaderBase[1], kRsaKeySuffix[1]), mKeyset.nca.header_sign_key.modulus, fnd::rsa::kRsa2048Size);
- _SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase, kRsaKeySuffix[0]), mKeyset.xci.header_sign_key.priv_exponent, crypto::rsa::kRsa2048Size);
- _SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase, kRsaKeySuffix[1]), mKeyset.xci.header_sign_key.modulus, crypto::rsa::kRsa2048Size);
+ _SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase, kRsaKeySuffix[0]), mKeyset.xci.header_sign_key.priv_exponent, fnd::rsa::kRsa2048Size);
+ _SAVE_KEYDATA(_CONCAT_2_STRINGS(kXciHeaderBase, kRsaKeySuffix[1]), mKeyset.xci.header_sign_key.modulus, fnd::rsa::kRsa2048Size);
- _SAVE_KEYDATA(_CONCAT_2_STRINGS(kAcidBase, kRsaKeySuffix[0]), mKeyset.acid_sign_key.priv_exponent, crypto::rsa::kRsa2048Size);
- _SAVE_KEYDATA(_CONCAT_2_STRINGS(kAcidBase, kRsaKeySuffix[1]), mKeyset.acid_sign_key.modulus, crypto::rsa::kRsa2048Size);
+ _SAVE_KEYDATA(_CONCAT_2_STRINGS(kAcidBase, kRsaKeySuffix[0]), mKeyset.acid_sign_key.priv_exponent, fnd::rsa::kRsa2048Size);
+ _SAVE_KEYDATA(_CONCAT_2_STRINGS(kAcidBase, kRsaKeySuffix[1]), mKeyset.acid_sign_key.modulus, fnd::rsa::kRsa2048Size);
- _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPackage2Base, kRsaKeySuffix[0]), mKeyset.package2_sign_key.priv_exponent, crypto::rsa::kRsa2048Size);
- _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPackage2Base, kRsaKeySuffix[1]), mKeyset.package2_sign_key.modulus, crypto::rsa::kRsa2048Size);
+ _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPackage2Base, kRsaKeySuffix[0]), mKeyset.package2_sign_key.priv_exponent, fnd::rsa::kRsa2048Size);
+ _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPackage2Base, kRsaKeySuffix[1]), mKeyset.package2_sign_key.modulus, fnd::rsa::kRsa2048Size);
- _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkiRootBase, kRsaKeySuffix[0]), mKeyset.pki.root_sign_key.priv_exponent, crypto::rsa::kRsa4096Size);
- _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkiRootBase, kRsaKeySuffix[1]), mKeyset.pki.root_sign_key.modulus, crypto::rsa::kRsa4096Size);
+ _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkiRootBase, kRsaKeySuffix[0]), mKeyset.pki.root_sign_key.priv_exponent, fnd::rsa::kRsa4096Size);
+ _SAVE_KEYDATA(_CONCAT_2_STRINGS(kPkiRootBase, kRsaKeySuffix[1]), mKeyset.pki.root_sign_key.modulus, fnd::rsa::kRsa4096Size);
// save keydata from input args
if (args.nca_bodykey.isSet)
{
- if (args.nca_bodykey.var.length() == (sizeof(crypto::aes::sAes128Key)*2))
+ if (args.nca_bodykey.var.length() == (sizeof(fnd::aes::sAes128Key)*2))
{
- decodeHexStringToBytes("--bodykey", args.nca_bodykey.var, mKeyset.nca.manual_body_key_aesctr.key, sizeof(crypto::aes::sAes128Key));
+ decodeHexStringToBytes("--bodykey", args.nca_bodykey.var, mKeyset.nca.manual_body_key_aesctr.key, sizeof(fnd::aes::sAes128Key));
}
else
{
- decodeHexStringToBytes("--bodykey", args.nca_bodykey.var, mKeyset.nca.manual_body_key_aesxts.key[0], sizeof(crypto::aes::sAesXts128Key));
+ decodeHexStringToBytes("--bodykey", args.nca_bodykey.var, mKeyset.nca.manual_body_key_aesxts.key[0], sizeof(fnd::aes::sAesXts128Key));
}
}
if (args.nca_titlekey.isSet)
{
- if (args.nca_titlekey.var.length() == (sizeof(crypto::aes::sAes128Key)*2))
+ if (args.nca_titlekey.var.length() == (sizeof(fnd::aes::sAes128Key)*2))
{
- decodeHexStringToBytes("--titlekey", args.nca_titlekey.var, mKeyset.nca.manual_title_key_aesctr.key, sizeof(crypto::aes::sAes128Key));
+ decodeHexStringToBytes("--titlekey", args.nca_titlekey.var, mKeyset.nca.manual_title_key_aesctr.key, sizeof(fnd::aes::sAes128Key));
}
else
{
- decodeHexStringToBytes("--titlekey", args.nca_titlekey.var, mKeyset.nca.manual_title_key_aesxts.key[0], sizeof(crypto::aes::sAesXts128Key));
+ decodeHexStringToBytes("--titlekey", args.nca_titlekey.var, mKeyset.nca.manual_title_key_aesxts.key[0], sizeof(fnd::aes::sAesXts128Key));
}
}
@@ -590,12 +590,12 @@ void UserSettings::populateKeyset(sCmdArgs& args)
switch (nn::pki::sign::getHashAlgo(tik.getSignature().getSignType()))
{
case (nn::pki::sign::HASH_ALGO_SHA1):
- tik_hash.alloc(crypto::sha::kSha1HashLen);
- crypto::sha::Sha1(tik.getBody().getBytes().data(), tik.getBody().getBytes().size(), tik_hash.data());
+ tik_hash.alloc(fnd::sha::kSha1HashLen);
+ fnd::sha::Sha1(tik.getBody().getBytes().data(), tik.getBody().getBytes().size(), tik_hash.data());
break;
case (nn::pki::sign::HASH_ALGO_SHA256):
- tik_hash.alloc(crypto::sha::kSha256HashLen);
- crypto::sha::Sha256(tik.getBody().getBytes().data(), tik.getBody().getBytes().size(), tik_hash.data());
+ tik_hash.alloc(fnd::sha::kSha256HashLen);
+ fnd::sha::Sha256(tik.getBody().getBytes().data(), tik.getBody().getBytes().size(), tik_hash.data());
break;
}
@@ -615,7 +615,7 @@ void UserSettings::populateKeyset(sCmdArgs& args)
// extract title key
if (tik.getBody().getTitleKeyEncType() == nn::es::ticket::AES128_CBC)
{
- memcpy(mKeyset.nca.manual_title_key_aesctr.key, tik.getBody().getEncTitleKey(), crypto::aes::kAes128KeySize);
+ memcpy(mKeyset.nca.manual_title_key_aesctr.key, tik.getBody().getEncTitleKey(), fnd::aes::kAes128KeySize);
}
else
{
@@ -638,7 +638,7 @@ void UserSettings::populateKeyset(sCmdArgs& args)
{
if (mKeyset.nca.header_key == zeros_aes_xts_key)
{
- crypto::aes::sAes128Key nca_header_kek;
+ fnd::aes::sAes128Key nca_header_kek;
nn::hac::AesKeygen::generateKey(nca_header_kek.key, aes_kek_generation_source.key, nca_header_kek_source.key, aes_key_generation_source.key, master_key[i].key);
nn::hac::AesKeygen::generateKey(mKeyset.nca.header_key.key[0], nca_header_key_source.key[0], nca_header_kek.key);
nn::hac::AesKeygen::generateKey(mKeyset.nca.header_key.key[1], nca_header_key_source.key[1], nca_header_kek.key);
diff --git a/programs/nstool/source/XciProcess.cpp b/programs/nstool/source/XciProcess.cpp
index 9408e42..230b1b9 100644
--- a/programs/nstool/source/XciProcess.cpp
+++ b/programs/nstool/source/XciProcess.cpp
@@ -183,18 +183,18 @@ void XciProcess::displayHeader()
bool XciProcess::validateRegionOfFile(size_t offset, size_t len, const byte_t* test_hash)
{
fnd::Vec scratch;
- crypto::sha::sSha256Hash calc_hash;
+ fnd::sha::sSha256Hash calc_hash;
scratch.alloc(len);
mFile->read(scratch.data(), offset, scratch.size());
- crypto::sha::Sha256(scratch.data(), scratch.size(), calc_hash.bytes);
+ fnd::sha::Sha256(scratch.data(), scratch.size(), calc_hash.bytes);
return calc_hash.compare(test_hash);
}
void XciProcess::validateXciSignature()
{
- crypto::sha::sSha256Hash calc_hash;
- crypto::sha::Sha256((byte_t*)&mHdrPage.header, sizeof(nn::hac::sXciHeader), calc_hash.bytes);
- if (crypto::rsa::pkcs::rsaVerify(mKeyset->xci.header_sign_key, crypto::sha::HASH_SHA256, calc_hash.bytes, mHdrPage.signature) != 0)
+ fnd::sha::sSha256Hash calc_hash;
+ fnd::sha::Sha256((byte_t*)&mHdrPage.header, sizeof(nn::hac::sXciHeader), calc_hash.bytes);
+ if (fnd::rsa::pkcs::rsaVerify(mKeyset->xci.header_sign_key, fnd::sha::HASH_SHA256, calc_hash.bytes, mHdrPage.signature) != 0)
{
printf("[WARNING] XCI Header Signature: FAIL \n");
}
diff --git a/programs/nstool/source/nstool.h b/programs/nstool/source/nstool.h
index 3e2043e..ba36f7a 100644
--- a/programs/nstool/source/nstool.h
+++ b/programs/nstool/source/nstool.h
@@ -2,8 +2,8 @@
#pragma once
#include
#include
-#include
-#include
+#include
+#include
#include
static const size_t kMasterKeyNum = 0x20;
@@ -63,38 +63,38 @@ struct sOptional
struct sKeyset
{
- crypto::rsa::sRsa2048Key acid_sign_key;
- crypto::aes::sAes128Key package1_key[kMasterKeyNum];
- crypto::rsa::sRsa2048Key package2_sign_key;
- crypto::aes::sAes128Key package2_key[kMasterKeyNum];
+ fnd::rsa::sRsa2048Key acid_sign_key;
+ fnd::aes::sAes128Key package1_key[kMasterKeyNum];
+ fnd::rsa::sRsa2048Key package2_sign_key;
+ fnd::aes::sAes128Key package2_key[kMasterKeyNum];
struct sNcaData
{
- crypto::rsa::sRsa2048Key header_sign_key;
- crypto::aes::sAesXts128Key header_key;
- crypto::aes::sAes128Key key_area_key[kNcaKeakNum][kMasterKeyNum];
+ fnd::rsa::sRsa2048Key header_sign_key;
+ fnd::aes::sAesXts128Key header_key;
+ fnd::aes::sAes128Key key_area_key[kNcaKeakNum][kMasterKeyNum];
- crypto::aes::sAes128Key manual_title_key_aesctr;
- crypto::aes::sAesXts128Key manual_title_key_aesxts;
- crypto::aes::sAes128Key manual_body_key_aesctr;
- crypto::aes::sAesXts128Key manual_body_key_aesxts;
+ fnd::aes::sAes128Key manual_title_key_aesctr;
+ fnd::aes::sAesXts128Key manual_title_key_aesxts;
+ fnd::aes::sAes128Key manual_body_key_aesctr;
+ fnd::aes::sAesXts128Key manual_body_key_aesxts;
} nca;
struct sXciData
{
- crypto::rsa::sRsa2048Key header_sign_key;
- crypto::aes::sAes128Key header_key;
+ fnd::rsa::sRsa2048Key header_sign_key;
+ fnd::aes::sAes128Key header_key;
} xci;
struct sTicketData
{
- crypto::rsa::sRsa2048Key sign_key;
- crypto::aes::sAes128Key titlekey_kek[kMasterKeyNum];
+ fnd::rsa::sRsa2048Key sign_key;
+ fnd::aes::sAes128Key titlekey_kek[kMasterKeyNum];
} ticket;
struct sPkiData
{
- crypto::rsa::sRsa4096Key root_sign_key;
+ fnd::rsa::sRsa4096Key root_sign_key;
} pki;
};