summaryrefslogtreecommitdiffstats
path: root/cryptopp562/winpipes.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/winpipes.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/winpipes.h142
1 files changed, 0 insertions, 142 deletions
diff --git a/cryptopp562/winpipes.h b/cryptopp562/winpipes.h
deleted file mode 100644
index ade93bb..0000000
--- a/cryptopp562/winpipes.h
+++ /dev/null
@@ -1,142 +0,0 @@
-#ifndef CRYPTOPP_WINPIPES_H
-#define CRYPTOPP_WINPIPES_H
-
-#include "config.h"
-
-#ifdef WINDOWS_PIPES_AVAILABLE
-
-#include "network.h"
-#include "queue.h"
-#include <winsock2.h>
-
-NAMESPACE_BEGIN(CryptoPP)
-
-//! Windows Handle
-class WindowsHandle
-{
-public:
- WindowsHandle(HANDLE h = INVALID_HANDLE_VALUE, bool own=false);
- WindowsHandle(const WindowsHandle &h) : m_h(h.m_h), m_own(false) {}
- virtual ~WindowsHandle();
-
- bool GetOwnership() const {return m_own;}
- void SetOwnership(bool own) {m_own = own;}
-
- operator HANDLE() {return m_h;}
- HANDLE GetHandle() const {return m_h;}
- bool HandleValid() const;
- void AttachHandle(HANDLE h, bool own=false);
- HANDLE DetachHandle();
- void CloseHandle();
-
-protected:
- virtual void HandleChanged() {}
-
- HANDLE m_h;
- bool m_own;
-};
-
-//! Windows Pipe
-class WindowsPipe
-{
-public:
- class Err : public OS_Error
- {
- public:
- Err(HANDLE h, const std::string& operation, int error);
- HANDLE GetHandle() const {return m_h;}
-
- private:
- HANDLE m_h;
- };
-
-protected:
- virtual HANDLE GetHandle() const =0;
- virtual void HandleError(const char *operation) const;
- void CheckAndHandleError(const char *operation, BOOL result) const
- {assert(result==TRUE || result==FALSE); if (!result) HandleError(operation);}
-};
-
-//! pipe-based implementation of NetworkReceiver
-class WindowsPipeReceiver : public WindowsPipe, public NetworkReceiver
-{
-public:
- WindowsPipeReceiver();
-
- bool MustWaitForResult() {return true;}
- bool Receive(byte* buf, size_t bufLen);
- unsigned int GetReceiveResult();
- bool EofReceived() const {return m_eofReceived;}
-
- unsigned int GetMaxWaitObjectCount() const {return 1;}
- void GetWaitObjects(WaitObjectContainer &container, CallStack const& callStack);
-
-private:
- WindowsHandle m_event;
- OVERLAPPED m_overlapped;
- bool m_resultPending;
- DWORD m_lastResult;
- bool m_eofReceived;
-};
-
-//! pipe-based implementation of NetworkSender
-class WindowsPipeSender : public WindowsPipe, public NetworkSender
-{
-public:
- WindowsPipeSender();
-
- bool MustWaitForResult() {return true;}
- void Send(const byte* buf, size_t bufLen);
- unsigned int GetSendResult();
- bool MustWaitForEof() { return false; }
- void SendEof() {}
-
- unsigned int GetMaxWaitObjectCount() const {return 1;}
- void GetWaitObjects(WaitObjectContainer &container, CallStack const& callStack);
-
-private:
- WindowsHandle m_event;
- OVERLAPPED m_overlapped;
- bool m_resultPending;
- DWORD m_lastResult;
-};
-
-//! Windows Pipe Source
-class WindowsPipeSource : public WindowsHandle, public NetworkSource, public WindowsPipeReceiver
-{
-public:
- WindowsPipeSource(HANDLE h=INVALID_HANDLE_VALUE, bool pumpAll=false, BufferedTransformation *attachment=NULL)
- : WindowsHandle(h), NetworkSource(attachment)
- {
- if (pumpAll)
- PumpAll();
- }
-
- using NetworkSource::GetMaxWaitObjectCount;
- using NetworkSource::GetWaitObjects;
-
-private:
- HANDLE GetHandle() const {return WindowsHandle::GetHandle();}
- NetworkReceiver & AccessReceiver() {return *this;}
-};
-
-//! Windows Pipe Sink
-class WindowsPipeSink : public WindowsHandle, public NetworkSink, public WindowsPipeSender
-{
-public:
- WindowsPipeSink(HANDLE h=INVALID_HANDLE_VALUE, unsigned int maxBufferSize=0, unsigned int autoFlushBound=16*1024)
- : WindowsHandle(h), NetworkSink(maxBufferSize, autoFlushBound) {}
-
- using NetworkSink::GetMaxWaitObjectCount;
- using NetworkSink::GetWaitObjects;
-
-private:
- HANDLE GetHandle() const {return WindowsHandle::GetHandle();}
- NetworkSender & AccessSender() {return *this;}
-};
-
-NAMESPACE_END
-
-#endif
-
-#endif