Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gmp and mpfr build for win32 - needed for pycrypto fastmath #373

Closed
totaam opened this issue Jul 8, 2013 · 12 comments
Closed

gmp and mpfr build for win32 - needed for pycrypto fastmath #373

totaam opened this issue Jul 8, 2013 · 12 comments

Comments

@totaam
Copy link
Collaborator

totaam commented Jul 8, 2013

Issue migrated from trac ticket # 373

component: client | priority: minor | resolution: fixed | keywords: win32

2013-07-08 11:36:06: antoine created the issue


Can be dealt with as part of #300

@totaam
Copy link
Collaborator Author

totaam commented Jul 16, 2013

2013-07-16 06:52:49: antoine changed status from new to assigned

@totaam
Copy link
Collaborator Author

totaam commented Jul 16, 2013

2013-07-16 07:26:45: antoine edited the issue description

@totaam
Copy link
Collaborator Author

totaam commented Oct 16, 2013

2013-10-16 09:41:22: totaam uploaded file session-info-showfastmath.png (1.9 KiB)

session info dialog showing availability of pycrypto's fastmath
session-info-showfastmath.png

@totaam
Copy link
Collaborator Author

totaam commented Oct 16, 2013

2013-10-16 09:41:49: totaam changed status from assigned to new

@totaam
Copy link
Collaborator Author

totaam commented Oct 16, 2013

2013-10-16 09:41:49: totaam changed owner from antoine to smo

@totaam
Copy link
Collaborator Author

totaam commented Oct 16, 2013

2013-10-16 09:41:49: totaam commented


This solution works for me: Building PyCrypto with fastmath (gmp or mpir) via pip on Windows (remove existing version before installing - and remember to use "export VAR=value" syntax in the mingw32 shell!)

You can verify it is installed with:

C:\Python27\Python.exe -c "from Crypto.PublicKey import _fastmath;print(_fastmath);"

And as of r4511, it is also shown on session info as "(fastmath available)":
[[Image(/raw-attachment/ticket/373/session-info-showfastmath.png)]]

Please confirm and close.

@totaam
Copy link
Collaborator Author

totaam commented Dec 10, 2013

2013-12-10 00:04:26: smo changed status from new to closed

@totaam
Copy link
Collaborator Author

totaam commented Dec 10, 2013

2013-12-10 00:04:26: smo changed resolution from ** to fixed

@totaam
Copy link
Collaborator Author

totaam commented Dec 10, 2013

2013-12-10 00:04:26: smo commented


Followed the same solution that worked for you. Compiled and Installed with minor issues.

There was an issue with the test units but doesn't seem to affect anything. Will reopen this ticket if I find a problem.

@totaam totaam closed this as completed Dec 10, 2013
@totaam
Copy link
Collaborator Author

totaam commented Jul 17, 2014

2014-07-17 17:55:14: totaam commented


Notes:

  • pycrypto version 2.6.1 was released on the 2014-06-20 and is an important update (security issues)
  • upgrading via easy_install breaks fastmath.. the instruction above have to be used every time (PITA)
  • mpir 2.7.0 beta is available (which means that the actual release is likely to happen before too long - and we probably should use it as it fixes RNG security issues, etc)

@totaam
Copy link
Collaborator Author

totaam commented Jul 24, 2014

2014-07-24 14:54:34: totaam commented


Was easier to rebuild with an up to date mingw32 environment and the libgmp it can install.

In a mingw shell:

mingw-get.exe update
mingw-get.exe upgrade
mingw-get.exe install mingw32-libgmp

Then in the pycrypto source directory, just:

./configure
/c/Python27/python.exe setup.py build -c mingw32
/c/Python27/python.exe setup.py test
/c/Python27/python.exe setup.py install

Note: this does not seem to work for Python 3.3 and 3.4, where the resulting module causes crashes at runtime

Note: as of version 0.12.x, you can also verify the presence of pycrypto's fastmath with Network_info.exe:

C:\Program Files\Xpra>Network_info.exe
Network interfaces found:
* {0F7E7AF4-D168-429C-86D0-0687BA76F4A5}
* MS TCP Loopback interface

Protocol Capabilities:
* bencode              : True
* bencode.version      : Cython, 0.11
* digest               : hmac, xor
* lz4                  : True
* mmap                 : True
* pycrypto.fastmath    : True
* pycrypto.version     : 2.6.1
* rencode              : True
* rencode.version      : Cython, 1.0.2
* yaml                 : False

PS: you may need to patch some of the mingw header files if you encounter off64_t and off_t errors, see here: mingw bug 2024: 'off64_t' does not name a type

@totaam
Copy link
Collaborator Author

totaam commented Jul 25, 2014

2014-07-25 16:48:57: totaam commented


For Python 3.x:

  • using gmp 6.0.0:
  • build it with mingw32 (no way to build with msvc?):
./configure --disable-static --enable-shared --with-pic --host=pentium-pc-mingw32
make
cd gmp-6.0.0
cd .libs
lib /def:libgmp-3.dll.def /out:gmp.lib
  • copy the gmp.lib to the pycrypto source dir
  • copy the gmp.h to pycrypto's src/inc-msvc dir
  • edit src/inc-msvc/config.h:
#define HAVE_DECL_MPZ_POWM 1
#define HAVE_DECL_MPZ_POWM_SEC 1
#define HAVE_LIBGMP 1
  • build + install pycrypto:
C:\Python34\Python.exe setup.py install

(and verify that it found gmp)

Note: for some reason, the fastmath pyd needs to find the libgmp-3.dll.dll (and fails no matter what it seems..)

[[BR]]

Nasty workaround:

  • make a static version of gmp instead:
./configure --disable-shared --enable-static --with-pic --host=pentium-pc-mingw32
make
  • copy .libs/libgmp.a and libgcc.a to pycrypto's source dir
  • edit pycrypto's setup.py and replace the fastmath extension's libraries= line with:
extra_objects=['libgmp.a', 'libgcc.a']
  • build + install pycrypto:
C:\Python34\Python.exe setup.py install

(and verify that it found gmp)

  • make an xpra build and verify that fastmath is present

  • using mpir:
  • requires msvc gui... which is stuck on the splash screen on my dev vm..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant