diff options
author | lloyd <[email protected]> | 2009-10-09 22:28:02 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-10-09 22:28:02 +0000 |
commit | 9db719642349bc37126dee4b2837d3bba022d734 (patch) | |
tree | d77b7f94dbba6b7852da7c3e075bcd548b74caaf /src/wrap/python/python_botan.h | |
parent | d970d9feb203e497f72f1e9b4dc095b1d7ca308f (diff) |
Reasonably functional RSA support; keygen, import/export, encrypt/decrypt, sign/verify
Diffstat (limited to 'src/wrap/python/python_botan.h')
-rw-r--r-- | src/wrap/python/python_botan.h | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/src/wrap/python/python_botan.h b/src/wrap/python/python_botan.h index 18c51dbb1..646c2e2c1 100644 --- a/src/wrap/python/python_botan.h +++ b/src/wrap/python/python_botan.h @@ -11,7 +11,7 @@ using namespace Botan; namespace python = boost::python; extern void export_filters(); -extern void export_pk(); +extern void export_rsa(); extern void export_x509(); class Bad_Size : public Exception @@ -48,4 +48,32 @@ inline python::object get_owner(T* me) python::borrowed(python::detail::wrapper_base_::get_owner(*me)))); } +class Python_RandomNumberGenerator + { + public: + Python_RandomNumberGenerator() + { rng = RandomNumberGenerator::make_rng(); } + ~Python_RandomNumberGenerator() { delete rng; } + + std::string name() const { return rng->name(); } + + void reseed() { rng->reseed(192); } + + int gen_random_byte() { return rng->next_byte(); } + + std::string gen_random(int n) + { + std::string s(n, 0); + rng->randomize(reinterpret_cast<byte*>(&s[0]), n); + return s; + } + + void add_entropy(const std::string& in) + { rng->add_entropy(reinterpret_cast<const byte*>(in.c_str()), in.length()); } + + RandomNumberGenerator& get_underlying_rng() { return *rng; } + private: + RandomNumberGenerator* rng; + }; + #endif |