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)<sizeof(void*) in win64... So I found 
more places
that needs some attention, the "Should be fixed" category probably impact more 
than
I can fix. Alignments are simple to fix, but changing the long variables that 
hold pointers
modifies interfaces. I just don't understand how using Microsoft compiler this 
code makes
sense.

Works but cast need do be fixed:
        cryptlib.c:442: warning: cast from pointer to integer of different size

printf, should be converted to %p and remove cast:
        asn1_lib.c:467: warning: cast from pointer to integer of different size
        mem_dbg.c:699: warning: cast from pointer to integer of different size
        bio_cb.c:78: warning: cast from pointer to integer of different size

Should be fixed:
        mem_dbg.c:333: warning: cast from pointer to integer of different size
        rc4_enc.c:123: warning: cast from pointer to integer of different size
        rc4_enc.c:124: warning: cast from pointer to integer of different size
        b_print.c:379: warning: cast from pointer to integer of different size
        s3_pkt.c:146: warning: cast from pointer to integer of different size
        s3_pkt.c:688: warning: cast from pointer to integer of different size
        s3_pkt.c:701: warning: cast from pointer to integer of different size

dllimport issues, probably unrelated:
        ecb_enc.c:64: warning: ‘OSSL_libdes_version’ redeclared without 
dllimport attribute: previous dllimport ignored
        ecb_enc.c:65: warning: ‘OSSL_DES_version’ redeclared without dllimport 
attribute: previous dllimport ignored
        s2_lib.c:124: warning: ‘ssl2_ciphers’ redeclared without dllimport 
attribute: previous dllimport ignored
        s3_lib.c:170: warning: ‘ssl3_ciphers’ redeclared without dllimport 
attribute: previous dllimport ignored

If you like, I wrote a build script for the mingw-win64 toolchain and OpenSC 
components (Including OpenSSL).
It is available at [1] and [2].

Attached is a new patch.

Thank you,
Alon Bar-Lev.

[1] 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.000000000 +0300
+++ openssl-SNAP-20081003.mingw64/Configure	2008-10-20 12:37:37.000000000 +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.000000000 +0200
+++ openssl-SNAP-20081003.mingw64/engines/e_aep.c	2008-10-20 12:46:24.000000000 +0200
@@ -62,8 +62,10 @@
 #include <unistd.h>
 #else
 #include <process.h>
+#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.000000000 +0300
+++ openssl-SNAP-20081028.mingw64/crypto/sha/sha512.c	2008-10-30 22:41:20.000000000 +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.000000000 +0200
+++ openssl-SNAP-20081028.mingw64/apps/speed.c	2008-10-30 22:59:16.000000000 +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.000000000 +0200
+++ openssl-SNAP-20081028.mingw64/crypto/jpake/jpake.c	2008-10-30 23:23:30.000000000 +0200
@@ -5,6 +5,7 @@
 #include <openssl/err.h>
 #include <memory.h>
 #include <assert.h>
+#include <string.h>
 
 /*
  * In the definition, (xa, xb, xc, xd) are Alice's (x1, x2, x3, x4) or

Reply via email to