fix DISABLE_CRYPTO
This commit is contained in:
@@ -14,6 +14,32 @@ static const RString PRIVATE_KEY_PATH = "Data/private.rsa";
|
|||||||
static const RString PUBLIC_KEY_PATH = "Data/public.rsa";
|
static const RString PUBLIC_KEY_PATH = "Data/public.rsa";
|
||||||
static const RString ALTERNATE_PUBLIC_KEY_DIR = "Data/keys/";
|
static const RString ALTERNATE_PUBLIC_KEY_DIR = "Data/keys/";
|
||||||
|
|
||||||
|
static bool HashFile( RageFile &f, unsigned char buf_hash[20], int iHash )
|
||||||
|
{
|
||||||
|
hash_state hash;
|
||||||
|
int iRet = hash_descriptor[iHash].init( &hash );
|
||||||
|
ASSERT_M( iRet == CRYPT_OK, error_to_string(iRet) );
|
||||||
|
|
||||||
|
RString s;
|
||||||
|
while( !f.AtEOF() )
|
||||||
|
{
|
||||||
|
if( f.Read(s, 1024*4) == -1 )
|
||||||
|
{
|
||||||
|
LOG->Warn( "Error reading %s: %s", f.GetPath().c_str(), f.GetError().c_str() );
|
||||||
|
hash_descriptor[iHash].done( &hash, buf_hash );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
iRet = hash_descriptor[iHash].process( &hash, (const unsigned char *) s.data(), s.size() );
|
||||||
|
ASSERT_M( iRet == CRYPT_OK, error_to_string(iRet) );
|
||||||
|
}
|
||||||
|
|
||||||
|
iRet = hash_descriptor[iHash].done( &hash, buf_hash );
|
||||||
|
ASSERT_M( iRet == CRYPT_OK, error_to_string(iRet) );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(DISABLE_CRYPTO)
|
#if defined(DISABLE_CRYPTO)
|
||||||
CryptManager::CryptManager() { }
|
CryptManager::CryptManager() { }
|
||||||
CryptManager::~CryptManager() { }
|
CryptManager::~CryptManager() { }
|
||||||
@@ -116,32 +142,6 @@ public:
|
|||||||
rsa_key m_Key;
|
rsa_key m_Key;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool HashFile( RageFile &f, unsigned char buf_hash[20], int iHash )
|
|
||||||
{
|
|
||||||
hash_state hash;
|
|
||||||
int iRet = hash_descriptor[iHash].init( &hash );
|
|
||||||
ASSERT_M( iRet == CRYPT_OK, error_to_string(iRet) );
|
|
||||||
|
|
||||||
RString s;
|
|
||||||
while( !f.AtEOF() )
|
|
||||||
{
|
|
||||||
if( f.Read(s, 1024*4) == -1 )
|
|
||||||
{
|
|
||||||
LOG->Warn( "Error reading %s: %s", f.GetPath().c_str(), f.GetError().c_str() );
|
|
||||||
hash_descriptor[iHash].done( &hash, buf_hash );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
iRet = hash_descriptor[iHash].process( &hash, (const unsigned char *) s.data(), s.size() );
|
|
||||||
ASSERT_M( iRet == CRYPT_OK, error_to_string(iRet) );
|
|
||||||
}
|
|
||||||
|
|
||||||
iRet = hash_descriptor[iHash].done( &hash, buf_hash );
|
|
||||||
ASSERT_M( iRet == CRYPT_OK, error_to_string(iRet) );
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
CryptManager::CryptManager()
|
CryptManager::CryptManager()
|
||||||
{
|
{
|
||||||
ltc_mp = ltm_desc;
|
ltc_mp = ltm_desc;
|
||||||
@@ -372,6 +372,12 @@ bool CryptManager::Verify( RString sPath, RString sSignature, RString sPublicKey
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CryptManager::GetRandomBytes( void *pData, int iBytes )
|
||||||
|
{
|
||||||
|
int iRet = prng_descriptor[g_pPRNG->m_iPRNG].read( (unsigned char *) pData, iBytes, &g_pPRNG->m_PRNG );
|
||||||
|
ASSERT( iRet == iBytes );
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
RString CryptManager::GetMD5ForFile( RString fn )
|
RString CryptManager::GetMD5ForFile( RString fn )
|
||||||
@@ -412,12 +418,6 @@ RString CryptManager::GetPublicKeyFileName()
|
|||||||
return PUBLIC_KEY_PATH;
|
return PUBLIC_KEY_PATH;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CryptManager::GetRandomBytes( void *pData, int iBytes )
|
|
||||||
{
|
|
||||||
int iRet = prng_descriptor[g_pPRNG->m_iPRNG].read( (unsigned char *) pData, iBytes, &g_pPRNG->m_PRNG );
|
|
||||||
ASSERT( iRet == iBytes );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2004-2007 Chris Danford, Glenn Maynard
|
* (c) 2004-2007 Chris Danford, Glenn Maynard
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
Reference in New Issue
Block a user