Browse Source

fixed compilation for x64

Nicolas Cannasse 8 years ago
parent
commit
9c52862a16
2 changed files with 12 additions and 10 deletions
  1. 6 4
      libs/ssl/ssl.c
  2. 6 6
      libs/ssl/ssl.vcxproj

+ 6 - 4
libs/ssl/ssl.c

@@ -85,7 +85,7 @@ static int ssl_error(int ret) {
 	char buf[128];
 	char buf[128];
 	uchar buf16[128];
 	uchar buf16[128];
 	mbedtls_strerror(ret, buf, sizeof(buf));
 	mbedtls_strerror(ret, buf, sizeof(buf));
-	hl_from_utf8(buf16, strlen(buf) + 1, buf);
+	hl_from_utf8(buf16, (int)strlen(buf) + 1, buf);
 	hl_error_msg(buf16);
 	hl_error_msg(buf16);
 	return ret;
 	return ret;
 }
 }
@@ -118,11 +118,11 @@ HL_PRIM int HL_NAME(ssl_handshake)(mbedtls_ssl_context *ssl) {
 }
 }
 
 
 int net_read(void *fd, unsigned char *buf, size_t len) {
 int net_read(void *fd, unsigned char *buf, size_t len) {
-	return recv((SOCKET)(int_val)fd, (char *)buf, len, 0);
+	return recv((SOCKET)(int_val)fd, (char *)buf, (int)len, 0);
 }
 }
 
 
 int net_write(void *fd, const unsigned char *buf, size_t len) {
 int net_write(void *fd, const unsigned char *buf, size_t len) {
-	return send((SOCKET)(int_val)fd, (char *)buf, len, 0);
+	return send((SOCKET)(int_val)fd, (char *)buf, (int)len, 0);
 }
 }
 
 
 HL_PRIM void HL_NAME(ssl_set_socket)(mbedtls_ssl_context *ssl, hl_socket *socket) {
 HL_PRIM void HL_NAME(ssl_set_socket)(mbedtls_ssl_context *ssl, hl_socket *socket) {
@@ -609,6 +609,7 @@ HL_PRIM vbyte *HL_NAME(dgst_sign)(vbyte *data, int len, hl_ssl_pkey *key, vbyte
 	int r = -1;
 	int r = -1;
 	vbyte *out;
 	vbyte *out;
 	unsigned char hash[MBEDTLS_MD_MAX_SIZE];
 	unsigned char hash[MBEDTLS_MD_MAX_SIZE];
+	size_t ssize = size ? *size : 0;
 
 
 	md = mbedtls_md_info_from_string(alg);
 	md = mbedtls_md_info_from_string(alg);
 	if (md == NULL) {
 	if (md == NULL) {
@@ -622,10 +623,11 @@ HL_PRIM vbyte *HL_NAME(dgst_sign)(vbyte *data, int len, hl_ssl_pkey *key, vbyte
 	}
 	}
 
 
 	out = hl_gc_alloc_noptr(MBEDTLS_MPI_MAX_SIZE);
 	out = hl_gc_alloc_noptr(MBEDTLS_MPI_MAX_SIZE);
-	if ((r = mbedtls_pk_sign(key->k, mbedtls_md_get_type(md), hash, 0, out, size, mbedtls_ctr_drbg_random, &ctr_drbg)) != 0){
+	if ((r = mbedtls_pk_sign(key->k, mbedtls_md_get_type(md), hash, 0, out, (size ? &ssize : NULL), mbedtls_ctr_drbg_random, &ctr_drbg)) != 0){
 		ssl_error(r);
 		ssl_error(r);
 		return NULL;
 		return NULL;
 	}
 	}
+	if( size ) *size = (int)ssize;
 	return out;
 	return out;
 }
 }
 
 

+ 6 - 6
libs/ssl/ssl.vcxproj

@@ -179,7 +179,7 @@
     <LinkIncremental>true</LinkIncremental>
     <LinkIncremental>true</LinkIncremental>
     <TargetExt>.hdll</TargetExt>
     <TargetExt>.hdll</TargetExt>
     <LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;../../x64/$(Configuration)</LibraryPath>
     <LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;../../x64/$(Configuration)</LibraryPath>
-    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../../src</IncludePath>
+    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../../src;../../include/mbedtls/include</IncludePath>
   </PropertyGroup>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <LinkIncremental>false</LinkIncremental>
     <LinkIncremental>false</LinkIncremental>
@@ -197,13 +197,13 @@
     <LinkIncremental>false</LinkIncremental>
     <LinkIncremental>false</LinkIncremental>
     <TargetExt>.hdll</TargetExt>
     <TargetExt>.hdll</TargetExt>
     <LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;../../x64/$(Configuration)</LibraryPath>
     <LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;../../x64/$(Configuration)</LibraryPath>
-    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../../src</IncludePath>
+    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../../src;../../include/mbedtls/include</IncludePath>
   </PropertyGroup>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|x64'">
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|x64'">
     <LinkIncremental>false</LinkIncremental>
     <LinkIncremental>false</LinkIncremental>
     <TargetExt>.hdll</TargetExt>
     <TargetExt>.hdll</TargetExt>
     <LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;../../x64/$(Configuration)</LibraryPath>
     <LibraryPath>$(VC_LibraryPath_x64);$(WindowsSDK_LibraryPath_x64);$(NETFXKitsDir)Lib\um\x64;../../x64/$(Configuration)</LibraryPath>
-    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../../src</IncludePath>
+    <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../../src;../../include/mbedtls/include</IncludePath>
   </PropertyGroup>
   </PropertyGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
     <ClCompile>
@@ -231,7 +231,7 @@
     <Link>
     <Link>
       <SubSystem>Windows</SubSystem>
       <SubSystem>Windows</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>std.lib;user32.lib;gdi32.lib</AdditionalDependencies>
+      <AdditionalDependencies>libhl.lib;user32.lib;gdi32.lib;ws2_32.lib;advapi32.lib;crypt32.lib</AdditionalDependencies>
     </Link>
     </Link>
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@@ -287,7 +287,7 @@
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <OptimizeReferences>true</OptimizeReferences>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>std.lib;user32.lib;gdi32.lib</AdditionalDependencies>
+      <AdditionalDependencies>libhl.lib;user32.lib;gdi32.lib;ws2_32.lib;advapi32.lib;crypt32.lib</AdditionalDependencies>
     </Link>
     </Link>
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|x64'">
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|x64'">
@@ -305,7 +305,7 @@
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
       <OptimizeReferences>true</OptimizeReferences>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>std.lib;user32.lib;gdi32.lib</AdditionalDependencies>
+      <AdditionalDependencies>libhl.lib;user32.lib;gdi32.lib;ws2_32.lib;advapi32.lib;crypt32.lib</AdditionalDependencies>
     </Link>
     </Link>
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />