Export to GitHub

py-bcrypt - issue #1

Windows & MSVS2008 compilation


Posted on Mar 31, 2011 by Massive Kangaroo

While compiling on Windows7 using Visual Studio 2008 (MinGW was throwing me too many errors), I had to change the calls to bzero() in bcrypt_python.c to memset() since bzero isn't provided in the Visual Studio 2008 linked libraries.

Comment #1

Posted on Jun 21, 2011 by Grumpy Cat

Same here.

Lines 85-87 of bcrypt_python.c had to changed to:

memset(password_copy, 0, strlen(password_copy)); free(password_copy); memset(salt_copy, 0, strlen(salt_copy));

Got further with that, but then got a "too many arguments to function 'encode_salt'" error. :-/

Comment #2

Posted on Jun 21, 2011 by Grumpy Cat

Okay, removed all instances of "#if defined(_MSC_VER)" from all the files. This fixed it. Note I was using the MinGW32 GCC compiler, so that might have had something to do with it.

Comment #3

Posted on Jul 12, 2011 by Swift Rabbit

According to http://groups.google.com/group/mpir-devel/msg/2c2d4cc7ec12adbb (flags defined under the various windows OS'es ,cygwins,mingw's and other's) its better to use _WIN32 instead of _MSC_VER, Together with the change from bzero to memset this compiles both under MSVC and MingW32.

Attached a patch with the required changes.

Attachments

Comment #4

Posted on Jul 28, 2011 by Quick Wombat

I had the same issue.

I'd suggest sidestepping all of the conditional defines, etc., and move from bzero to memset, which is recommended anyway; bcopy was marked as LEGACY in POSIX.1-2001.

This will make it more likely that py-bcrypt will compile on mingw32, vc++, and who knows how many other non-Windows compilers.

Finally, can I request a new release? Keeping all of my runtime environments up to date with HEAD (not to mention a locally patched HEAD due to this issue) is laborious.

THANKS everyone!!!

Diff:

85c85

< memset(password_copy, 0, strlen(password_copy));

bzero(password_copy, strlen(password_copy)); 87c87

< memset(salt_copy, 0, strlen(salt_copy));

bzero(salt_copy, strlen(salt_copy));

Comment #5

Posted on Aug 30, 2011 by Happy Giraffe

I have made a release just for Windows here http://pypi.python.org/pypi/py-bcrypt-w32

Comment #6

Posted on May 14, 2012 by Helpful Giraffe

@djpnew...@gmail.com: I'm installing using the link you provided and I get the following errors:

