Boost logo

Boost Users :

Subject: [Boost-users] Boost Python and Crypto++
From: Boost Users List (078d7a6a70b2586b9cf1b456657079e9f510ef50_at_[hidden])
Date: 2012-02-16 08:35:38


Hi,

I'm trying to use Crypto++ with boost::python. My code seems to build OK,
but when I try to import it into Python, I receive this error:

ImportError: nf_decrypt.so: undefined symbol:
_ZN8CryptoPP21SimpleKeyingInterface6SetKeyEPKhmRKNS_14NameValuePairsE

Here is the cpp source code file:

#include <cryptopp/aes.h>
#include <cryptopp/hex.h>
#include <cryptopp/modes.h>

std::string nf_decrypt( const std::string& estring )
{
    std::string hex_pk = "00000000000000000000000000000000";
    std::string hex_iv = "00000000000000000000000000000000";

    std::string pk;
    std::string iv;
    std::string cipher_text;
    std::string plain_text;

    CryptoPP::StringSource ( hex_pk.c_str(), true, new
    CryptoPP::HexDecoder( new CryptoPP::StringSink(pk) ) );

    CryptoPP::StringSource ( hex_iv.c_str(), true, new
    CryptoPP::HexDecoder( new CryptoPP::StringSink(iv) ) );

    CryptoPP::StringSource ( estring.c_str(), true, new
    CryptoPP::StringSink(cipher_text) );

    CryptoPP::AES::Decryption aesDecryption( (byte*)pk.c_str(),
    CryptoPP::AES::DEFAULT_KEYLENGTH );

    CryptoPP::CBC_Mode_ExternalCipher::Decryption cbcDecryption(
    aesDecryption, (byte*)iv.c_str() );

    CryptoPP::StringSource( cipher_text, true, new
    CryptoPP::StreamTransformationFilter( cbcDecryption, new
    CryptoPP::StringSink(plain_text)));

    return plain_text;
}

// python wrapper
#include <boost/python.hpp>

BOOST_PYTHON_MODULE(nf_decrypt)
{
    boost::python::def("nf_decrypt", nf_decrypt,
    boost::python::args("string_to_decrypt"), "nf_decrypt docstring");
}

Has anyone built boost python extensions from Crypto++ code? I may try
doing the same thing with Botan if Crypto++ in general is problematic. I
can send my Jamroot file if that would be helpful. Thanks for any advice.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net