From ba37b4325c8eefbff8bbd508b0487d7e14573e22 Mon Sep 17 00:00:00 2001 From: Leonetienne Date: Tue, 31 May 2022 18:19:12 +0200 Subject: [PATCH] Integrated DataOutputLayer to ModuleGenerateKey --- GCryptCLI/src/ModuleGenerateKey.cpp | 21 +++++++++++++++++++-- GCryptCLI/src/main.cpp | 3 +++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/GCryptCLI/src/ModuleGenerateKey.cpp b/GCryptCLI/src/ModuleGenerateKey.cpp index 8d84d61..3707829 100644 --- a/GCryptCLI/src/ModuleGenerateKey.cpp +++ b/GCryptCLI/src/ModuleGenerateKey.cpp @@ -1,5 +1,5 @@ #include "ModuleGenerateKey.h" - +#include "DataOutputLayer.h" #include "KeyManager.h" #include "CommandlineInterface.h" @@ -8,7 +8,24 @@ using namespace Module; void GenerateKey::Run() { - // Pass KeyManager::GetKey() to data output layer + // Initialize the data output layer + IO::DataOutputLayer::Init(); + + // Enqueue our single block of data + IO::DataOutputLayer::Enqueue(KeyManager::GetKey()); + + // Tell the data output layer, that is has received all blocks + IO::DataOutputLayer::ReachedEOF(); + + // Tell it to write all blocks + // (a single call should suffice, but a while-loop is the proper + // way to do it) + while (!IO::DataOutputLayer::IsFinished()) { + IO::DataOutputLayer::WriteBlock(); + } + + // Destruct the data output layer + IO::DataOutputLayer::Destruct(); return; } diff --git a/GCryptCLI/src/main.cpp b/GCryptCLI/src/main.cpp index 79748b5..f477576 100644 --- a/GCryptCLI/src/main.cpp +++ b/GCryptCLI/src/main.cpp @@ -19,8 +19,11 @@ int main(int argc, char* const* argv) { switch (Configuration::activeModule) { case Configuration::MODULE::GENERATE_KEY: Module::GenerateKey::Run(); + break; + case Configuration::MODULE::ENCRYPTION: Module::Encryption::Run(); + break; } return 0;