sign screenshots saved to a profile
This commit is contained in:
@@ -30,8 +30,8 @@ void RSASignFile(const char *privFilename, const char *messageFilename, const ch
|
||||
{
|
||||
FileSource privFile(privFilename, true, new HexDecoder);
|
||||
RSASSA_PKCS1v15_SHA_Signer priv(privFile);
|
||||
// RSASSA_PKCS1v15_SHA_Signer ignores the rng. Use a real RNG for other signature schemes!
|
||||
FileSource f(messageFilename, true, new SignerFilter(NullRNG(), priv, new HexEncoder(new FileSink(signatureFilename))));
|
||||
RandomNumberGenerator &rng = RandomPool();
|
||||
FileSource f(messageFilename, true, new SignerFilter(rng, priv, new HexEncoder(new FileSink(signatureFilename))));
|
||||
}
|
||||
|
||||
bool RSAVerifyFile(const char *pubFilename, const char *messageFilename, const char *signatureFilename)
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#ifndef CryptHelpers_H
|
||||
#define CryptHelpers_H
|
||||
|
||||
void GenerateRSAKey(unsigned int keyLength, const char *privFilename, const char *pubFilename, const char *seed);
|
||||
void RSASignFile(const char *privFilename, const char *messageFilename, const char *signatureFilename);
|
||||
bool RSAVerifyFile(const char *pubFilename, const char *messageFilename, const char *signatureFilename);
|
||||
void DigestFile(const char *filename);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1322,7 +1322,7 @@ void ScreenEvaluation::Input( const DeviceInput& DeviceI, const InputEventType t
|
||||
/* StyleI won't be valid if it's a menu button that's pressed.
|
||||
* There's got to be a better way of doing this. -Chris */
|
||||
CString sDir = PROFILEMAN->GetProfileDir((ProfileSlot)pn);
|
||||
SaveScreenshot( sDir );
|
||||
SaveScreenshot( sDir, true, true );
|
||||
m_bSavedScreenshot[pn] = true;
|
||||
return; // handled
|
||||
}
|
||||
|
||||
+37
-10
@@ -32,6 +32,7 @@
|
||||
#include "SDL_utils.h"
|
||||
|
||||
#include "CodeDetector.h"
|
||||
#include "CryptHelpers.h"
|
||||
|
||||
//
|
||||
// StepMania global classes
|
||||
@@ -791,6 +792,11 @@ void SaveGamePrefsToDisk()
|
||||
ini.WriteFile();
|
||||
}
|
||||
|
||||
static void OnFirstRun()
|
||||
{
|
||||
// TODO: generate a machine keypair here
|
||||
}
|
||||
|
||||
static void MountTreeOfZips( const CString &dir )
|
||||
{
|
||||
vector<CString> dirs;
|
||||
@@ -916,6 +922,9 @@ int main(int argc, char* argv[])
|
||||
|
||||
CheckSDLVersion( 1,2,6 );
|
||||
|
||||
if( PREFSMAN->m_bFirstRun )
|
||||
OnFirstRun();
|
||||
|
||||
/* This should be done after PREFSMAN is set up, so it can use HOOKS->MessageBoxOK,
|
||||
* but before we do more complex things that might crash. */
|
||||
HOOKS->DumpDebugInfo();
|
||||
@@ -1083,25 +1092,43 @@ int main(int argc, char* argv[])
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SaveScreenshot( CString sDir, bool bSaveUncompressed )
|
||||
bool SaveScreenshot( CString sDir, bool bSaveCompressed, bool bMakeSignature )
|
||||
{
|
||||
// Save Screenshot.
|
||||
CString sPath;
|
||||
|
||||
//
|
||||
// Find a file name for the screenshot
|
||||
//
|
||||
FlushDirCache();
|
||||
|
||||
CString sScreenshotPath;
|
||||
/* XXX slow? */
|
||||
for( int i=0; i<10000; i++ )
|
||||
{
|
||||
sPath = ssprintf( sDir+"screen%04d.%s",i,bSaveUncompressed ? "bmp" : "jpg" );
|
||||
if( !DoesFileExist(sPath) )
|
||||
sScreenshotPath = ssprintf( sDir+"screen%04d.%s", i, bSaveCompressed ? "jpg" : "bmp" );
|
||||
if( !DoesFileExist(sScreenshotPath) )
|
||||
break;
|
||||
}
|
||||
bool bResult = DISPLAY->SaveScreenshot( sPath, bSaveUncompressed ? RageDisplay::bmp : RageDisplay::jpg );
|
||||
|
||||
//
|
||||
// Save the screenshot
|
||||
//
|
||||
bool bResult = DISPLAY->SaveScreenshot( sScreenshotPath, bSaveCompressed ? RageDisplay::jpg : RageDisplay::bmp );
|
||||
if( bResult )
|
||||
SOUND->PlayOnce( THEME->GetPathToS("Common screenshot") );
|
||||
else
|
||||
{
|
||||
SOUND->PlayOnce( THEME->GetPathToS("Common invalid") );
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Write a signature
|
||||
//
|
||||
if( bMakeSignature )
|
||||
{
|
||||
CString sSignaturePath = sScreenshotPath + ".sig.rsa";
|
||||
RSASignFile( "private.rsa", sScreenshotPath, sSignaturePath);
|
||||
}
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
@@ -1203,9 +1230,9 @@ bool HandleGlobalInputs( DeviceInput DeviceI, InputEventType type, GameInput Gam
|
||||
(INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_RMETA)) ||
|
||||
INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_LMETA)))))
|
||||
{
|
||||
// If holding LShift save a BMP, else save a JPG
|
||||
bool bSaveUncompressed = INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_LSHIFT) );
|
||||
SaveScreenshot( "Screenshots/", bSaveUncompressed );
|
||||
// If holding LShift save uncompressed, else save compressed
|
||||
bool bSaveCompressed = !INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_LSHIFT) );
|
||||
SaveScreenshot( "Screenshots/", bSaveCompressed, false );
|
||||
return true; // handled
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ void ResetGame( bool ReturnToFirstScreen=true );
|
||||
void ReadGamePrefsFromDisk( bool bSwitchToLastPlayedGame=true );
|
||||
void SaveGamePrefsToDisk();
|
||||
void ChangeCurrentGame( Game g );
|
||||
bool SaveScreenshot( CString sDir, bool bSaveUncompressed = false );
|
||||
bool SaveScreenshot( CString sDir, bool bSaveCompressed, bool bMakeSignature );
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
#include "windows.h"
|
||||
|
||||
Reference in New Issue
Block a user