diff --git a/stepmania/src/CryptManager.cpp b/stepmania/src/CryptManager.cpp index 65cc4fe217..99d8c659e8 100644 --- a/stepmania/src/CryptManager.cpp +++ b/stepmania/src/CryptManager.cpp @@ -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. diff --git a/stepmania/src/CryptManager.h b/stepmania/src/CryptManager.h index 8c5c794141..02843b1dcc 100644 --- a/stepmania/src/CryptManager.h +++ b/stepmania/src/CryptManager.h @@ -16,7 +16,7 @@ public: static bool VerifyFileWithFile( RString sPath, RString sSignatureFile = "" ); static bool VerifyFileWithFile( RString sPath, RString sSignatureFile, RString sPublicKeyFile ); - static RString Sign( RString sPath ); + static void GetRandomBytes( void *pData, int iBytes ); static RString GetMD5ForFile( RString fn ); // in Hex static RString GetMD5ForString( RString sData ); // in Hex diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index 9d074d017e..13887ff1a5 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -15,7 +15,6 @@ #include "ProfileManager.h" #include "RageFileManager.h" #include "LuaManager.h" -#include "crypto/CryptRand.h" #include "UnlockManager.h" #include "XmlFile.h" #include "XmlFileUtil.h" @@ -85,13 +84,12 @@ void Profile::InitEditableData() RString Profile::MakeGuid() { - // Does the RNG need to be inited and seeded every time? - random_init(); - random_add_noise( "ai8049ujr3odusj" ); - RString s; + s.resize( GUID_SIZE_BYTES ); + char buf[GUID_SIZE_BYTES]; + CryptManager::GetRandomBytes( buf, GUID_SIZE_BYTES ); for( unsigned i=0; i