aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pubkey/pk_ops_impl.h
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-12-26 21:54:09 -0500
committerJack Lloyd <[email protected]>2015-12-26 21:54:09 -0500
commit72f0f0ad2a9f869092b889779e2e9baed0fe7a85 (patch)
tree0b3a127a4ceb18df2cd35038eac3eb225f0c095e /src/lib/pubkey/pk_ops_impl.h
parent2e47770cf7ddc6e33bee586211a5ea2cdf2e8659 (diff)
Add generalized KEM interface
Convert McEliece KEM to use it Add RSA-KEM
Diffstat (limited to 'src/lib/pubkey/pk_ops_impl.h')
-rw-r--r--src/lib/pubkey/pk_ops_impl.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/lib/pubkey/pk_ops_impl.h b/src/lib/pubkey/pk_ops_impl.h
index f27de4af4..0acceb53c 100644
--- a/src/lib/pubkey/pk_ops_impl.h
+++ b/src/lib/pubkey/pk_ops_impl.h
@@ -139,6 +139,46 @@ class Key_Agreement_with_KDF : public Key_Agreement
std::unique_ptr<KDF> m_kdf;
};
+class KEM_Encryption_with_KDF : public KEM_Encryption
+ {
+ public:
+ void kem_encrypt(secure_vector<byte>& out_encapsulated_key,
+ secure_vector<byte>& out_shared_key,
+ size_t desired_shared_key_len,
+ Botan::RandomNumberGenerator& rng,
+ const uint8_t salt[],
+ size_t salt_len) override;
+
+ protected:
+ virtual void raw_kem_encrypt(secure_vector<byte>& out_encapsulated_key,
+ secure_vector<byte>& raw_shared_key,
+ Botan::RandomNumberGenerator& rng) = 0;
+
+ KEM_Encryption_with_KDF(const std::string& kdf);
+ ~KEM_Encryption_with_KDF();
+ private:
+ std::unique_ptr<KDF> m_kdf;
+ };
+
+class KEM_Decryption_with_KDF : public KEM_Decryption
+ {
+ public:
+ secure_vector<byte> kem_decrypt(const byte encap_key[],
+ size_t len,
+ size_t desired_shared_key_len,
+ const uint8_t salt[],
+ size_t salt_len);
+
+ protected:
+ virtual secure_vector<byte>
+ raw_kem_decrypt(const byte encap_key[], size_t len) = 0;
+
+ KEM_Decryption_with_KDF(const std::string& kdf);
+ ~KEM_Decryption_with_KDF();
+ private:
+ std::unique_ptr<KDF> m_kdf;
+ };
+
}
}