Commit 9ff526fa2218f8697dcd0c9821330fa04682eb75

karel-m 2018-12-08T17:42:27

Merge pull request #133 from libtom/pr/msvc-fixes Fixes for #131 + #132 (MSVC related)

diff --git a/.gitignore b/.gitignore
index 20e85c3..d5a7b5b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,6 +33,25 @@ mtest.exe
 # ignore user specific settings
 *.user
 *.suo
+*.userosscache
+*.sln.docstates
+*.userprefs
+# cache/options directory
+.vs/
+# Backup & report files from converting an old project file to a newer Visual Studio version
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+# Visual Studio 6 build log + workspace options file
+*.plg
+*.opt
+# visual studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
 
 # ignore stuff generated by "make manual" and "make poster"
 *.aux
diff --git a/bn_mp_exptmod_fast.c b/bn_mp_exptmod_fast.c
old mode 100644
new mode 100755
index 0d01e38..a63ebd5
--- a/bn_mp_exptmod_fast.c
+++ b/bn_mp_exptmod_fast.c
@@ -165,15 +165,15 @@ int mp_exptmod_fast(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y
    }
 
    /* compute the value at M[1<<(winsize-1)] by squaring M[1] (winsize-1) times */
-   if ((err = mp_copy(&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) {
+   if ((err = mp_copy(&M[1], &M[(size_t)1 << (winsize - 1)])) != MP_OKAY) {
       goto LBL_RES;
    }
 
    for (x = 0; x < (winsize - 1); x++) {
-      if ((err = mp_sqr(&M[1 << (winsize - 1)], &M[1 << (winsize - 1)])) != MP_OKAY) {
+      if ((err = mp_sqr(&M[(size_t)1 << (winsize - 1)], &M[(size_t)1 << (winsize - 1)])) != MP_OKAY) {
          goto LBL_RES;
       }
-      if ((err = redux(&M[1 << (winsize - 1)], P, mp)) != MP_OKAY) {
+      if ((err = redux(&M[(size_t)1 << (winsize - 1)], P, mp)) != MP_OKAY) {
          goto LBL_RES;
       }
    }
diff --git a/bn_s_mp_exptmod.c b/bn_s_mp_exptmod.c
index f84da21..52a6422 100644
--- a/bn_s_mp_exptmod.c
+++ b/bn_s_mp_exptmod.c
@@ -99,19 +99,19 @@ int s_mp_exptmod(const mp_int *G, const mp_int *X, const mp_int *P, mp_int *Y, i
    /* compute the value at M[1<<(winsize-1)] by squaring
     * M[1] (winsize-1) times
     */
-   if ((err = mp_copy(&M[1], &M[1 << (winsize - 1)])) != MP_OKAY) {
+   if ((err = mp_copy(&M[1], &M[(size_t)1 << (winsize - 1)])) != MP_OKAY) {
       goto LBL_MU;
    }
 
    for (x = 0; x < (winsize - 1); x++) {
       /* square it */
-      if ((err = mp_sqr(&M[1 << (winsize - 1)],
-                        &M[1 << (winsize - 1)])) != MP_OKAY) {
+      if ((err = mp_sqr(&M[(size_t)1 << (winsize - 1)],
+                        &M[(size_t)1 << (winsize - 1)])) != MP_OKAY) {
          goto LBL_MU;
       }
 
       /* reduce modulo P */
-      if ((err = redux(&M[1 << (winsize - 1)], P, &mu)) != MP_OKAY) {
+      if ((err = redux(&M[(size_t)1 << (winsize - 1)], P, &mu)) != MP_OKAY) {
          goto LBL_MU;
       }
    }
diff --git a/libtommath_VS2008.sln b/libtommath_VS2008.sln
index c592fe0..6bfc159 100644
--- a/libtommath_VS2008.sln
+++ b/libtommath_VS2008.sln
@@ -1,7 +1,7 @@
 
 Microsoft Visual Studio Solution File, Format Version 10.00
 # Visual Studio 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtommath", "libtommath_VS2008.vcproj", "{42109FEE-B0B9-4FCD-9E56-2863BF8C55D2}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tommath", "libtommath_VS2008.vcproj", "{42109FEE-B0B9-4FCD-9E56-2863BF8C55D2}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -23,4 +23,7 @@ Global
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {83B84178-7B4F-4B78-9C5D-17B8201D5B61}
+	EndGlobalSection
 EndGlobal
diff --git a/libtommath_VS2008.vcproj b/libtommath_VS2008.vcproj
index 98e2be4..26429c9 100644
--- a/libtommath_VS2008.vcproj
+++ b/libtommath_VS2008.vcproj
@@ -2,9 +2,9 @@
 <VisualStudioProject
 	ProjectType="Visual C++"
 	Version="9.00"
-	Name="libtommath"
+	Name="tommath"
 	ProjectGUID="{42109FEE-B0B9-4FCD-9E56-2863BF8C55D2}"
-	RootNamespace="libtommath"
+	RootNamespace="tommath"
 	TargetFrameworkVersion="0"
 	>
 	<Platforms>
@@ -37,9 +37,6 @@
 				Name="VCXMLDataGeneratorTool"
 			/>
 			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
 				Name="VCMIDLTool"
 			/>
 			<Tool
@@ -73,7 +70,7 @@
 			/>
 			<Tool
 				Name="VCLibrarianTool"
-				OutputFile="$(OutDir)\tommathd.lib"
+				OutputFile="$(OutDir)\tommath.lib"
 				SuppressStartupBanner="true"
 			/>
 			<Tool
@@ -85,7 +82,7 @@
 			<Tool
 				Name="VCBscMakeTool"
 				SuppressStartupBanner="true"
-				OutputFile="$(OutDir)\libtommath.bsc"
+				OutputFile="$(OutDir)\tommath.bsc"
 			/>
 			<Tool
 				Name="VCFxCopTool"
@@ -113,9 +110,6 @@
 				Name="VCXMLDataGeneratorTool"
 			/>
 			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
 				Name="VCMIDLTool"
 				TargetEnvironment="3"
 			/>
@@ -150,7 +144,7 @@
 			/>
 			<Tool
 				Name="VCLibrarianTool"
-				OutputFile="$(OutDir)\tommathd.lib"
+				OutputFile="$(OutDir)\tommath.lib"
 				SuppressStartupBanner="true"
 			/>
 			<Tool
@@ -162,7 +156,7 @@
 			<Tool
 				Name="VCBscMakeTool"
 				SuppressStartupBanner="true"
-				OutputFile="$(OutDir)\libtommath.bsc"
+				OutputFile="$(OutDir)\tommath.bsc"
 			/>
 			<Tool
 				Name="VCFxCopTool"
@@ -190,9 +184,6 @@
 				Name="VCXMLDataGeneratorTool"
 			/>
 			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
 				Name="VCMIDLTool"
 			/>
 			<Tool
@@ -236,7 +227,7 @@
 			<Tool
 				Name="VCBscMakeTool"
 				SuppressStartupBanner="true"
-				OutputFile="$(OutDir)\libtommath.bsc"
+				OutputFile="$(OutDir)\tommath.bsc"
 			/>
 			<Tool
 				Name="VCFxCopTool"
@@ -264,9 +255,6 @@
 				Name="VCXMLDataGeneratorTool"
 			/>
 			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
 				Name="VCMIDLTool"
 				TargetEnvironment="3"
 			/>
@@ -311,7 +299,7 @@
 			<Tool
 				Name="VCBscMakeTool"
 				SuppressStartupBanner="true"
-				OutputFile="$(OutDir)\libtommath.bsc"
+				OutputFile="$(OutDir)\tommath.bsc"
 			/>
 			<Tool
 				Name="VCFxCopTool"