summaryrefslogtreecommitdiffstats
path: root/cryptopp562/iterhash.h
diff options
context:
space:
mode:
authorMalfurious <m@lfurio.us>2024-10-24 06:44:24 -0400
committerMalfurious <m@lfurio.us>2024-10-24 06:44:24 -0400
commit512aa4c77b3dc0d72db713a9215ff65a98a99ec3 (patch)
tree6db82e0109dc987b5b021f81d4e8a0926eb75ff7 /cryptopp562/iterhash.h
parent428471d39fb8c205a9fad899c88c30a2cb7df685 (diff)
parent10affea371406c0ae4c080e5a19390a8e9bd154b (diff)
downloadcompass-512aa4c77b3dc0d72db713a9215ff65a98a99ec3.tar.gz
compass-512aa4c77b3dc0d72db713a9215ff65a98a99ec3.zip
Merge branch 'mbedtls'
Replace Crypto++ 5.6.2 with Mbed TLS 3.6.0 Newer compilers are starting to show the age of the crypto library we've been using, as it is sometimes a pain to recompile compass lately. So, the tracked version of Crypto++ was at least due for an upgrade. However, I plan to soon begin reimplementing compass in C. So, I'm taking this opportunity to first just migrate the cryptography library to a newer C alternative. This branch does so, and integrates its use into the current C++ version of compass. * mbedtls: Remove unnecessary exception handler catch block Refactor random password generation to use mbedtls entropy source Refactor SHA256 function to use mbedtls Refactor AES functions to use mbedtls Add Mbedtls library Remove Crypto++ library
Diffstat (limited to '')
-rw-r--r--cryptopp562/iterhash.h106
1 files changed, 0 insertions, 106 deletions
diff --git a/cryptopp562/iterhash.h b/cryptopp562/iterhash.h
deleted file mode 100644
index cce9e82..0000000
--- a/cryptopp562/iterhash.h
+++ /dev/null
@@ -1,106 +0,0 @@
-#ifndef CRYPTOPP_ITERHASH_H
-#define CRYPTOPP_ITERHASH_H
-
-#include "cryptlib.h"
-#include "secblock.h"
-#include "misc.h"
-#include "simple.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-//! exception thrown when trying to hash more data than is allowed by a hash function
-class CRYPTOPP_DLL HashInputTooLong : public InvalidDataFormat
-{
-public:
- explicit HashInputTooLong(const std::string &alg)
- : InvalidDataFormat("IteratedHashBase: input data exceeds maximum allowed by hash function " + alg) {}
-};
-
-//! _
-template <class T, class BASE>
-class CRYPTOPP_NO_VTABLE IteratedHashBase : public BASE
-{
-public:
- typedef T HashWordType;
-
- IteratedHashBase() : m_countLo(0), m_countHi(0) {}
- unsigned int OptimalBlockSize() const {return this->BlockSize();}
- unsigned int OptimalDataAlignment() const {return GetAlignmentOf<T>();}
- void Update(const byte *input, size_t length);
- byte * CreateUpdateSpace(size_t &size);
- void Restart();
- void TruncatedFinal(byte *digest, size_t size);
-
-protected:
- inline T GetBitCountHi() const {return (m_countLo >> (8*sizeof(T)-3)) + (m_countHi << 3);}
- inline T GetBitCountLo() const {return m_countLo << 3;}
-
- void PadLastBlock(unsigned int lastBlockSize, byte padFirst=0x80);
- virtual void Init() =0;
-
- virtual ByteOrder GetByteOrder() const =0;
- virtual void HashEndianCorrectedBlock(const HashWordType *data) =0;
- virtual size_t HashMultipleBlocks(const T *input, size_t length);
- void HashBlock(const HashWordType *input) {HashMultipleBlocks(input, this->BlockSize());}
-
- virtual T* DataBuf() =0;
- virtual T* StateBuf() =0;
-
-private:
- T m_countLo, m_countHi;
-};
-
-//! _
-template <class T_HashWordType, class T_Endianness, unsigned int T_BlockSize, class T_Base = HashTransformation>
-class CRYPTOPP_NO_VTABLE IteratedHash : public IteratedHashBase<T_HashWordType, T_Base>
-{
-public:
- typedef T_Endianness ByteOrderClass;
- typedef T_HashWordType HashWordType;
-
- CRYPTOPP_CONSTANT(BLOCKSIZE = T_BlockSize)
- // BCB2006 workaround: can't use BLOCKSIZE here
- CRYPTOPP_COMPILE_ASSERT((T_BlockSize & (T_BlockSize - 1)) == 0); // blockSize is a power of 2
- unsigned int BlockSize() const {return T_BlockSize;}
-
- ByteOrder GetByteOrder() const {return T_Endianness::ToEnum();}
-
- inline static void CorrectEndianess(HashWordType *out, const HashWordType *in, size_t byteCount)
- {
- ConditionalByteReverse(T_Endianness::ToEnum(), out, in, byteCount);
- }
-
-protected:
- T_HashWordType* DataBuf() {return this->m_data;}
- FixedSizeSecBlock<T_HashWordType, T_BlockSize/sizeof(T_HashWordType)> m_data;
-};
-
-//! _
-template <class T_HashWordType, class T_Endianness, unsigned int T_BlockSize, unsigned int T_StateSize, class T_Transform, unsigned int T_DigestSize = 0, bool T_StateAligned = false>
-class CRYPTOPP_NO_VTABLE IteratedHashWithStaticTransform
- : public ClonableImpl<T_Transform, AlgorithmImpl<IteratedHash<T_HashWordType, T_Endianness, T_BlockSize>, T_Transform> >
-{
-public:
- CRYPTOPP_CONSTANT(DIGESTSIZE = T_DigestSize ? T_DigestSize : T_StateSize)
- unsigned int DigestSize() const {return DIGESTSIZE;};
-
-protected:
- IteratedHashWithStaticTransform() {this->Init();}
- void HashEndianCorrectedBlock(const T_HashWordType *data) {T_Transform::Transform(this->m_state, data);}
- void Init() {T_Transform::InitState(this->m_state);}
-
- T_HashWordType* StateBuf() {return this->m_state;}
- FixedSizeAlignedSecBlock<T_HashWordType, T_BlockSize/sizeof(T_HashWordType), T_StateAligned> m_state;
-};
-
-#ifndef __GNUC__
- CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word64, HashTransformation>;
- CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase<word64, MessageAuthenticationCode>;
-
- CRYPTOPP_DLL_TEMPLATE_CLASS IteratedHashBase<word32, HashTransformation>;
- CRYPTOPP_STATIC_TEMPLATE_CLASS IteratedHashBase<word32, MessageAuthenticationCode>;
-#endif
-
-NAMESPACE_END
-
-#endif