aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/pbkdf/pbkdf.cpp
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-05-27 07:43:02 -0400
committerJack Lloyd <[email protected]>2017-05-27 07:43:02 -0400
commit360769bc65057ac44013f93a25ff9a06d971acae (patch)
tree691dfd44c0462093280a8df45081b0b990eb3803 /src/lib/pbkdf/pbkdf.cpp
parenta293c21ba83fb9c4d59237f8fa0fd5d852c27992 (diff)
Add (back) OpenPGP-S2K
It was removed somewhere along the line in 1.11, with the logic that it is a funky PGP-specific scheme and (quoting the commit that removed it) "not really useful outside of a full PGP implementation". This assumed that the PGP implementation would be in Botan itself, but PGP is implemented in https://github.com/evpo/EncryptPad/ (which is a PGP implementation using 1.10), and RNP (https://github.com/riboseinc/rnp) would like to use it also. This work was sponsored by Ribose Inc (@riboseinc).
Diffstat (limited to 'src/lib/pbkdf/pbkdf.cpp')
-rw-r--r--src/lib/pbkdf/pbkdf.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib/pbkdf/pbkdf.cpp b/src/lib/pbkdf/pbkdf.cpp
index a60c93d5c..40610998b 100644
--- a/src/lib/pbkdf/pbkdf.cpp
+++ b/src/lib/pbkdf/pbkdf.cpp
@@ -16,6 +16,10 @@
#include <botan/pbkdf2.h>
#endif
+#if defined(BOTAN_HAS_PGP_S2K)
+#include <botan/pgp_s2k.h>
+#endif
+
namespace Botan {
std::unique_ptr<PBKDF> PBKDF::create(const std::string& algo_spec,
@@ -50,6 +54,14 @@ std::unique_ptr<PBKDF> PBKDF::create(const std::string& algo_spec,
}
#endif
+#if defined(BOTAN_HAS_PGP_S2K)
+ if(req.algo_name() == "OpenPGP-S2K" && req.arg_count() == 1)
+ {
+ if(auto hash = HashFunction::create(req.arg(0)))
+ return std::unique_ptr<PBKDF>(new OpenPGP_S2K(hash.release()));
+ }
+#endif
+
BOTAN_UNUSED(req);
BOTAN_UNUSED(provider);