add size check for signature files

This commit is contained in:
Chris Danford
2004-05-22 19:50:16 +00:00
parent 88564f6b24
commit a12cc31f3a
+6
View File
@@ -3,6 +3,7 @@
#include "RageUtil.h"
#include "RageLog.h"
#include "PrefsManager.h"
#include "RageFileManager.h"
// crypt headers
#include "CryptHelpers.h"
@@ -18,6 +19,7 @@ using namespace std;
static const CString PRIVATE_KEY_PATH = "Data/private.rsa";
static const CString PUBLIC_KEY_PATH = "Data/public.rsa";
static const int KEY_LENGTH = 1024;
#define MAX_SIGNATURE_SIZE_BYTES 1024 // 1 KB
CryptManager* CRYPTMAN = NULL; // global and accessable from anywhere in our program
@@ -100,6 +102,10 @@ bool CryptManager::VerifyFileWithFile( CString sPath, CString sSignatureFile )
if( !IsAFile(sSignatureFile) )
return false;
int iBytes = FILEMAN->GetFileSizeInBytes( sSignatureFile );
if( iBytes > MAX_SIGNATURE_SIZE_BYTES )
return false;
try {
RageFileSource pubFile(sPubFilename, true);
RSASSA_PKCS1v15_SHA_Verifier pub(pubFile);