INSTALL.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. Installation
  2. ------------
  3. The installation procedure depends on the package you want the library in.
  4. PyCryptodome can be used as:
  5. #. **a drop-in replacement for the old PyCrypto library**.
  6. You install it with::
  7. pip install pycryptodome
  8. In this case, all modules are installed under the ``Crypto`` package.
  9. You can test everything is right with::
  10. python -m Crypto.SelfTest
  11. One must avoid having both PyCrypto and PyCryptodome installed
  12. at the same time, as they will interfere with each other.
  13. This option is therefore recommended only when you are sure that
  14. the whole application is deployed in a ``virtualenv``.
  15. #. **a library independent of the old PyCrypto**.
  16. You install it with::
  17. pip install pycryptodomex
  18. You can test everything is right with::
  19. python -m Cryptodome.SelfTest
  20. In this case, all modules are installed under the ``Cryptodome`` package.
  21. PyCrypto and PyCryptodome can coexist.
  22. The procedures below go a bit more in detail, by explaining
  23. how to setup the environment for compiling the C extensions
  24. for each OS, and how to install the GMP library.
  25. All instructions to follow install PyCryptodome as the ``Cryptodome`` package
  26. (option #2). Change ``pycryptodomex`` to ``pycryptodome`` if you prefer
  27. option #1 (``Crypto`` package).
  28. Linux Ubuntu
  29. ~~~~~~~~~~~~
  30. For Python 2.x::
  31. $ sudo apt-get install build-essential libgmp3-dev python-dev
  32. $ pip install pycryptodomex
  33. $ python -m Cryptodome.SelfTest
  34. For Python 3.x::
  35. $ sudo apt-get install build-essential libgmp3-dev python3-dev
  36. $ pip install pycryptodomex
  37. $ python3 -m Cryptodome.SelfTest
  38. For PyPy::
  39. $ sudo apt-get install build-essential libgmp3-dev pypy-dev
  40. $ pip install pycryptodomex
  41. $ pypy -m Cryptodome.SelfTest
  42. Linux Fedora
  43. ~~~~~~~~~~~~
  44. For Python 2.x::
  45. $ sudo yum install gcc gmp python-devel
  46. $ pip install pycryptodomex
  47. $ python -m Cryptodome.SelfTest
  48. For Python 3.x::
  49. $ sudo yum install gcc gmp python3-devel
  50. $ pip install pycryptodomex
  51. $ python3 -m Cryptodome.SelfTest
  52. For PyPy::
  53. $ sudo yum install gcc gmp pypy-devel
  54. $ pip install pycryptodomex
  55. $ pypy -m Cryptodome.SelfTest
  56. Windows (pre-compiled)
  57. ~~~~~~~~~~~~~~~~~~~~~~
  58. #. Install PyCryptodome as a `wheel <http://pythonwheels.com/>`_::
  59. > pip install pycryptodomex
  60. #. To make sure everything works fine, run the test suite::
  61. > python -m Cryptodome.SelfTest
  62. Windows (from sources, Python 2.x, Python <=3.2)
  63. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  64. Windows does not come with a C compiler like most Unix systems.
  65. The simplest way to compile the *Pycryptodome* extensions from
  66. source code is to install the minimum set of Visual Studio
  67. components freely made available by Microsoft.
  68. #. Run Python from the command line and note down its version
  69. and whether it is a 32 bit or a 64 bit application.
  70. For instance, if you see::
  71. Python 2.7.2+ ... [MSC v.1500 32 bit (Intel)] on win32
  72. you clearly have Python 2.7 and it is a 32 bit application.
  73. #. **[Only once]** In order to speed up asymmetric key algorithms like RSA,
  74. it is recommended to install the MPIR_ library (a fork of the popular
  75. GMP_ library, more suitable for the Windows environment).
  76. For convenience, I made available pre-compiled *mpir.dll* files to match
  77. the various types of Python one may have:
  78. - Python 2.x, 3.1, 3.2 (VS2008 runtime)
  79. - `32 bits <https://github.com/Legrandin/mpir-windows-builds/blob/master/mpir-2.6.0_VS2008_32/mpir.dll>`_
  80. - `64 bits <https://github.com/Legrandin/mpir-windows-builds/blob/master/mpir-2.6.0_VS2008_64/mpir.dll>`_
  81. - Python 3.3 and 3.4 (VS2010 runtime)
  82. - `32 bits <https://github.com/Legrandin/mpir-windows-builds/blob/master/mpir-2.6.0_VS2010_32/mpir.dll>`_
  83. - `64 bits <https://github.com/Legrandin/mpir-windows-builds/blob/master/mpir-2.6.0_VS2010_64/mpir.dll>`_
  84. - Python 3.5 (VS2015 runtime)
  85. - `32 bits <https://github.com/Legrandin/mpir-windows-builds/blob/master/mpir-2.6.0_VS2015_32/mpir.dll>`_
  86. - `64 bits <https://github.com/Legrandin/mpir-windows-builds/blob/master/mpir-2.6.0_VS2015_64/mpir.dll>`_
  87. Download the correct *mpir.dll* and drop it into the Python interpreter
  88. directory (for instance ``C:\Python34``). *Pycryptodome* will
  89. automatically make use of it.
  90. #. **[Only once]** Install `Virtual Clone Drive`_.
  91. #. **[Only once]** Download the ISO image of the `MS SDK for Windows 7 and . NET Framework 3.5 SP1`_.
  92. It contains the Visual C++ 2008 compiler.
  93. There are three ISO images available: you will need ``GRMSDK_EN_DVD.iso`` if your
  94. Windows OS is 32 bits or ``GRMSDKX_EN_DVD.iso`` if 64 bits.
  95. Mount the ISO with *Virtual Clone Drive* and install the C/C++ compilers and the
  96. redistributable only.
  97. #. If your Python is a 64 bit application, open a command prompt and perform the following steps::
  98. > cd "C:\Program Files\Microsoft SDKs\Windows\v7.0"
  99. > cmd /V:ON /K Bin\SetEnv.Cmd /x64 /release
  100. > set DISTUTILS_USE_SDK=1
  101. Replace ``/x64`` with ``/x86`` if your Python is a 32 bit application.
  102. #. Compile and install PyCryptodome::
  103. > pip install pycryptodomex --no-use-wheel
  104. #. To make sure everything work fine, run the test suite::
  105. > python -m Cryptodome.SelfTest
  106. Windows (from sources, Python 3.3 and 3.4)
  107. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  108. Windows does not come with a C compiler like most Unix systems.
  109. The simplest way to compile the *Pycryptodome* extensions from
  110. source code is to install the minimum set of Visual Studio
  111. components freely made available by Microsoft.
  112. #. Run Python from the command line and note down its version
  113. and whether it is a 32 bit or a 64 bit application.
  114. For instance, if you see::
  115. Python 2.7.2+ ... [MSC v.1500 32 bit (Intel)] on win32
  116. you clearly have Python 2.7 and it is a 32 bit application.
  117. #. **[Only once]** In order to speed up asymmetric key algorithms like RSA,
  118. it is recommended to install the MPIR_ library (a fork of the popular
  119. GMP_ library, more suitable for the Windows environment).
  120. For convenience, I made available pre-compiled *mpir.dll* files to match
  121. the various types of Python one may have:
  122. - Python 2.x, 3.1, 3.2 (VS2008 runtime)
  123. - `32 bits <https://github.com/Legrandin/mpir-windows-builds/blob/master/mpir-2.6.0_VS2008_32/mpir.dll>`_
  124. - `64 bits <https://github.com/Legrandin/mpir-windows-builds/blob/master/mpir-2.6.0_VS2008_64/mpir.dll>`_
  125. - Python 3.3 and 3.4 (VS2010 runtime)
  126. - `32 bits <https://github.com/Legrandin/mpir-windows-builds/blob/master/mpir-2.6.0_VS2010_32/mpir.dll>`_
  127. - `64 bits <https://github.com/Legrandin/mpir-windows-builds/blob/master/mpir-2.6.0_VS2010_64/mpir.dll>`_
  128. - Python 3.5 (VS2015 runtime)
  129. - `32 bits <https://github.com/Legrandin/mpir-windows-builds/blob/master/mpir-2.6.0_VS2015_32/mpir.dll>`_
  130. - `64 bits <https://github.com/Legrandin/mpir-windows-builds/blob/master/mpir-2.6.0_VS2015_64/mpir.dll>`_
  131. Download the correct *mpir.dll* and drop it into the Python interpreter
  132. directory (for instance ``C:\Python34``). *Pycryptodome* will
  133. automatically make use of it.
  134. #. **[Only once]** Install `Virtual Clone Drive`_.
  135. #. **[Only once]** Download the ISO image of the `MS SDK for Windows 7 and . NET Framework 4`_.
  136. It contains the Visual C++ 2010 compiler.
  137. There are three ISO images available: you will need ``GRMSDK_EN_DVD.iso`` if your
  138. Windows OS is 32 bits or ``GRMSDKX_EN_DVD.iso`` if 64 bits.
  139. Mount the ISO with *Virtual Clone Drive* and install the C/C++ compilers and the
  140. redistributable only.
  141. #. If your Python is a 64 bit application, open a command prompt and perform the following steps::
  142. > cd "C:\Program Files\Microsoft SDKs\Windows\v7.1"
  143. > cmd /V:ON /K Bin\SetEnv.Cmd /x64 /release
  144. > set DISTUTILS_USE_SDK=1
  145. Replace ``/x64`` with ``/x86`` if your Python is a 32 bit application.
  146. #. Compile and install PyCryptodome::
  147. > pip install pycryptodomex --no-use-wheel
  148. #. To make sure everything work fine, run the test suite::
  149. > python -m Cryptodome.SelfTest
  150. Windows (from sources, Python 3.5 and newer)
  151. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  152. Windows does not come with a C compiler like most Unix systems.
  153. The simplest way to compile the *Pycryptodome* extensions from
  154. source code is to install the minimum set of Visual Studio
  155. components freely made available by Microsoft.
  156. #. **[Once only]** Download `MS Visual Studio 2015`_ (Community Edition) and install the C/C++
  157. compilers and the redistributable only.
  158. #. Perform all steps from the section *Windows (pre-compiled)* but add the ``--no-use-wheel``
  159. parameter when calling ``pip``::
  160. > pip install pycryptodomex --no-use-wheel
  161. Documentation
  162. ~~~~~~~~~~~~~
  163. Project documentation is written in reStructuredText and it is stored under ``Doc/src``.
  164. To publish it as HTML files, you need to install `sphinx <http://www.sphinx-doc.org/en/stable/>` and
  165. use::
  166. > make -C Doc/ html
  167. It will then be available under ``Doc/_build/html/``.
  168. PGP verification
  169. ~~~~~~~~~~~~~~~~
  170. All source packages and wheels on PyPI are cryptographically signed.
  171. They can be verified with the following PGP key::
  172. -----BEGIN PGP PUBLIC KEY BLOCK-----
  173. mQINBFTXjPgBEADc3j7vnma9MXRshBPPXXenVpthQD6lrF/3XaBT2RptSf/viOD+
  174. tz85du5XVp+r0SYYGeMNJCQ9NsztxblN/lnKgkfWRmSrB+V6QGS+e3bR5d9OIxzN
  175. 7haPxBnyRj//hCT/kKis6fa7N9wtwKBBjbaSX+9vpt7Rrt203sKfcChA4iR3EG89
  176. TNQoc/kGGmwk/gyjfU38726v0NOhMKJp2154iQQVZ76hTDk6GkOYHTcPxdkAj4jS
  177. Dd74M9sOtoOlyDLHOLcWNnlWGgZjtz0z0qSyFXRSuOfggTxrepWQgKWXXzgVB4Jo
  178. 0bhmXPAV8vkX5BoG6zGkYb47NGGvknax6jCvFYTCp1sOmVtf5UTVKPplFm077tQg
  179. 0KZNAvEQrdWRIiQ1cCGCoF2Alex3VmVdefHOhNmyY7xAlzpP0c8z1DsgZgMnytNn
  180. GPusWeqQVijRxenl+lyhbkb9ZLDq7mOkCRXSze9J2+5aLTJbJu3+Wx6BEyNIHP/f
  181. K3E77nXvC0oKaYTbTwEQSBAggAXP+7oQaA0ea2SLO176xJdNfC5lkQEtMMSZI4gN
  182. iSqjUxXW2N5qEHHex1atmTtk4W9tQEw030a0UCxzDJMhD0aWFKq7wOxoCQ1q821R
  183. vxBH4cfGWdL/1FUcuCMSUlc6fhTM9pvMXgjdEXcoiLSTdaHuVLuqmF/E0wARAQAB
  184. tB9MZWdyYW5kaW4gPGhlbGRlcmlqc0BnbWFpbC5jb20+iQI4BBMBAgAiBQJU14z4
  185. AhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRDabO+N4RaZEn7IEACpApha
  186. vRwPB+Dv87aEyVmjZ96Nb3mxHdeP2uSmUxAODzoB5oJJ1QL6HRxEVlU8idjdf73H
  187. DX39ZC7izD+oYIve9sNwTbKqJCZaTxlTDdgSF1N57eJOlELAy+SqpHtaMJPk7SfJ
  188. l/iYoUYxByPLZU1wDwZEDNzt9RCGy3bd/vF/AxWjdUJJPh3E4j5hswvIGSf8/Tp3
  189. MDROU1BaNBOd0CLvBHok8/xavwO6Dk/fE4hJhd5uZcEPtd1GJcPq51z2yr7PGUcb
  190. oERsKZyG8cgfd7j8qoTd6jMIW6fBVHdxiMxW6/Z45X/vVciQSzzEl/yjPUW42kyr
  191. Ib6M16YmnDzp8bl4NNFvvR9uWvOdUkep2Bi8s8kBMJ7G9rHHJcdVy/tP1ECS9Bse
  192. hN4v5oJJ4v5mM/MiWRGKykZULWklonpiq6Cew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ZEo7lD/45J6z2wbL8aIudGEL0aY3hfmW3qrUyoHgaw35KsOY9vZwb
  209. cZuJe0RlYptOreH/NrbR5SXODfhd2sxYyyvXBOuZh9i7OOBsrAd5UE01GCvToPwh
  210. 7IpMV3GSSAB4P8XyJh20tZqiZOYKhmbf29gUDzqAI6GzUa0U8xidUKpW2zqYGZjp
  211. wk3RI1fS7tyi/0N8B9tIZF48kbvpFDAjF8w7NSCrgRquAL7zJZIG5o5zXJM/ffF3
  212. 67Dnz278MbifdM/HJ+Tj0R0Uvvki9Z61nT653SoUgvILQyC72XI+x0+3GQwsE38a
  213. 5aJNZ1NBD3/v+gERQxRfhM5iLFLXK0Xe4K2XFM1g0yN4L4bQPbhSCq88g9Dhmygk
  214. XPbBsrK0NKPVnyGyUXM0VpgRbot11hxx02jC3HxS1nlLF+oQdkKFzJAMOU7UbpX/
  215. oO+286J1FmpG+fihIbvp1Quq48immtnzTeLZbYCsG4mrM+ySYd0Er0G8TBdAOTiN
  216. 3zMbGX0QOO2fOsJ1d980cVjHn5CbAo8C0A/4/R2cXAfpacbvTiNq5BVk9NKa2dNb
  217. kmnTStP2qILWmm5ASXlWhOjWNmptvsUcK+8T+uQboLioEv19Ob4j5Irs/OpOuP0K
  218. v4woCi9+03HMS42qGSe/igClFO3+gUMZg9PJnTJhuaTbytXhUBgBRUPsS+lQAQ==
  219. =DpoI
  220. -----END PGP PUBLIC KEY BLOCK-----
  221. .. _pypi: https://pypi.python.org/pypi/pycryptodome
  222. .. _get-pip.py: https://bootstrap.pypa.io/get-pip.py
  223. .. _MS Windows SDK for Windows 7 and .NET Framework 3.5 SP1: http://www.microsoft.com/en-us/download/details.aspx?id=18950
  224. .. _MS Windows SDK for Windows 7 and .NET Framework 4: https://www.microsoft.com/en-us/download/details.aspx?id=8442
  225. .. _Virtual Clone Drive: http://www.slysoft.com/it/virtual-clonedrive.html
  226. .. _MPIR: http://mpir.org
  227. .. _GMP: http://gmplib.org
  228. .. _MS Visual Studio 2015: https://www.visualstudio.com/en-us/downloads/download-visual-studio-vs.aspx