move secure random code
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user