[Ironpython-users] using IronPython with pycrypto
Baron Oldenburg
Baron.Oldenburg at leviathansecurity.com
Wed Oct 29 23:43:24 CET 2014
Hello!
I'm attempting to import a module (KillerBee<https://code.google.com/p/killerbee/>) in IronPython. I've encountered a couple of issues along the way, some of which I've been able to fix. I'm hoping the mailing list can help me out with what I haven't fixed. Here are the problems I've encountered and the steps I've taken:
1. "Exception during object creation: no module named killerbee"
a. Per http://stackoverflow.com/questions/1371994/importing-external-module-in-ironpython, I added the following which allowed IronPython to recognize killerbee as a module and let me import it:
var paths = engine.GetSearchPaths();
paths.Add(@"/usr/lib/python2.7/site-packages/");
engine.SetSearchPaths(paths);
2. "Exception during object creation: cannot import _AES from Crypto.Cipher"
a. I tracked this error down to this line in a killerbee file "dot154decode.py":
"from Crypto.Cipher import AES"
and then further to /usr/lib/python2.7/site-packages/Crypto/Cipher/AES.py:
"from Crypto.Cipher import _AES"
In the same directory as AES.py there is an _AES.so.
b. If I attempt this from the python interpreter, there are no errors:
$ python
Python 2.7.8 (default, Sep 24 2014, 18:26:21)
[GCC 4.9.1 20140903 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from Crypto.Cipher import AES
>>> import Crypto
>>> print Crypto.__version__
2.6.1
>>>
c. If I attempt this from IronPython with the following code (instead of importing killerbee):
engine.ImportModule("Crypto.Cipher.AES");
I get the same error ("cannot import _AES from Crypto.Cipher").
d. If I attempt to just import Crypto.Cipher ("engine.ImportModule("Crypto.Cipher");") there are no errors.
Before I start trying increasingly complicated workarounds, does anyone have an idea as to the possible root cause? I've searched around on the Internet generally and in outstanding IronPython issues specifically for other people with this problem, but I've only found the following semi-related hits around IronPython and pycrypto:
* http://stackoverflow.com/questions/2365661/how-to-create-a-package-in-c-sharp-for-use-in-ironpython
* http://www.pyinstaller.org/ticket/881
* http://lists.ironpython.com/pipermail/users-ironpython.com/2006-November/018956.html
* https://bitbucket.org/mvdk/ironpycrypto
The relevant parts of the source look like this:
using IronPython;
using IronPython.Hosting;
using Microsoft.Scripting;
using Microsoft.Scripting.Hosting;
ScriptEngine engine = Python.CreateEngine();
var paths = engine.GetSearchPaths();
paths.Add(@"/usr/lib/python2.7/site-packages/");
engine.SetSearchPaths(paths);
engine.ImportModule("Crypto.Cipher.AES");
Thanks for your time! I'm happy to provide any other details or source code necessary to continue debugging.
Baron
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20141029/2b30e67d/attachment.html>
More information about the Ironpython-users
mailing list