[PATCH] Support Windows CE 5 and later
Hi everyone, please find attached a patch to update the Windows CE support to current versions (Windows CE 5 and 6) based on version 0.9.8i. Most changes are related to the wcecompat lib, which defines an additional requirement for this platform. Unfortunately the maintainers did not respond to multiple contact mails for half a year, thus we were forced to fork the project to be able to provide updates. It is now hosted at github at following URL: http://github.com/mauricek/wcecompat Basically the patch consists of: * updated documentation (also some more details on setup) * a compile regression which seemed to have happened within one of the later versions of OpenSSL (o_str.c) * Windows CE 5 and later updates (mostly in the configuration script). OpenSSL compiles for Windows CE 5 Standard SDK on all provided architectures (x86,mips, arm, etc.) and for Windows Mobile 5 and 6. Tests were run on Windows CE 5 x86 and mips devices and they all pass. If you have any questions or comments, feel free to contact me, otherwise I'd be delighted to see these updates in the next version of this project. Best Regards, Maurice Kalinowski -- Maurice Kalinowski - maurice.kalinowski (AT) nokia.com Software Engineer - Nokia, Qt Software Rudower Chaussee 13, 12489 Berlin, Germany diff -durw openssl-0.9.8i_original/INSTALL.WCE openssl-0.9.8i/INSTALL.WCE --- openssl-0.9.8i_original/INSTALL.WCE Tue Oct 4 08:35:14 2005 +++ openssl-0.9.8i/INSTALL.WCE Thu Oct 30 10:59:54 2008 @@ -4,18 +4,15 @@ Building OpenSSL for Windows CE requires the following external tools: - * Microsoft eMbedded Visual C++ 3.0 - * wcecompat compatibility library (www.essemer.com.au) + * Microsoft eMbedded Visual C++ 3.0 or Microsoft Visual Studio 2005 and later + * wcecompat compatibility library + * www.essemer.com.au Windows CE 4.2 and earlier + * github.com/mauricek/wcecompat all Windows CE versions * Optionally ceutils for running automated tests (www.essemer.com.au) You also need Perl for Win32. You will need ActiveState Perl, available - from http://www.activestate.com/ActivePerl. - - Windows CE support in OpenSSL relies on wcecompat and therefore it's - appropriate to check http://www.essemer.com.au/windowsce/ for updates in - case of compilation problems. As for the moment of this writing version - 1.1 is available and actually required for WCE 4.2 and newer platforms. - All Windows CE specific issues should be directed to www.essemer.com.au. + from http://www.activestate.com/ActivePerl. Note that perl by MSYS does + not create correct makefiles. The C Runtime Library implementation for Windows CE that is included with Microsoft eMbedded Visual C++ 3.0 is incomplete and in some places @@ -26,6 +23,10 @@ by the OpenSSL library itself but is used for the tests and openssl.exe. More information is available at www.essemer.com.au. + With Windows CE 5 and following a lot of standard functionality has been + added to the core system, making some parts of the wcecompat lib deprecated. + More information is available at github.com/mauricek/wcecompat + Building @@ -34,10 +35,18 @@ > "C:\Program Files\Microsoft eMbedded Tools\EVC\WCE300\BIN\WCEARM.BAT" + For Visual Studio 2005 and following there might be similar script depending + on the SDK OpenSSL is supposed to be build for. Follow the SDK documentation + to get more information how to setup a cross-compiler environment. + Next indicate where wcecompat is located: > set WCECOMPAT=C:\wcecompat + OpenSSL for Windows CE uses the same environment variables for compilation + as wcecompat does. Thus, there might be more settings needed. For more + information follow the wcecompat documentation. + Next you should run Configure: > perl Configure VC-CE @@ -61,8 +70,9 @@ > nmake -f ms\cedll.mak If all is well it should compile and you will have some static libraries and - executables in out32, or some DLLs and executables in out32dll. If you want - to try the tests then make sure the ceutils are in the path and do: + executables in out32_xyz, or some DLLs and executables in out32dll_xyz where + xyz refers to the target processor architecture of the Windows CE SDK. + If you want to try the tests then make sure the ceutils are in the path and do: > cd out32 > ..\ms\testce diff -durw openssl-0.9.8i_original/crypto/o_str.c openssl-0.9.8i/crypto/o_str.c --- openssl-0.9.8i_original/crypto/o_str.c Sat Mar 29 14:22:49 2008 +++ openssl-0.9.8i/crypto/o_str.c Wed Oct 29 10:30:03 2008 @@ -60,7 +60,7 @@ #include #include "o_str.h" -#if !defined(OPENSSL_IMPLEMENTS_strncasecmp) && !defined(OPENSSL_SYSNAME_WIN32) +#if !defined(OPENSSL_IMPLEMENTS_strncasecmp) && !defined(OPENSSL_SYSNAME_WIN32) && !defined(OPENSSL_SYS_WINCE) # include #endif diff -durw openssl-0.9.8i_original/crypto/rsa/rsa_pss.c openssl-0.9.8i/crypto/rsa/rsa_pss.c --- openssl-0.9.8i_original/crypto/rsa/rsa_pss.c
RE: [openssl.org #1770] 'make test' failure for OpenSSL 9.8g
> I tried to install OpenSSL 9.8g as follows on linux-x86_64 >1. Edited config and Configure to replace ‘perl5’ with ‘perl’ >2. ./config 386 no-asm >3. Modifed the CFLAGS in Makefile (removed –m64 and added –m32) >4. Make >5. Make test ….’make test fails’ . Why does it fail? Obviously your '386' parameter didn't work, since it didn't select a compiler that produces 32-bit code. Adding '-m32' caused a borked build, since you configured without '-m32' but built with it. DS __ OpenSSL Project http://www.openssl.org Development Mailing List openssl-dev@openssl.org Automated List Manager [EMAIL PROTECTED]
Re: [PATCH] Support Windows CE 5 and later
On Thu, Oct 30, 2008, Maurice Kalinowski wrote: > Hi everyone, > > please find attached a patch to update the Windows CE support to current > versions (Windows CE 5 and 6) based on version 0.9.8i. > Thank you for the patch. A couple of quick points. Patches should be sent to the request tracker so they don't get overlooked. Can you produce a version for the HEAD (OpenSSL 0.9.9-dev) too? Steve. -- Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage OpenSSL project core developer and freelance consultant. Homepage: http://www.drh-consultancy.demon.co.uk __ OpenSSL Project http://www.openssl.org Development Mailing List openssl-dev@openssl.org Automated List Manager [EMAIL PROTECTED]
Re: [openssl.org #1693] Compiling OpenSSL with mingw-w64
Hello, Attached is latest mingw win64 patch for OpenSSL. It is verified to work with the OpenSC project and the OpenVPN project using cross compile from Linux machine using binutils CVS head, gcc-4.3.2 and mingw-w64 svn head. There is no assembly support for pe64. So no assembly is available. Can someone estimate if it is better to use 32bit with assembly than 64bit without? I am not fully sure that the crypto/sha/sha512.c is correct, it simulate the behavior of win64 using Microsoft compiler, using _rotr64 function as ROTR. If correct, please consider to merge this so there is some solution for win64 users and not require to keep syncing with CVS head. I use: ./Configure --prefix="//" --cross-compile-prefix=x86_64-pc-mingw32- no-zlib shared mingw64 no-capieng Thank you, Alon Bar-Lev. diff -urNp openssl-SNAP-20081003/Configure openssl-SNAP-20081003.mingw64/Configure --- openssl-SNAP-20081003/Configure 2008-09-16 00:00:05.0 +0300 +++ openssl-SNAP-20081003.mingw64/Configure 2008-10-20 12:37:37.0 +0200 @@ -496,6 +496,8 @@ my %table=( # MinGW "mingw", "gcc:-mno-cygwin -DL_ENDIAN -fomit-frame-pointer -O3 -march=i486 -Wall:::MINGW32:-lws2_32 -lgdi32:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts} EXPORT_VAR_AS_FN:${x86_coff_asm}:win32:cygwin-shared:-D_WINDLL -DOPENSSL_USE_APPLINK:-mno-cygwin:.dll.a", +"mingw64", "gcc:-mno-cygwin -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -fomit-frame-pointer -O3 -Wall -D_WIN32_WINNT=0x333:::MINGW64:-lws2_32 -lgdi32:SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:${no_asm}:win32:cygwin-shared:-D_WINDLL:-mno-cygwin:.dll.a", + # UWIN "UWIN", "cc:-DTERMIOS -DL_ENDIAN -O -Wall:::UWIN::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:win32", @@ -968,7 +970,7 @@ foreach (sort (keys %disabled)) my $IsMK1MF=scalar grep /^$target$/,@MK1MF_Builds; -$exe_ext=".exe" if ($target eq "Cygwin" || $target eq "DJGPP" || $target eq "mingw"); +$exe_ext=".exe" if ($target eq "Cygwin" || $target eq "DJGPP" || $target =~ /^mingw/); $exe_ext=".nlm" if ($target =~ /netware/); $exe_ext=".pm" if ($target =~ /vos/); $openssldir="/usr/local/ssl" if ($openssldir eq "" and $prefix eq ""); --- openssl-SNAP-20081003/engines/e_aep.c 2008-01-04 01:01:24.0 +0200 +++ openssl-SNAP-20081003.mingw64/engines/e_aep.c 2008-10-20 12:46:24.0 +0200 @@ -62,8 +62,10 @@ #include #else #include +#ifndef _PID_T_ typedef int pid_t; +#endif #endif #if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) #define getpid GetThreadID --- openssl-SNAP-20081023/crypto/sha/sha512.c 2008-04-24 13:00:12.0 +0300 +++ openssl-SNAP-20081023.mingw64/crypto/sha/sha512.c 2008-10-28 00:19:56.0 +0200 @@ -350,11 +350,15 @@ static const SHA_LONG64 K512[80] = { #ifndef PEDANTIC # if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) # if defined(__x86_64) || defined(__x86_64__) -# define ROTR(a,n) ({ unsigned long ret; \ +# if defined(_WIN64) +#define ROTR(a,n) _rotr64((a),n) /* applies to both IA-64 and AMD64 */ +# else +#define ROTR(a,n) ({ unsigned long ret; \ asm ("rorq %1,%0" \ : "=r"(ret) \ : "J"(n),"0"(a) \ : "cc"); ret; }) +# endif # if !defined(B_ENDIAN) #define PULL64(x) ({ SHA_LONG64 ret=*((const SHA_LONG64 *)(&(x))); \ asm ("bswapq %0" \
Re: [openssl.org #1693] Compiling OpenSSL with mingw-w64
> There is no assembly support for pe64. Well, Win64 ABI is fully supported by OpenSSL x86_64 assembler modules. There is no support for GNU assembler under Win64, but masm (rather known as ml64) and nasm are fully supported (though there are requirements for least supported versions, for nasm it's 2.03). > So no assembly is available. If assembler was to be added to mingw64, I'd rather deploy nasm. It would be easiest. > Can someone estimate if it is better to use 32bit with assembly than > 64bit without? 64-bit algorithms, most notably SHA512, would perform better with 64-bit compiler, while 32-bit assembler is likely to outperform it on 32-bit algorithms (such as everything else symmetric). Indeed, 32-bit assembler normally delivers ~80% of 64-bit assembler on 32-bit algorithms (not on SHA256 though), so assuming that 64-bit assembler gives at least 30% improvement over 64-bit compiler generated code... As for BN performance. As it is *now*, 32-bit assembler would perform approximately as fast as (if not better) 64-bit compiler generated code, but[!] it's possible to improve the latter. Try following. In bn_lcl.h there is BN_UMULT_HIGH definition in #elif defined(__x86_64) && defined(SIXTY_FOUR_BIT_LONG) in __GNUC__. Replace last defined() with (defined(SIXTY_FOUR_BIT_LONG) || defined(SIXTY_FOUR_BIT)). This will give significant performance improvement. Please verify. > I am not fully sure that the crypto/sha/sha512.c is correct, it > simulate the behavior of win64 using Microsoft compiler, using > _rotr64 function as ROTR. What you should have done instead is to modify macro in question declaring ret as unsigned long long. If it doesn't work, then it's more appropriate to leave ROTR undefined, i.e. *not* using _rotr64. Please verify. Also. As NT is natively UNICODE, and there are no non-NT Win64 implementations(*), there is no reason to favor legacy ANSI interfaces. Could you verify that it compiles and works with -DUNICODE -D_UNICODE added to config line? A. (*) this is unlike Win32, which was available as NT and Win9x, where latter was natively ANSI. __ OpenSSL Project http://www.openssl.org Development Mailing List openssl-dev@openssl.org Automated List Manager [EMAIL PROTECTED]
Re: [openssl.org #1693] Compiling OpenSSL with mingw-w64
On Thursday 30 October 2008, Andy Polyakov via RT wrote: > > There is no assembly support for pe64. > > Well, Win64 ABI is fully supported by OpenSSL x86_64 assembler modules. > There is no support for GNU assembler under Win64, but masm (rather > known as ml64) and nasm are fully supported (though there are > requirements for least supported versions, for nasm it's 2.03). This would be great! > > I am not fully sure that the crypto/sha/sha512.c is correct, it > > simulate the behavior of win64 using Microsoft compiler, using > > _rotr64 function as ROTR. > > What you should have done instead is to modify macro in question > declaring ret as unsigned long long. If it doesn't work, then it's more > appropriate to leave ROTR undefined, i.e. *not* using _rotr64. Please > verify. Thanks, I converted this to SHA_LONG64 and it now compiles. > Also. As NT is natively UNICODE, and there are no non-NT Win64 > implementations(*), there is no reason to favor legacy ANSI interfaces. > Could you verify that it compiles and works with -DUNICODE -D_UNICODE > added to config line? A. This is too much work, and it is not related to mingw-win64, as this is needed also for NT port. There is too much dependency in ANSI in current implementation. I forgot to mention that the uplink was removed due to assembly issues. There is another issue... sizeof(long)http://www.opensc-project.org/build/browser/trunk/mingw64 [2] http://www.opensc-project.org/build/browser/trunk diff -urNp openssl-SNAP-20081003/Configure openssl-SNAP-20081003.mingw64/Configure --- openssl-SNAP-20081003/Configure 2008-09-16 00:00:05.0 +0300 +++ openssl-SNAP-20081003.mingw64/Configure 2008-10-20 12:37:37.0 +0200 @@ -496,6 +496,8 @@ my %table=( # MinGW "mingw", "gcc:-mno-cygwin -DL_ENDIAN -fomit-frame-pointer -O3 -march=i486 -Wall:::MINGW32:-lws2_32 -lgdi32:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts} EXPORT_VAR_AS_FN:${x86_coff_asm}:win32:cygwin-shared:-D_WINDLL -DOPENSSL_USE_APPLINK:-mno-cygwin:.dll.a", +"mingw64", "gcc:-mno-cygwin -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -fomit-frame-pointer -O3 -Wall -D_WIN32_WINNT=0x333:::MINGW64:-lws2_32 -lgdi32:SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:${no_asm}:win32:cygwin-shared:-D_WINDLL:-mno-cygwin:.dll.a", + # UWIN "UWIN", "cc:-DTERMIOS -DL_ENDIAN -O -Wall:::UWIN::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${no_asm}:win32", @@ -968,7 +970,7 @@ foreach (sort (keys %disabled)) my $IsMK1MF=scalar grep /^$target$/,@MK1MF_Builds; -$exe_ext=".exe" if ($target eq "Cygwin" || $target eq "DJGPP" || $target eq "mingw"); +$exe_ext=".exe" if ($target eq "Cygwin" || $target eq "DJGPP" || $target =~ /^mingw/); $exe_ext=".nlm" if ($target =~ /netware/); $exe_ext=".pm" if ($target =~ /vos/); $openssldir="/usr/local/ssl" if ($openssldir eq "" and $prefix eq ""); --- openssl-SNAP-20081003/engines/e_aep.c 2008-01-04 01:01:24.0 +0200 +++ openssl-SNAP-20081003.mingw64/engines/e_aep.c 2008-10-20 12:46:24.0 +0200 @@ -62,8 +62,10 @@ #include #else #include +#ifndef _PID_T_ typedef int pid_t; +#endif #endif #if defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB) #define getpid GetThreadID diff -urNp openssl-SNAP-20081028.org/crypto/sha/sha512.c openssl-SNAP-20081028/crypto/sha/sha512.c --- openssl-SNAP-20081028/crypto/sha/sha512.c 2008-04-24 13:00:12.0 +0300 +++ openssl-SNAP-20081028.mingw64/crypto/sha/sha512.c 2008-10-30 22:41:20.0 +0200 @@ -350,7 +350,7 @@ static const SHA_LONG64 K512[80] = { #ifndef PEDANTIC # if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM) # if defined(__x86_64) || defined(__x86_64__) -# define ROTR(a,n) ({ unsigned long ret; \ +# define ROTR(a,n) ({ SHA_LONG64 ret; \ asm ("rorq %1,%0" \ : "=r"(ret) \ : "J"(n),"0"(a) \ --- openssl-SNAP-20081028/apps/speed.c 2008-10-30 22:59:03.0 +0200 +++ openssl-SNAP-20081028.mingw64/apps/speed.c 2008-10-30 22:59:16.0 +0200 @@ -281,7 +281,7 @@ static double Time_F(int s) if (thr==NULL) { DWORD ret=GetLastError(); - BIO_printf(bio_err,"unable to CreateThread (%d)",ret); + BIO_printf(bio_err,"unable to CreateThread (%ld)",ret); ExitProcess(ret); } CloseHandle(thr); /* detach the thread */ --- openssl-SNAP-20081028/crypto/jpake/jpake.c 2008-10-27 15:00:14.0 +0200 +++ openssl-SNAP-20081028.mingw64/crypto/jpake/jpake.c 2008-10-30 23:23:30.0 +0200 @@ -5,6 +5,7 @@ #include #include #include +#include /* * In the definition, (xa, xb, xc, xd) are Alice's (x1, x2, x3, x4) or