move secure random code

This commit is contained in:
Glenn Maynard
2006-12-20 23:17:57 +00:00
parent b8cb44c0be
commit ea7e48e08e
3 changed files with 24 additions and 7 deletions
+19
View File
@@ -6,6 +6,7 @@
#include "PrefsManager.h"
#include "RageFileManager.h"
#include "crypto/CryptMD5.h"
#include "crypto/CryptRand.h"
CryptManager* CRYPTMAN = NULL; // global and accessable from anywhere in our program
@@ -24,6 +25,13 @@ bool CryptManager::VerifyFileWithFile( RString sPath, RString sSignatureFile )
return true;
}
void CryptManager::GetRandomBytes( void *pData, int iBytes )
{
uint8_t *pBuf = (uint8_t *) pData;
while( iBytes-- )
*pBuf++ = (uint8_t) RandomInt( 256 );
}
#else
// crypt headers
@@ -232,6 +240,17 @@ RString CryptManager::GetPublicKeyFileName()
return PUBLIC_KEY_PATH;
}
void CryptManager::GetRandomBytes( void *pData, int iBytes )
{
// Does the RNG need to be inited and seeded every time?
random_init();
random_add_noise( "ai8049ujr3odusj" );
uint8_t *pBuf = (uint8_t *) pData;
while( iBytes-- )
*pBuf++ = random_byte();
}
/*
* (c) 2004 Chris Danford
* All rights reserved.