Merge pull request #133 from libtom/pr/msvc-fixes

Fixes for #131 + #132 (MSVC related)
This commit is contained in:
karel-m 2018-12-08 17:42:27 +01:00 committed by GitHub
commit 9ff526fa22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 28 deletions

19
.gitignore vendored
View File

@ -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

6
bn_mp_exptmod_fast.c Normal file → Executable file
View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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

View File

@ -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>
@ -36,9 +36,6 @@
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
@ -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"
@ -112,9 +109,6 @@
<Tool
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"
@ -189,9 +183,6 @@
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
@ -236,7 +227,7 @@
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile="$(OutDir)\libtommath.bsc"
OutputFile="$(OutDir)\tommath.bsc"
/>
<Tool
Name="VCFxCopTool"
@ -263,9 +254,6 @@
<Tool
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"