aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2008-09-29 19:42:08 +0000
committerlloyd <[email protected]>2008-09-29 19:42:08 +0000
commit14c2ddcdf698000ab170e9325d4f7d774c0f2247 (patch)
tree9c9a5c94fceed5d53b92a88a3539a7972192d1ae
parentee9965d3a59112d042df7569fde6a45302491499 (diff)
Updates to Boost.Python wrapper for 1.7.14. RSA disabled, needs RNG
-rw-r--r--misc/python/src/block.cpp9
-rw-r--r--misc/python/src/core.cpp2
-rw-r--r--misc/python/src/filter.cpp8
-rw-r--r--misc/python/src/hash.cpp4
-rw-r--r--misc/python/src/pk.cpp8
5 files changed, 28 insertions, 3 deletions
diff --git a/misc/python/src/block.cpp b/misc/python/src/block.cpp
index d77936305..385376005 100644
--- a/misc/python/src/block.cpp
+++ b/misc/python/src/block.cpp
@@ -15,6 +15,8 @@ class Py_BlockCipher : public BlockCipher
virtual std::string dec_str(const std::string&) const = 0;
virtual void set_key_obj(const OctetString&) = 0;
+ void clear() throw() {}
+
void enc(const byte in[], byte out[]) const
{
string2binary(
@@ -63,6 +65,8 @@ std::string decrypt_string(BlockCipher* cipher, const std::string& in)
class Wrapped_Block_Cipher : public BlockCipher
{
public:
+ void clear() throw() { cipher->clear(); }
+
void enc(const byte in[], byte out[]) const { cipher->encrypt(in, out); }
void dec(const byte in[], byte out[]) const { cipher->decrypt(in, out); }
void key(const byte key[], u32bit len) { cipher->set_key(key, len); }
@@ -90,6 +94,11 @@ class Py_BlockCipher_Wrapper : public Py_BlockCipher,
return new Wrapped_Block_Cipher(py_clone, bc);
}
+ void clear() throw()
+ {
+ this->get_override("clear")();
+ }
+
std::string name() const
{
return this->get_override("name")();
diff --git a/misc/python/src/core.cpp b/misc/python/src/core.cpp
index 316356adf..3bca5330f 100644
--- a/misc/python/src/core.cpp
+++ b/misc/python/src/core.cpp
@@ -24,7 +24,7 @@ BOOST_PYTHON_MODULE(_botan)
python::class_<OctetString>("OctetString")
.def(python::init< python::optional<std::string> >())
- .def(python::init< u32bit >())
+ //.def(python::init< u32bit >())
.def("__str__", &OctetString::as_string)
.def("__len__", &OctetString::length);
diff --git a/misc/python/src/filter.cpp b/misc/python/src/filter.cpp
index b0cd77197..262622eef 100644
--- a/misc/python/src/filter.cpp
+++ b/misc/python/src/filter.cpp
@@ -92,7 +92,9 @@ Filter* make_filter3(const std::string& name,
const SymmetricKey& key,
Cipher_Dir direction)
{
- return return_or_raise(get_cipher(name, key, direction), name);
+ return return_or_raise(
+ get_cipher(global_state(), name, key, direction),
+ name);
}
Filter* make_filter4(const std::string& name,
@@ -100,7 +102,9 @@ Filter* make_filter4(const std::string& name,
const InitializationVector& iv,
Cipher_Dir direction)
{
- return return_or_raise(get_cipher(name, key, iv, direction), name);
+ return return_or_raise(
+ get_cipher(global_state(), name, key, iv, direction),
+ name);
}
void append_filter(Pipe& pipe, std::auto_ptr<Filter> filter)
diff --git a/misc/python/src/hash.cpp b/misc/python/src/hash.cpp
index 082d992b2..69c107c32 100644
--- a/misc/python/src/hash.cpp
+++ b/misc/python/src/hash.cpp
@@ -14,6 +14,8 @@ class Py_HashFunction : public HashFunction
virtual void hash_str(const std::string&) = 0;
virtual std::string final_str() = 0;
+ void clear() throw() {}
+
void add_data(const byte input[], u32bit length)
{
hash_str(make_string(input, length));
@@ -34,6 +36,8 @@ class Wrapped_HashFunction : public HashFunction
void add_data(const byte in[], u32bit len) { hash->update(in, len); }
void final_result(byte out[]) { hash->final(out); }
+ void clear() throw() {}
+
std::string name() const { return hash->name(); }
HashFunction* clone() const { return hash->clone(); }
diff --git a/misc/python/src/pk.cpp b/misc/python/src/pk.cpp
index 1a713ff9c..72d3294b8 100644
--- a/misc/python/src/pk.cpp
+++ b/misc/python/src/pk.cpp
@@ -44,6 +44,7 @@ std::string encode_priv(const Private_Key* key,
throw Encoding_Error("Unknown key encoding method " + type);
}
+/*
Private_Key* load_priv(const std::string& file, const std::string& pass)
{
return PKCS8::load_key(file, pass);
@@ -53,7 +54,9 @@ Public_Key* load_public(const std::string& file)
{
return X509::load_key(file);
}
+*/
+/*
std::string encrypt_string(const PK_Encryptor* enc, const std::string& in)
{
SecureVector<byte> cipher = enc->encrypt((const byte*)in.data(), in.length());
@@ -65,13 +68,16 @@ std::string decrypt_string(const PK_Decryptor* dec, const std::string& in)
SecureVector<byte> plain = dec->decrypt((const byte*)in.data(), in.length());
return std::string((const char*)plain.begin(), plain.size());
}
+*/
void export_pk()
{
+ /*
python::def("private_key", load_priv,
python::return_value_policy<python::manage_new_object>());
python::def("public_key", load_public,
python::return_value_policy<python::manage_new_object>());
+ */
python::class_<Public_Key, boost::noncopyable>
("Public_Key", python::no_init)
@@ -95,8 +101,10 @@ void export_pk()
python::class_<DSA_PublicKey, python::bases<Public_Key> >
("DSA_PublicKey", python::no_init);
+ /*
python::class_<RSA_PrivateKey, python::bases<RSA_PublicKey, PK_Decrypting_Key> >
("RSA_PrivateKey", python::init<u32bit>());
+ */
/*
python::class_<PK_Encryptor, boost::noncopyable>