diff options
author | lloyd <[email protected]> | 2010-06-11 16:18:26 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-06-11 16:18:26 +0000 |
commit | b7e44b278265b81fa935e0e58a17c684402056bf (patch) | |
tree | 347afdaff32cebe2a08d072cfad19f49ffd00e00 /src/wrap | |
parent | eb6b6e21a5cfc469a80368c36bc15d39c82115f9 (diff) |
Add to_ber to the RSA objects so you can get the raw BER encoding.
Requested by Thomas Capricelli.
Diffstat (limited to 'src/wrap')
-rw-r--r-- | src/wrap/python/rsa.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/wrap/python/rsa.cpp b/src/wrap/python/rsa.cpp index 900c3f93d..d0053ca5d 100644 --- a/src/wrap/python/rsa.cpp +++ b/src/wrap/python/rsa.cpp @@ -36,6 +36,15 @@ class Py_RSA_PrivateKey return PKCS8::PEM_encode(*rsa_key); } + std::string to_ber() const + { + Pipe out; + out.start_msg(); + X509::encode(*rsa_key, out, RAW_BER); + out.end_msg(); + return out.read_all_as_string(); + } + std::string get_N() const { return bigint2str(get_bigint_N()); } std::string get_E() const { return bigint2str(get_bigint_E()); } @@ -113,6 +122,15 @@ class Py_RSA_PublicKey return X509::PEM_encode(*rsa_key); } + std::string to_ber() const + { + Pipe out; + out.start_msg(); + X509::encode(*rsa_key, out, RAW_BER); + out.end_msg(); + return out.read_all_as_string(); + } + std::string encrypt(const std::string& in, const std::string& padding, Python_RandomNumberGenerator& rng); @@ -171,6 +189,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 +199,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) |