Files
UnrealEngineUWP/Engine/Source/Developer/PakFileUtilities/Private/SignedArchiveWriter.h
graeme thornton f9123f5f24 Created a new interface to RSA functionality that is independent of key size (unlike the old TBigInt version). Internally, RSA functions are implemented by OpenSSL on Windows/Mac/Linux an falling back to the TBigInt implementation for other platforms
- Future plan would be not to use OpenSSL directly, but to go via PlatformCrypto or something like it which could provide platform specific RSA functionality if it exists
- Also contains some compensation code for platforms that are still stuck on an older version of OpenSSL (everything except windows)
- On platforms that use OpenSSL < 1.1.1, register a locking callback so we can provide mutexes and stop it crashing horribly when the same RSA key is used concurrently on different threads

Changed default key size in the CryptoKeys plugin to 4096 bits.

#jira UE-71377
#rb ian.fox, robert.manuszewski, ryan.gerleve

#ROBOMERGE-OWNER: ryan.vance
#ROBOMERGE-AUTHOR: graeme.thornton
#ROBOMERGE-SOURCE: CL 5447433 in //UE4/Release-4.22/... via CL 5447485
#ROBOMERGE-BOT: DEVVR (Main -> Dev-VR)

[CL 5447722 by graeme thornton in Dev-VR branch]
2019-03-19 09:01:04 -04:00

49 lines
1.2 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Serialization/Archive.h"
#include "Serialization/MemoryWriter.h"
#include "Math/BigInt.h"
#include "IPlatformFilePak.h"
/**
* Wrapper for writing and signing an archive
*/
class FSignedArchiveWriter : public FArchive
{
/** Buffer to sign */
TArray<uint8> Buffer;
/** Buffer writer */
FMemoryWriter BufferArchive;
/** The actual pak archive */
FArchive& PakWriter;
/** The filename of the signature file that accompanies the pak */
FString PakSignaturesFilename;
/** Size of the archive on disk (including signatures) */
int64 SizeOnDisk;
/** Data size (excluding signatures) */
int64 PakSize;
/** Signing key */
FRSA::TKeyPtr SigningKey;
/** Hashes */
TArray<TPakChunkHash> ChunkHashes;
/**
* Serializes and signs a buffer
*/
void SerializeBufferAndSign();
public:
FSignedArchiveWriter(FArchive& InPak, const FString& InPakFilename, FRSA::TKeyPtr InSigningKey);
virtual ~FSignedArchiveWriter();
// FArchive interface
virtual bool Close() override;
virtual void Serialize(void* Data, int64 Length) override;
virtual int64 Tell() override;
virtual int64 TotalSize() override;
virtual void Seek(int64 InPos) override;
};