From c4f600fa9f168ac3ba56cc0d6b8f445bbffe9563 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 31 Jan 2007 03:05:43 +0000 Subject: [PATCH] better api --- stepmania/src/CryptManager.cpp | 18 +++++++++--------- stepmania/src/CryptManager.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/stepmania/src/CryptManager.cpp b/stepmania/src/CryptManager.cpp index e951cd5e56..d596e49bd6 100644 --- a/stepmania/src/CryptManager.cpp +++ b/stepmania/src/CryptManager.cpp @@ -14,7 +14,7 @@ static const RString PRIVATE_KEY_PATH = "Data/private.rsa"; static const RString PUBLIC_KEY_PATH = "Data/public.rsa"; static const RString ALTERNATE_PUBLIC_KEY_DIR = "Data/keys/"; -static bool HashFile( RageFile &f, unsigned char buf_hash[20], int iHash ) +static bool HashFile( RageFileBasic &f, unsigned char buf_hash[20], int iHash ) { hash_state hash; int iRet = hash_descriptor[iHash].init( &hash ); @@ -25,7 +25,7 @@ static bool HashFile( RageFile &f, unsigned char buf_hash[20], int iHash ) { if( f.Read(s, 1024*4) == -1 ) { - LOG->Warn( "Error reading %s: %s", f.GetPath().c_str(), f.GetError().c_str() ); + LOG->Warn( "Error reading %s: %s", f.GetDisplayPath().c_str(), f.GetError().c_str() ); hash_descriptor[iHash].done( &hash, buf_hash ); return false; } @@ -358,11 +358,6 @@ bool CryptManager::VerifyFileWithFile( RString sPath, RString sSignatureFile, RS if( !GetFileContents(sSignatureFile, sSignature) ) return false; - return Verify( sPath, sSignature, sPublicKey ); -} - -bool CryptManager::Verify( RString sPath, RString sSignature, RString sPublicKey ) -{ RageFile file; if( !file.Open(sPath) ) { @@ -370,6 +365,11 @@ bool CryptManager::Verify( RString sPath, RString sSignature, RString sPublicKey return false; } + return Verify( file, sSignature, sPublicKey ); +} + +bool CryptManager::Verify( RageFileBasic &file, RString sSignature, RString sPublicKey ) +{ RSAKeyWrapper key; if( !key.Load(sPublicKey) ) return false; @@ -387,13 +387,13 @@ bool CryptManager::Verify( RString sPath, RString sSignature, RString sPublicKey if( iRet != CRYPT_OK ) { - LOG->Warn( "Verify(%s) failed: %s", sPath.c_str(), error_to_string(iRet) ); + LOG->Warn( "Verify(%s) failed: %s", file.GetDisplayPath().c_str(), error_to_string(iRet) ); return false; } if( !iMatch ) { - LOG->Warn( "Verify(%s) failed: signature mismatch", sPath.c_str() ); + LOG->Warn( "Verify(%s) failed: signature mismatch", file.GetDisplayPath().c_str() ); return false; } diff --git a/stepmania/src/CryptManager.h b/stepmania/src/CryptManager.h index b02742e2d2..d58b9292ab 100644 --- a/stepmania/src/CryptManager.h +++ b/stepmania/src/CryptManager.h @@ -16,7 +16,7 @@ public: static bool Sign( RString sPath, RString &sSignatureOut, RString sPrivateKey ); static bool VerifyFileWithFile( RString sPath, RString sSignatureFile = "" ); static bool VerifyFileWithFile( RString sPath, RString sSignatureFile, RString sPublicKeyFile ); - static bool Verify( RString sPath, RString sSignature, RString sPublicKey ); + static bool Verify( RageFileBasic &file, RString sSignature, RString sPublicKey ); static void GetRandomBytes( void *pData, int iBytes );