summaryrefslogtreecommitdiff
path: root/src/channel.h
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-08-19 09:42:34 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2023-08-19 09:42:34 +0200
commit4153da3c16d184a1e6ffa15d2c504c6e3f6b0e1f (patch)
treeed8578a0c4d2dadc28da8480d379607675dfcc23 /src/channel.h
parent86b465cfccef5552aa111941fb74ec622e2e7c03 (diff)
Network: move secure channel to protocol module
Diffstat (limited to 'src/channel.h')
-rw-r--r--src/channel.h73
1 files changed, 0 insertions, 73 deletions
diff --git a/src/channel.h b/src/channel.h
deleted file mode 100644
index 5f1786e..0000000
--- a/src/channel.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#pragma once
-
-#include <erebos/storage.h>
-
-#include "identity.h"
-
-#include <atomic>
-#include <memory>
-
-namespace erebos {
-
-using std::array;
-using std::atomic;
-using std::unique_ptr;
-
-struct ChannelRequestData
-{
- Ref store(const Storage & st) const;
- static ChannelRequestData load(const Ref &);
-
- const vector<Stored<Signed<IdentityData>>> peers;
- const Stored<PublicKexKey> key;
-};
-
-typedef Signed<ChannelRequestData> ChannelRequest;
-
-struct ChannelAcceptData
-{
- Ref store(const Storage & st) const;
- static ChannelAcceptData load(const Ref &);
-
- unique_ptr<class Channel> channel() const;
-
- const Stored<ChannelRequest> request;
- const Stored<PublicKexKey> key;
-};
-
-typedef Signed<ChannelAcceptData> ChannelAccept;
-
-class Channel
-{
-public:
- Channel(const vector<Stored<Signed<IdentityData>>> & peers,
- vector<uint8_t> && key, bool ourRequest):
- peers(peers),
- key(std::move(key)),
- nonceFixedOur({ uint8_t(ourRequest ? 1 : 2), 0, 0, 0, 0, 0 }),
- nonceFixedPeer({ uint8_t(ourRequest ? 2 : 1), 0, 0, 0, 0, 0 })
- {}
-
- Channel(const Channel &) = delete;
- Channel(Channel &&) = delete;
- Channel & operator=(const Channel &) = delete;
- Channel & operator=(Channel &&) = delete;
-
- static Stored<ChannelRequest> generateRequest(const Storage &,
- const Identity & self, const Identity & peer);
- static optional<Stored<ChannelAccept>> acceptRequest(const Identity & self,
- const Identity & peer, const Stored<ChannelRequest> & request);
-
- vector<uint8_t> encrypt(const vector<uint8_t> &);
- optional<vector<uint8_t>> decrypt(const vector<uint8_t> &);
-
-private:
- const vector<Stored<Signed<IdentityData>>> peers;
- const vector<uint8_t> key;
-
- const array<uint8_t, 6> nonceFixedOur;
- const array<uint8_t, 6> nonceFixedPeer;
- atomic<uint64_t> nonceCounter = 0;
-};
-
-}