From ab86a1f0c3b86050e65fc5b7ac1e88a00f0d228c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Mon, 27 Jan 2020 21:25:39 +0100 Subject: Encrypted channels --- src/pubkey.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/pubkey.h') diff --git a/src/pubkey.h b/src/pubkey.h index 80da3fa..b14743d 100644 --- a/src/pubkey.h +++ b/src/pubkey.h @@ -133,4 +133,35 @@ bool Signed::isSignedBy(const Stored & key) const return false; } + +class PublicKexKey +{ + PublicKexKey(EVP_PKEY * key): + key(key, EVP_PKEY_free) {} + friend class SecretKexKey; +public: + static optional load(const Ref &); + Ref store(const Storage &) const; + + const shared_ptr key; +}; + +class SecretKexKey +{ + SecretKexKey(EVP_PKEY * key, const Stored & pub): + key(key, EVP_PKEY_free), pub_(pub) {} + SecretKexKey(shared_ptr && key, const Stored & pub): + key(key), pub_(pub) {} +public: + static SecretKexKey generate(const Storage & st); + static optional load(const Stored & st); + + Stored pub() const { return pub_; } + vector dh(const PublicKexKey &) const; + +private: + const shared_ptr key; + Stored pub_; +}; + } -- cgit v1.2.3