1

I have successfully written a simple program in Python to encrypt files. That program depends on pycrypt 2.6 package, and this package has *.pyd Python libs.

It works fine in standard Python 3.3 VM. Nice, I thought, when finished to write the program! :)

But after that I tried to run my program on production environment, that uses a specific embedded Python 3.3 VM... And it doesn't load *.pyd files, so I am stuck with running my pycrypto-based program in that Python VM.

Are there any Python crypto libraries with RSA and AES, that wrote in pure Python and doesn't use *.pyd files?

Thank you very much!

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Arthur
  • 3,253
  • 7
  • 43
  • 75
  • the [`cryptography`](https://pypi.python.org/pypi/cryptography) package is written in pure python. Well by default it uses CFFI linked to openssl which I think you can probably shim away. – cowbert Sep 29 '17 at 21:42
  • Hmm... I tried to install it `pip install cryptography` and I got a lot of build errors like `distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 10.0 is required. Get it with "Microsoft Windows SDK 7.1": www.microsoft.com/download/details.aspx?id=8279` . – Arthur Sep 29 '17 at 21:50
  • In the past I found pre-build version of pycrypto here - http://www.voidspace.org.uk/python/modules.shtml#pycrypto . Where can I find pre-built `cryptography` library for Win 64 and Python 3.3? – Arthur Sep 29 '17 at 21:52
  • it looks like via pip `cryptography` is only available for python3 >= 3.3. But I also googled "pure python cryptography" and it returned a bunch of results. – cowbert Sep 29 '17 at 21:58
  • I've installed `cryptography` on my linux server and I see, that it uses some libs in the `/usr/local/lib/python3.5/dist-packages/cryptography/hazmat/bindings`, like *_constant_time.abi3.so and *_padding.abi3.so . I think, it will not work without that libs? – Arthur Sep 29 '17 at 22:01
  • 1
    [`oscrypto`](https://pypi.python.org/pypi/oscrypto) claims to be compiler-less (by attempting to detect the os crypto library and call it). – cowbert Sep 29 '17 at 22:02
  • Meh, not so compiler-less... A simple program `from oscrypto._openssl.asymmetric import generate_pair from oscrypto.asymmetric import dump_private_key (PublicKey, PrivateKey)=generate_pair('rsa') privKey=dump_private_key(PrivateKey, None, encoding="der") print(privKey)` rises error `File "d:\Python33\lib\site-packages\oscrypto\_openssl\_libcrypto_ctypes.py", line 25, in raise LibraryNotFoundError('The library libcrypto could not be found') oscrypto.errors.LibraryNotFoundError: The library libcrypto could not be found` – Arthur Sep 29 '17 at 22:21
  • Pure python AES library: https://github.com/serprex/aespython , from the answer to: [What (pure) Python library to use for AES 256 encryption?](https://stackoverflow.com/questions/172486/what-pure-python-library-to-use-for-aes-256-encryption) – cowbert Sep 29 '17 at 22:22

1 Answers1

1

There are many pure-python implementations of both algorithms. But they are more slower (x100) then cffi implementation. Anyway, you can easily google them.

For example, here are top rated (starred) pure-python packages: AES and RSA

Andrii
  • 822
  • 10
  • 24