diff --git a/ExampleApp/main.cpp b/ExampleApp/main.cpp index c75ab7d..6c735fa 100644 --- a/ExampleApp/main.cpp +++ b/ExampleApp/main.cpp @@ -12,7 +12,7 @@ void ExampleString() std::cout << "Example on how to encrypt & decrypt a string:" << std::endl; // Get some string - const std::string input = "I am a super secret message!I am a super secret message!I am a super secret message!I am a super secret message!I am a super secret message!I am a super secret message!I am a super secret message!I am a super secret message!I am a super secret message!I am a super secret message!I am a super secret message!I am a super secret message!I am a super secret message!"; + const std::string input = "I am a super secret message!"; std::cout << input << std::endl; // Encrypt diff --git a/GhettoCrypt/InitializationVector.cpp b/GhettoCrypt/InitializationVector.cpp index c1b9a8f..ac3b872 100644 --- a/GhettoCrypt/InitializationVector.cpp +++ b/GhettoCrypt/InitializationVector.cpp @@ -1,34 +1,12 @@ #include "InitializationVector.h" -#include -#include - -// It would be REALLY BAD if another compiler/*version would use -// a mersenne twister with different attrbitutes. It would basically mean -// that E_machine1(M,K) != E_machine2(M,K), which would make them incompatible. -// We do NOT want this to happen, so let's be VERY specific about what mersenne twister setup we want. -// This is std::mt19937, as of msvc stl. -using Prng_MT = std::mersenne_twister_engine< - unsigned int, - 32, 624, 397, 31, 0x9908b0df, 11, 0xffffffff, - 7, 0x9d2c5680, 15,0xefc60000, 18, 1812433253 ->; +#include +#include "Feistel.h" GhettoCipher::InitializationVector::InitializationVector(const Block& seed) { - // Since an initialization vector does not have to be a secret, - // we should be fine just using a mersenne twister seeded with - // for example the key to fill it up to fit BLOCK_SIZE. - - // Loosely seed mersenne twister with seed - // Here is nothing copied. Both Block::Get, and Hash<>::operator() take refs. - Prng_MT mt = Prng_MT(std::hash>()(seed.Get())); - // Now generate BLOCK_SIZE urandom bits - std::stringstream ss; - for (std::size_t i = 0; i < BLOCK_SIZE; i++) - ss << (mt() % 2 ? '1' : '0'); - - // And create a block - iv = Block(ss.str()); + // We'll generate our initialization vector by encrypting our seed with itself as a key + // iv = E(M=seed, K=seed) + iv = Feistel(seed).Encipher(seed); } GhettoCipher::InitializationVector::operator GhettoCipher::Block() const diff --git a/GhettoCrypt/Version.h b/GhettoCrypt/Version.h index 5667d5b..c2e7dc2 100644 --- a/GhettoCrypt/Version.h +++ b/GhettoCrypt/Version.h @@ -1,2 +1,2 @@ #pragma once -#define GHETTOCRYPT_VERSION 0.2 +#define GHETTOCRYPT_VERSION 0.21 diff --git a/GhettoCryptCLI/Version.h b/GhettoCryptCLI/Version.h index 6ce6300..2380443 100644 --- a/GhettoCryptCLI/Version.h +++ b/GhettoCryptCLI/Version.h @@ -1,2 +1,2 @@ #pragma once -#define GHETTOCRYPTCLI_VERSION 0.12 +#define GHETTOCRYPTCLI_VERSION 0.121 diff --git a/GhettoCryptCLI/gecrypt b/GhettoCryptCLI/gecrypt index d701bdc..a3855f7 100644 Binary files a/GhettoCryptCLI/gecrypt and b/GhettoCryptCLI/gecrypt differ