Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here is a step-by-step I've just made up on my CentOS server (the sequence assumes you're not root):</p> <p><strong>LIBGMP INSTALL</strong></p> <p>Firstly, setup and install libgmp somewhere in your home directory, as follows:</p> <pre><code>./configure prefix=$HOME make make install prefix=$HOME </code></pre> <p>This will create a ~/lib, a ~/include and a ~/share directory if not existing already.</p> <p>Then, add the following line to your .bashrc:</p> <pre><code>export LD_LIBRARY_PATH=$HOME/lib:/usr/local/lib:$LD_LIBRARY_PATH </code></pre> <p>Do a ". ~/.bashrc" to enforce your changes.</p> <p><strong>PYCRYPTO BUILD &amp; INSTALL</strong></p> <p>We need to deal with the install process manually. Firstly, we may download pycrypto as follows:</p> <ul> <li><p>go into a directory where you store your sources:</p> <p>cd ~/src</p></li> <li><p>download pycrypto source archive:</p> <p>curl -o pycrypto.tar.gz "<a href="https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.tar.gz#md5=88dad0a270d1fe83a39e0467a66a22bb" rel="nofollow">https://pypi.python.org/packages/source/p/pycrypto/pycrypto-2.6.tar.gz#md5=88dad0a270d1fe83a39e0467a66a22bb</a>"</p></li> <li><p>uncompress + untar archive:</p> <p>gunzip pycrypto.tar.gz tar xvf pycrypto.tar</p></li> </ul> <p>Then we need to cheat the configuration "a bit":</p> <pre><code>cd pycrypto-26 ./configure --includedir=$HOME/include </code></pre> <ul> <li><p>Edit the file cd src/config.h and amend the values for the definitions:</p> <p>#define HAVE_DECL_MPZ_POWM 0 instead of 1</p> <p>#define HAVE_DECL_MPZ_POWM_SEC 1 instead of 0</p> <p>#define HAVE_LIBGMP 1 instead of 0</p></li> <li><p>Then edit the setup.py file by searching for the keyword "_fastmath" and ensure that the Extension() declaration looks as per below:</p> <pre><code>Extension("Crypto.PublicKey._fastmath", include_dirs=['/home/&lt;yourhome&gt;/include','src/','/usr/include/'], library_dirs=['/home/&lt;yourhome&gt;/lib'], libraries=['gmp'], sources=["src/_fastmath.c"]), </code></pre></li> </ul> <p>Finally, build pycrypto with:</p> <pre><code>python setup.py build </code></pre> <p>You should see somewhere in the trace the following line:</p> <pre><code>... building 'Crypto.PublicKey._fastmath' extension ... </code></pre> <p>You can then do a "python setup.py install" or, if like me you prefer pip:</p> <pre><code>cd .. pip install ./pycrypto-2.6 </code></pre> <p>Then you should get no error when executing the following lines from python:</p> <pre><code>&gt;&gt;&gt; from Crypto.PublicKey import _fastmath &gt;&gt;&gt; import Crypto.Random &gt;&gt;&gt; _fastmath.HAVE_DECL_MPZ_POWM_SEC 1 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload