From ccfcb3af8b8404f998aba895ddfc7f3d4405fdd5 Mon Sep 17 00:00:00 2001 From: lloyd Date: Sat, 14 Mar 2015 04:31:24 +0000 Subject: In PK encrypt/decrypt move pad calls to the operation. This allows an op to use a padding scheme outside of our knowledge or control, for instance an OpenSSL RSA op which uses OpenSSL's padding code. Similar change for key agreement and KDFs for the same reason. Add an EME_Raw type; previously this operation was implicit in the code in pubkey.cpp --- src/lib/pubkey/dh/dh.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/lib/pubkey/dh') diff --git a/src/lib/pubkey/dh/dh.cpp b/src/lib/pubkey/dh/dh.cpp index be411c5d8..57310efae 100644 --- a/src/lib/pubkey/dh/dh.cpp +++ b/src/lib/pubkey/dh/dh.cpp @@ -82,13 +82,13 @@ namespace { /** * DH operation */ -class DH_KA_Operation : public PK_Ops::Key_Agreement +class DH_KA_Operation : public PK_Ops::Key_Agreement_with_KDF { public: typedef DH_PrivateKey Key_Type; - DH_KA_Operation(const DH_PrivateKey& key, const std::string&); + DH_KA_Operation(const DH_PrivateKey& key, const std::string& kdf); - secure_vector agree(const byte w[], size_t w_len); + secure_vector raw_agree(const byte w[], size_t w_len); private: const BigInt& m_p; @@ -96,7 +96,8 @@ class DH_KA_Operation : public PK_Ops::Key_Agreement Blinder m_blinder; }; -DH_KA_Operation::DH_KA_Operation(const DH_PrivateKey& dh, const std::string&) : +DH_KA_Operation::DH_KA_Operation(const DH_PrivateKey& dh, const std::string& kdf) : + PK_Ops::Key_Agreement_with_KDF(kdf), m_p(dh.group_p()), m_powermod_x_p(dh.get_x(), m_p), m_blinder(m_p, @@ -105,7 +106,7 @@ DH_KA_Operation::DH_KA_Operation(const DH_PrivateKey& dh, const std::string&) : { } -secure_vector DH_KA_Operation::agree(const byte w[], size_t w_len) +secure_vector DH_KA_Operation::raw_agree(const byte w[], size_t w_len) { BigInt input = BigInt::decode(w, w_len); -- cgit v1.2.3