Files
UnrealEngineUWP/Engine/Source/Developer/PakFileUtilities/Private/KeyGenerator.h
ben marsh 2b46ba7b94 Update copyright notices to 2019.
#rb none
#lockdown Nick.Penwarden

#ROBOMERGE-OWNER: ryan.gerleve
#ROBOMERGE-AUTHOR: ben.marsh
#ROBOMERGE-SOURCE: CL 4662404 in //UE4/Main/...
#ROBOMERGE-BOT: ENGINE (Main -> Dev-Networking)

[CL 4662413 by ben marsh in Dev-Networking branch]
2018-12-14 13:44:01 -05:00

49 lines
1.1 KiB
C

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Math/BigInt.h"
/**
* Encryption keys: public and private
*/
struct FKeyPair
{
/** Public decryption key */
FEncryptionKey PublicKey;
/** Private encryption key */
FEncryptionKey PrivateKey;
friend FArchive& operator<<(FArchive& Ar, FKeyPair& Pair)
{
Ar << Pair.PublicKey.Exponent;
Ar << Pair.PublicKey.Modulus;
Ar << Pair.PrivateKey.Exponent;
Ar << Pair.PrivateKey.Modulus;
return Ar;
}
bool IsValid() const
{
return !PrivateKey.Exponent.IsZero()
&& !PrivateKey.Modulus.IsZero()
&& !PublicKey.Exponent.IsZero()
&& !PublicKey.Modulus.IsZero();
}
};
/**
* Generates a prime number table where the max prime number value is less than MaxValue
*/
void GeneratePrimeNumberTable(int64 MaxValue, const TCHAR* Filename);
/**
* Generates a file with the encryption keys
*/
bool GenerateKeys(const TCHAR* KeyFilename);
bool SaveKeysToFile(const FKeyPair& Keys, const TCHAR* KeyFilename);
bool ReadKeysFromFile(const TCHAR* KeyFilename, FKeyPair& OutKeys);
bool TestKeys(FKeyPair& Pair);