aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-02 14:19:05 +0000
committerlloyd <[email protected]>2010-03-02 14:19:05 +0000
commit11c8570f6486caf871767265f687f0d4fe17d7e0 (patch)
treeab4424ee2043e73ea7bb81b360d969e38c11e33a
parent23a0b9af002a0126ff1fdfc54e16045c84b2f43d (diff)
Fix python_pbkdf2 for new signature.
Add python KDF2 call, patch from Thomas Capricelli
-rw-r--r--src/wrap/python/core.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/wrap/python/core.cpp b/src/wrap/python/core.cpp
index fe26e16ee..b1be3b71f 100644
--- a/src/wrap/python/core.cpp
+++ b/src/wrap/python/core.cpp
@@ -166,10 +166,25 @@ std::string python_pbkdf2(const std::string& passphrase,
{
PKCS5_PBKDF2 pbkdf2(new HMAC(get_hash(hash_fn)));
- pbkdf2.set_iterations(iterations);
- pbkdf2.change_salt(reinterpret_cast<const byte*>(salt.data()), salt.size());
+ return make_string(
+ pbkdf2.derive_key(output_size,
+ passphrase,
+ reinterpret_cast<const byte*>(salt.data()),
+ salt.size(),
+ iterations).bits_of());
+ }
+
+std::string python_kdf2(const std::string& param,
+ const std::string& masterkey,
+ u32bit outputlength)
+ {
+ std::auto_ptr<KDF> kdf(get_kdf("KDF2(SHA-1)"));
- return make_string(pbkdf2.derive_key(output_size, passphrase).bits_of());
+ return make_string(
+ kdf->derive_key(outputlength,
+ reinterpret_cast<const byte*>(masterkey.data()),
+ masterkey.length(),
+ param));
}
BOOST_PYTHON_MODULE(_botan)
@@ -209,6 +224,7 @@ BOOST_PYTHON_MODULE(_botan)
python::def("cryptobox_encrypt", cryptobox_encrypt);
python::def("cryptobox_decrypt", cryptobox_decrypt);
python::def("pbkdf2", python_pbkdf2);
+ python::def("derive_key", python_kdf2);
export_filters();
export_rsa();