allow validating from alternate keys
fix missing HAVE_CRYPTOPP defs
This commit is contained in:
@@ -6,10 +6,13 @@
|
|||||||
#include "RageFileManager.h"
|
#include "RageFileManager.h"
|
||||||
#include "crypto/CryptMD5.h"
|
#include "crypto/CryptMD5.h"
|
||||||
|
|
||||||
|
#include "arch/arch_platform.h" // hack: HAVE_ stuff should not be defined by arch
|
||||||
|
|
||||||
CryptManager* CRYPTMAN = NULL; // global and accessable from anywhere in our program
|
CryptManager* CRYPTMAN = NULL; // global and accessable from anywhere in our program
|
||||||
|
|
||||||
static const CString PRIVATE_KEY_PATH = "Data/private.rsa";
|
static const CString PRIVATE_KEY_PATH = "Data/private.rsa";
|
||||||
static const CString PUBLIC_KEY_PATH = "Data/public.rsa";
|
static const CString PUBLIC_KEY_PATH = "Data/public.rsa";
|
||||||
|
static const CString ALTERNATE_PUBLIC_KEY_DIR = "Data/keys/";
|
||||||
|
|
||||||
#if !defined(HAVE_CRYPTOPP)
|
#if !defined(HAVE_CRYPTOPP)
|
||||||
CryptManager::CryptManager() { }
|
CryptManager::CryptManager() { }
|
||||||
@@ -154,12 +157,32 @@ bool CryptManager::VerifyFileWithFile( CString sPath, CString sSignatureFile )
|
|||||||
{
|
{
|
||||||
ASSERT( PREFSMAN->m_bSignProfileData );
|
ASSERT( PREFSMAN->m_bSignProfileData );
|
||||||
|
|
||||||
CString sPubFilename = PUBLIC_KEY_PATH;
|
if( VerifyFileWithFile(sPath, sSignatureFile, PUBLIC_KEY_PATH) )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
vector<CString> asKeys;
|
||||||
|
GetDirListing( ALTERNATE_PUBLIC_KEY_DIR, asKeys, false, true );
|
||||||
|
for( unsigned i = 0; i < asKeys.size(); ++i )
|
||||||
|
{
|
||||||
|
const CString &sKey = asKeys[i];
|
||||||
|
LOG->Trace( "Trying alternate key \"%s\" ...", sKey.c_str() );
|
||||||
|
|
||||||
|
if( VerifyFileWithFile(sPath, sSignatureFile, sKey) )
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CryptManager::VerifyFileWithFile( CString sPath, CString sSignatureFile, CString sPublicKeyFile )
|
||||||
|
{
|
||||||
|
ASSERT( PREFSMAN->m_bSignProfileData );
|
||||||
|
|
||||||
CString sMessageFilename = sPath;
|
CString sMessageFilename = sPath;
|
||||||
if( sSignatureFile.empty() )
|
if( sSignatureFile.empty() )
|
||||||
sSignatureFile = sPath + SIGNATURE_APPEND;
|
sSignatureFile = sPath + SIGNATURE_APPEND;
|
||||||
|
|
||||||
if( !IsAFile(sPubFilename) )
|
if( !IsAFile(sPublicKeyFile) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( !IsAFile(sSignatureFile) )
|
if( !IsAFile(sSignatureFile) )
|
||||||
@@ -170,7 +193,7 @@ bool CryptManager::VerifyFileWithFile( CString sPath, CString sSignatureFile )
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RageFileSource pubFile(sPubFilename, true);
|
RageFileSource pubFile(sPublicKeyFile, true);
|
||||||
RSASSA_PKCS1v15_SHA_Verifier pub(pubFile);
|
RSASSA_PKCS1v15_SHA_Verifier pub(pubFile);
|
||||||
|
|
||||||
RageFileSource signatureFile(sSignatureFile, true);
|
RageFileSource signatureFile(sSignatureFile, true);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ public:
|
|||||||
|
|
||||||
static void SignFileToFile( CString sPath, CString sSignatureFile = "" );
|
static void SignFileToFile( CString sPath, CString sSignatureFile = "" );
|
||||||
static bool VerifyFileWithFile( CString sPath, CString sSignatureFile = "" );
|
static bool VerifyFileWithFile( CString sPath, CString sSignatureFile = "" );
|
||||||
|
static bool VerifyFileWithFile( CString sPath, CString sSignatureFile, CString sPublicKeyFile );
|
||||||
|
|
||||||
static CString Sign( CString sPath );
|
static CString Sign( CString sPath );
|
||||||
static bool Verify( CString sPath, CString sSignature );
|
static bool Verify( CString sPath, CString sSignature );
|
||||||
|
|||||||
Reference in New Issue
Block a user