From 15bca8f20c0ccb69ee4aa18977477a42c33d0a07 Mon Sep 17 00:00:00 2001 From: lloyd Date: Tue, 15 Jun 2010 02:47:32 +0000 Subject: Use X509::BER_encode in the Python wrappers --- src/wrap/python/rsa.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/wrap') diff --git a/src/wrap/python/rsa.cpp b/src/wrap/python/rsa.cpp index 8b9fa80ea..2aa30efd7 100644 --- a/src/wrap/python/rsa.cpp +++ b/src/wrap/python/rsa.cpp @@ -38,11 +38,10 @@ class Py_RSA_PrivateKey std::string to_ber() const { - Pipe out; - out.start_msg(); - PKCS8::encode(*rsa_key, out, RAW_BER); - out.end_msg(); - return out.read_all_as_string(); + SecureVector bits = PKCS8::BER_encode(*rsa_key); + + return std;:string(reinterpret_cast(&bits[0]), + bits.size()); } std::string get_N() const { return bigint2str(get_bigint_N()); } @@ -124,11 +123,10 @@ class Py_RSA_PublicKey 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(); + SecureVector bits = X509::BER_encode(*rsa_key); + + return std;:string(reinterpret_cast(&bits[0]), + bits.size()); } std::string encrypt(const std::string& in, -- cgit v1.2.3