summaryrefslogtreecommitdiff
path: root/src/pubkey.h
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2020-01-27 21:25:39 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2020-02-05 21:02:08 +0100
commitab86a1f0c3b86050e65fc5b7ac1e88a00f0d228c (patch)
tree24f1b79bc9a90846bca31203b306eb4c60a055c1 /src/pubkey.h
parentec402bfaa90cdb52276f5ccc2525e799cb4419d7 (diff)
Encrypted channels
Diffstat (limited to 'src/pubkey.h')
-rw-r--r--src/pubkey.h31
1 files changed, 31 insertions, 0 deletions
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<T>::isSignedBy(const Stored<PublicKey> & key) const
return false;
}
+
+class PublicKexKey
+{
+ PublicKexKey(EVP_PKEY * key):
+ key(key, EVP_PKEY_free) {}
+ friend class SecretKexKey;
+public:
+ static optional<PublicKexKey> load(const Ref &);
+ Ref store(const Storage &) const;
+
+ const shared_ptr<EVP_PKEY> key;
+};
+
+class SecretKexKey
+{
+ SecretKexKey(EVP_PKEY * key, const Stored<PublicKexKey> & pub):
+ key(key, EVP_PKEY_free), pub_(pub) {}
+ SecretKexKey(shared_ptr<EVP_PKEY> && key, const Stored<PublicKexKey> & pub):
+ key(key), pub_(pub) {}
+public:
+ static SecretKexKey generate(const Storage & st);
+ static optional<SecretKexKey> load(const Stored<PublicKexKey> & st);
+
+ Stored<PublicKexKey> pub() const { return pub_; }
+ vector<uint8_t> dh(const PublicKexKey &) const;
+
+private:
+ const shared_ptr<EVP_PKEY> key;
+ Stored<PublicKexKey> pub_;
+};
+
}