aboutsummaryrefslogtreecommitdiffstats
path: root/src/wrap/python/rsa.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-06-17 21:48:55 +0000
committerlloyd <[email protected]>2010-06-17 21:48:55 +0000
commitc06b260b3328c5ce4be44c4f1a88feb55ee3dbc4 (patch)
tree41b05df5982b5b2e8a23b55972263d2172d6a9fd /src/wrap/python/rsa.cpp
parent0eecae9f21172c0a74ad62acaf77148c94a25be7 (diff)
parent3dde5683f69b9cb9f558bfb18087ce35fbbec78a (diff)
propagate from branch 'net.randombit.botan' (head 294e2082ce9231d6165276e2f2a4153a0116aca3)
to branch 'net.randombit.botan.c++0x' (head 0b695fad10f924601e07b009fcd781191fafcb28)
Diffstat (limited to 'src/wrap/python/rsa.cpp')
-rw-r--r--src/wrap/python/rsa.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/wrap/python/rsa.cpp b/src/wrap/python/rsa.cpp
index 41d9bd4d1..903516f11 100644
--- a/src/wrap/python/rsa.cpp
+++ b/src/wrap/python/rsa.cpp
@@ -36,6 +36,14 @@ class Py_RSA_PrivateKey
return PKCS8::PEM_encode(*rsa_key);
}
+ std::string to_ber() const
+ {
+ SecureVector<byte> bits = PKCS8::BER_encode(*rsa_key);
+
+ return std;:string(reinterpret_cast<const char*>(&bits[0]),
+ bits.size());
+ }
+
std::string get_N() const { return bigint2str(get_bigint_N()); }
std::string get_E() const { return bigint2str(get_bigint_E()); }
@@ -113,6 +121,14 @@ class Py_RSA_PublicKey
return X509::PEM_encode(*rsa_key);
}
+ std::string to_ber() const
+ {
+ SecureVector<byte> bits = X509::BER_encode(*rsa_key);
+
+ return std;:string(reinterpret_cast<const char*>(&bits[0]),
+ bits.size());
+ }
+
std::string encrypt(const std::string& in,
const std::string& padding,
Python_RandomNumberGenerator& rng);
@@ -171,6 +187,7 @@ void export_rsa()
("RSA_PublicKey", python::init<std::string>())
.def(python::init<const Py_RSA_PrivateKey&>())
.def("to_string", &Py_RSA_PublicKey::to_string)
+ .def("to_ber", &Py_RSA_PublicKey::to_ber)
.def("encrypt", &Py_RSA_PublicKey::encrypt)
.def("verify", &Py_RSA_PublicKey::verify)
.def("get_N", &Py_RSA_PublicKey::get_N)
@@ -180,6 +197,7 @@ void export_rsa()
("RSA_PrivateKey", python::init<std::string, Python_RandomNumberGenerator&, std::string>())
.def(python::init<u32bit, Python_RandomNumberGenerator&>())
.def("to_string", &Py_RSA_PrivateKey::to_string)
+ .def("to_ber", &Py_RSA_PrivateKey::to_ber)
.def("decrypt", &Py_RSA_PrivateKey::decrypt)
.def("sign", &Py_RSA_PrivateKey::sign)
.def("get_N", &Py_RSA_PrivateKey::get_N)