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


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: undefined symbol:

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::CBC_Mode_ExternalCipher::Decryption cbcDecryption(
    aesDecryption, (byte*)iv.c_str() );

    CryptoPP::StringSource( cipher_text, true, new
    CryptoPP::StreamTransformationFilter( cbcDecryption, new

    return plain_text;

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

    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, kalb at, bjorn.karlsson at, gregod at, wekempf at