diff options
author | Malfurious <m@lfurio.us> | 2024-10-24 06:44:24 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2024-10-24 06:44:24 -0400 |
commit | 512aa4c77b3dc0d72db713a9215ff65a98a99ec3 (patch) | |
tree | 6db82e0109dc987b5b021f81d4e8a0926eb75ff7 /cryptopp562/zlib.cpp | |
parent | 428471d39fb8c205a9fad899c88c30a2cb7df685 (diff) | |
parent | 10affea371406c0ae4c080e5a19390a8e9bd154b (diff) | |
download | compass-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/zlib.cpp | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/cryptopp562/zlib.cpp b/cryptopp562/zlib.cpp deleted file mode 100644 index 4abafb0..0000000 --- a/cryptopp562/zlib.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// zlib.cpp - written and placed in the public domain by Wei Dai - -// "zlib" is the name of a well known C language compression library -// (http://www.zlib.org) and also the name of a compression format -// (RFC 1950) that the library implements. This file is part of a -// complete reimplementation of the zlib compression format. - -#include "pch.h" -#include "zlib.h" -#include "zdeflate.h" -#include "zinflate.h" - -NAMESPACE_BEGIN(CryptoPP) - -static const byte DEFLATE_METHOD = 8; -static const byte FDICT_FLAG = 1 << 5; - -// ************************************************************* - -void ZlibCompressor::WritePrestreamHeader() -{ - m_adler32.Restart(); - byte cmf = DEFLATE_METHOD | ((GetLog2WindowSize()-8) << 4); - byte flags = GetCompressionLevel() << 6; - AttachedTransformation()->PutWord16(RoundUpToMultipleOf(cmf*256+flags, 31)); -} - -void ZlibCompressor::ProcessUncompressedData(const byte *inString, size_t length) -{ - m_adler32.Update(inString, length); -} - -void ZlibCompressor::WritePoststreamTail() -{ - FixedSizeSecBlock<byte, 4> adler32; - m_adler32.Final(adler32); - AttachedTransformation()->Put(adler32, 4); -} - -unsigned int ZlibCompressor::GetCompressionLevel() const -{ - static const unsigned int deflateToCompressionLevel[] = {0, 1, 1, 1, 2, 2, 2, 2, 2, 3}; - return deflateToCompressionLevel[GetDeflateLevel()]; -} - -// ************************************************************* - -ZlibDecompressor::ZlibDecompressor(BufferedTransformation *attachment, bool repeat, int propagation) - : Inflator(attachment, repeat, propagation) -{ -} - -void ZlibDecompressor::ProcessPrestreamHeader() -{ - m_adler32.Restart(); - - byte cmf; - byte flags; - - if (!m_inQueue.Get(cmf) || !m_inQueue.Get(flags)) - throw HeaderErr(); - - if ((cmf*256+flags) % 31 != 0) - throw HeaderErr(); // if you hit this exception, you're probably trying to decompress invalid data - - if ((cmf & 0xf) != DEFLATE_METHOD) - throw UnsupportedAlgorithm(); - - if (flags & FDICT_FLAG) - throw UnsupportedPresetDictionary(); - - m_log2WindowSize = 8 + (cmf >> 4); -} - -void ZlibDecompressor::ProcessDecompressedData(const byte *inString, size_t length) -{ - AttachedTransformation()->Put(inString, length); - m_adler32.Update(inString, length); -} - -void ZlibDecompressor::ProcessPoststreamTail() -{ - FixedSizeSecBlock<byte, 4> adler32; - if (m_inQueue.Get(adler32, 4) != 4) - throw Adler32Err(); - if (!m_adler32.Verify(adler32)) - throw Adler32Err(); -} - -NAMESPACE_END |