running install running bdist_egg running egg_info writing py_bcrypt_w32.egg-info\PKG-INFO writing top-level names to py_bcrypt_w32.egg-info\top_level.txt writing dependency_links to py_bcrypt_w32.egg-info\dependency_links.txt reading manifest file 'py_bcrypt_w32.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'ChangeLog' warning: no files found matching 'test' under directory 'bcrypt' writing manifest file 'py_bcrypt_w32.egg-info\SOURCES.txt' installing library code to build\bdist.win32\egg running install_lib running build_py copying bcrypt__init__.py -> build\lib.win32-2.7\bcrypt running build_ext building 'bcrypt._bcrypt' extension C:\MinGW32-xy\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c bc rypt/bcrypt_python.c -o build\temp.win32-2.7\Release\bcrypt\bcrypt_python.o bcrypt/bcrypt_python.c: In function 'bcrypt_encode_salt': bcrypt/bcrypt_python.c:56:2: warning: pointer targets in passing argument 2 of 'encode_salt' diff er in signedness bcrypt/bcrypt_python.c:29:6: note: expected 'u_int8_t *' but argument is of type 'char ' C:\MinGW32-xy\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c bc rypt/blowfish.c -o build\temp.win32-2.7\Release\bcrypt\blowfish.o In file included from bcrypt/blowfish.c:43:0: bcrypt/pybc_blf.h:55:2: error: expected specifier-qualifier-list before 'u_int32_t' bcrypt/pybc_blf.h:66:55: warning: type defaults to 'int' in declaration of 'u_int8_t' bcrypt/pybc_blf.h:66:64: error: expected ';', ',' or ')' before '' token bcrypt/pybc_blf.h:67:54: warning: type defaults to 'int' in declaration of 'u_int8_t' bcrypt/pybc_blf.h:67:63: error: expected ';', ',' or ')' before '' token bcrypt/pybc_blf.h:72:35: error: expected declaration specifiers or '...' before 'u_int32_t' bcrypt/pybc_blf.h:72:48: error: expected declaration specifiers or '...' before 'u_int16_t' bcrypt/pybc_blf.h:75:11: error: expected '=', ',', ';', 'asm' or 'attribute' before 'pybc_Blo wfish_stream2word' bcrypt/blowfish.c:55:41: error: expected declaration specifiers or '...' before 'u_int32_t' bcrypt/blowfish.c:55:56: error: expected declaration specifiers or '...' before 'u_int32_t' bcrypt/blowfish.c: In function 'pybc_Blowfish_encipher': bcrypt/blowfish.c:57:2: error: 'u_int32_t' undeclared (first use in this function) bcrypt/blowfish.c:57:2: note: each undeclared identifier is reported only once for each function it appears in bcrypt/blowfish.c:57:12: error: expected ';' before 'Xl' bcrypt/blowfish.c:58:12: error: expected ';' before 'Xr' bcrypt/blowfish.c:59:13: error: 's' undeclared (first use in this function) bcrypt/blowfish.c:59:18: error: 'pybc_blf_ctx' has no member named 'S' bcrypt/blowfish.c:60:13: error: 'p' undeclared (first use in this function) bcrypt/blowfish.c:60:18: error: 'pybc_blf_ctx' has no member named 'P' bcrypt/blowfish.c:62:2: error: 'Xl' undeclared (first use in this function) bcrypt/blowfish.c:62:8: error: 'xl' undeclared (first use in this function) bcrypt/blowfish.c:63:2: error: 'Xr' undeclared (first use in this function) bcrypt/blowfish.c:63:8: error: 'xr' undeclared (first use in this function) bcrypt/blowfish.c: In function 'pybc_Blowfish_initstate': bcrypt/blowfish.c:85:2: error: extra brace group at end of initializer bcrypt/blowfish.c:85:2: error: (near initialization for 'initstate') bcrypt/blowfish.c:86:3: error: extra brace group at end of initializer bcrypt/blowfish.c:86:3: error: (near initialization for 'initstate') bcrypt/blowfish.c:151:3: error: extra brace group at end of initializer bcrypt/blowfish.c:151:3: error: (near initialization for 'initstate') bcrypt/blowfish.c:216:3: error: extra brace group at end of initializer bcrypt/blowfish.c:216:3: error: (near initialization for 'initstate') bcrypt/blowfish.c:281:3: error: extra brace group at end of initializer bcrypt/blowfish.c:281:3: error: (near initialization for 'initstate') bcrypt/blowfish.c:346:2: warning: excess elements in struct initializer bcrypt/blowfish.c:346:2: warning: (near initialization for 'initstate') bcrypt/blowfish.c:347:2: error: extra brace group at end of initializer bcrypt/blowfish.c:347:2: error: (near initialization for 'initstate') bcrypt/blowfish.c:353:2: warning: excess elements in struct initializer bcrypt/blowfish.c:353:2: warning: (near initialization for 'initstate') bcrypt/blowfish.c: At top level: bcrypt/blowfish.c:359:1: error: expected '=', ',', ';', 'asm' or 'attribute' before 'pybc_Blo wfish_stream2word' bcrypt/blowfish.c:380:51: warning: type defaults to 'int' in declaration of 'u_int8_t' bcrypt/blowfish.c:380:60: error: expected ';', ',' or ')' before '' token bcrypt/blowfish.c:419:50: warning: type defaults to 'int' in declaration of 'u_int8_t' bcrypt/blowfish.c:419:59: error: expected ';', ',' or ')' before '*' token bcrypt/blowfish.c:462:31: error: expected declaration specifiers or '...' before 'u_int32_t' bcrypt/blowfish.c:462:48: error: expected declaration specifiers or '...' before 'u_int16_t' bcrypt/blowfish.c: In function 'pybc_blf_enc': bcrypt/blowfish.c:464:2: error: 'u_int32_t' undeclared (first use in this function) bcrypt/blowfish.c:464:13: error: 'd' undeclared (first use in this function) bcrypt/blowfish.c:465:2: error: 'u_int16_t' undeclared (first use in this function) bcrypt/blowfish.c:465:12: error: expected ';' before 'i' bcrypt/blowfish.c:467:6: error: 'data' undeclared (first use in this function) bcrypt/blowfish.c:468:7: error: 'i' undeclared (first use in this function) bcrypt/blowfish.c:468:18: error: 'blocks' undeclared (first use in this function) bcrypt/blowfish.c:469:3: error: too many arguments to function 'pybc_Blowfish_encipher' bcrypt/blowfish.c:55:1: note: declared here error: command 'gcc' failed with exit status 1

Any suggestions?

Comment #7

Posted on Jun 12, 2012 by Happy Camel

The py-bcrypt_11.patch fixed it for me; I applied it manually.

Thanks a lot and do apply that patch to future releases for Windows, please.

Running it on a Windows 7 with the MinGW suite that comes with the Codeblocks IDE

Comment #8

Posted on Jun 18, 2012 by Happy Bird

There is yet another issue with compiling on windows as cl cannot cope with definition of variables mid-function and thus char* password/salt_copy will not work. I attached a patch that combines the above patch (which is awesome <3) with my fixes. One note though: The lines concerning bzero/memset dont seem to be present any more so they are not in my patch, of course.

Attachments

Comment #9

Posted on Aug 20, 2012 by Happy Dog

Following up on florian's patch, I would love to see that pushed through... It is really needed!

Comment #10

Posted on Aug 27, 2012 by Happy Dog

Combining Florian, rye and beng's changes, I went ahead and created a repo on Github. I am hoping anyone with further changes will fork and pull on Github, or else here. Seeing as there does not seem to be much activity on this repository (sadly).

https://github.com/wcdolphin/py-bcrypt

Comment #11

Posted on Jul 27, 2013 by Massive Wombat

Hi,

I've pushed some changes in preparation of a py-bcrypt-0.4 release that include a tweaked version of this patch. Please give the current hg tip a test and let me know if it fixes the problems on Windows - I haven't had access to MSVC for a few years to test myself.

-d

Comment #12

Posted on Jul 27, 2013 by Massive Wombat

(No comment was entered for this change.)

Comment #13

Posted on Aug 12, 2013 by Happy Monkey

As mentioned by florian (#8), revision 32 again has a variable declaration which is not at the beginning of the function. MSVC therefore cannot compile the project. The attached patch solves the issue for revision 32.

Attachments

Comment #14

Posted on Aug 25, 2013 by Massive Wombat

Patch applied - thanks!

Status: Fixed

Labels:
Type-Defect Priority-Medium