Пример #1
0
bool C3dsTool::encryptFile()
{
	bool bResult = false;
	if (m_nEncryptMode == CNcch::kEncryptModeAesCtr && !m_sCounter.empty())
	{
		u8 uAesCtr[16] = {};
		bResult = FSHexToU8(m_sCounter, uAesCtr);
		if (bResult)
		{
			bResult = FEncryptAesCtrFile(m_pFileName, m_uKey, uAesCtr, 0, 0, true, m_bVerbose);
		}
	}
	else if (m_nEncryptMode == CNcch::kEncryptModeXor && m_pXorFileName != nullptr)
	{
		bResult = FEncryptXorFile(m_pFileName, m_pXorFileName, 0, 0, true, 0, m_bVerbose);
	}
	else if (CNcch::IsCxiFile(m_pFileName))
	{
		CNcch ncch;
		ncch.SetFileName(m_pFileName);
		ncch.SetVerbose(m_bVerbose);
		ncch.SetEncryptMode(m_nEncryptMode);
		ncch.SetKey(m_uKey);
		ncch.SetExtendedHeaderXorFileName(m_pExtendedHeaderXorFileName);
		ncch.SetExeFsXorFileName(m_pExeFsXorFileName);
		ncch.SetExeFsTopXorFileName(m_pExeFsTopXorFileName);
		ncch.SetRomFsXorFileName(m_pRomFsXorFileName);
		bResult = ncch.EncryptFile();
	}
	else if (CNcch::IsCfaFile(m_pFileName))
	{
		CNcch ncch;
		ncch.SetFileName(m_pFileName);
		ncch.SetVerbose(m_bVerbose);
		ncch.SetEncryptMode(m_nEncryptMode);
		ncch.SetKey(m_uKey);
		ncch.SetExeFsXorFileName(m_pExeFsXorFileName);
		ncch.SetRomFsXorFileName(m_pRomFsXorFileName);
		bResult = ncch.EncryptFile();
	}
	return bResult;
}
Пример #2
0
bool C3dsTool::encryptFile()
{
	bool bResult = false;
	if (m_nEncryptMode == CNcch::kEncryptModeAesCtr && m_bCounterValid)
	{
		bResult = FEncryptAesCtrFile(m_pFileName, m_Key, m_Counter, 0, 0, true, 0);
	}
	else if (m_nEncryptMode == CNcch::kEncryptModeXor && m_pXorFileName != nullptr)
	{
		bResult = FEncryptXorFile(m_pFileName, m_pXorFileName, 0, 0, true, 0);
	}
	else if (CNcch::IsCxiFile(m_pFileName))
	{
		CNcch ncch;
		ncch.SetFileName(m_pFileName);
		ncch.SetVerbose(m_bVerbose);
		ncch.SetEncryptMode(m_nEncryptMode);
		ncch.SetKey(m_Key);
		ncch.SetExtendedHeaderXorFileName(m_pExtendedHeaderXorFileName);
		ncch.SetExeFsXorFileName(m_pExeFsXorFileName);
		ncch.SetExeFsTopXorFileName(m_pExeFsTopXorFileName);
		ncch.SetRomFsXorFileName(m_pRomFsXorFileName);
		ncch.SetExeFsTopAutoKey(m_bExeFsTopAutoKey);
		ncch.SetRomFsAutoKey(m_bRomFsAutoKey);
		bResult = ncch.EncryptFile();
	}
	else if (CNcch::IsCfaFile(m_pFileName))
	{
		CNcch ncch;
		ncch.SetFileName(m_pFileName);
		ncch.SetVerbose(m_bVerbose);
		ncch.SetEncryptMode(m_nEncryptMode);
		ncch.SetKey(m_Key);
		ncch.SetExeFsXorFileName(m_pExeFsXorFileName);
		ncch.SetRomFsXorFileName(m_pRomFsXorFileName);
		ncch.SetRomFsAutoKey(m_bRomFsAutoKey);
		bResult = ncch.EncryptFile();
	}
	return bResult;
}