From 075a3f6f4450967671d10b6d9e9388eb0d23b935 Mon Sep 17 00:00:00 2001 From: manzerbredes Date: Wed, 11 Mar 2015 10:18:34 +0400 Subject: Clear branch --- CryptClass/AESCrypt.cpp | 0 CryptClass/AESCrypt.hpp | 0 CryptClass/HASHCrypt.cpp | 68 --------------------------------- CryptClass/HASHCrypt.hpp | 99 ------------------------------------------------ 4 files changed, 167 deletions(-) delete mode 100644 CryptClass/AESCrypt.cpp delete mode 100644 CryptClass/AESCrypt.hpp delete mode 100644 CryptClass/HASHCrypt.cpp delete mode 100644 CryptClass/HASHCrypt.hpp (limited to 'CryptClass') diff --git a/CryptClass/AESCrypt.cpp b/CryptClass/AESCrypt.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/CryptClass/AESCrypt.hpp b/CryptClass/AESCrypt.hpp deleted file mode 100644 index e69de29..0000000 diff --git a/CryptClass/HASHCrypt.cpp b/CryptClass/HASHCrypt.cpp deleted file mode 100644 index 4c42ef3..0000000 --- a/CryptClass/HASHCrypt.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/** - * @file HASHCrypt.cpp - * @brief HASHCrypt class definitions - * @author manzerbredes - * @date 8 Mars 2015 - * - * Contain all definitions of HASHCrypt class. - * - */ - - -#include "HASHCrypt.hpp" - - -//Constructor -HASHCrypt::HASHCrypt(){ -} - -//Destructor -HASHCrypt::~HASHCrypt(){ -} - - - -void HASHCrypt::getMD5_128(std::string chain, byte* digest, int size){ - - //Digest size controller - this->checkDigestSize(CryptoPP::Weak1::MD5::DIGESTSIZE,size); - - //Create the MD5 on digest parameter - CryptoPP::Weak1::MD5 hash; - hash.CalculateDigest( digest, (byte*) chain.c_str(), chain.length() ); - -} - - -void HASHCrypt::getSHA_256(std::string chain, byte* digest, int size){ - - //Digest size controller - this->checkDigestSize(CryptoPP::SHA256::DIGESTSIZE,size); - - //Create the SHA-256 on digest parameter - CryptoPP::SHA256 hash; - hash.CalculateDigest( digest, (byte*) chain.c_str(), chain.length() ); -} - - - -void HASHCrypt::checkDigestSize(int sizeRequired, int size){ - try{ - if(size !=sizeRequired){ - throw this->getInvalidDigestSizeError(sizeRequired, size); - } - - } - catch(std::string erreur){ - std::cerr << erreur < -#include -#include - -//----- crypto++ ----- -#include //For MD5 -#include //For Hex convertion -#include //For SHA - - - - -/** - * @class HASHCrypt HASHCrypt.hpp "/CryptClass/HASHCrypt.hpp" - * @brief Hashing class - * @author manzerbredes - * - * Class who handle hashing functions to a byte* parameter. - * HASHCrypt try to detect errors and throw exceptions. - * HASHCrypt use crypto++ library. - */ -class HASHCrypt{ - - public: - /** - * @brief Contructor - */ - HASHCrypt(); - - /** - * @brief Destructor - */ - ~HASHCrypt(); - - /** - * @brief Create an MD5 over 128 bits on a digest array of bytes. - * - * @param chain : Chain to hash - * @param digest : An array of bytes (8 bits) - * @param size : Length of the array digest - * - * **Warning** digest will be modified. - * Digest must be an array of byte with 16 entries - */ - void getMD5_128(std::string chain, byte* digest, int size); - - /** - * @brief Create an SHA over 256 bits on a digest array of bytes. - * - * @param chain : Chain to hash - * @param digest : An array of bytes (8 bits) - * @param size : Length of the array digest - * - * **Warning** digest will be modified. - * Digest must be an array of byte with 32 entries - */ - void getSHA_256(std::string chain, byte* digest, int size); //Retourne SHA_256 - - private: - - /** - * @brief Check the digest size - * - * @param sizeRequired : Digest size expected - * @param size : Given digest size - * - * Throw an exception, and stop the programm if - * sizeRequired != size - * Use getInvalidDigestSizeError method. - */ - void checkDigestSize(int sizeRequired, int size); - - /** - * @brief Make and error message. - * - * @param sizeRequired : Digest size expected - * @param size : Given digest size - * - * @return a string correspond to the error message - * - * Construct an error message with sizeRequired and size. - */ - std::string getInvalidDigestSizeError(int sizeRequired, int size); - - - -}; -- cgit v1.2.3