diff --git a/.gitmodules b/.gitmodules index aaec02a6..dd289153 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "3rdparty/openssl"] path = 3rdparty/openssl url = https://github.com/openssl/openssl.git +[submodule "3rdparty/ed25519"] + path = 3rdparty/ed25519 + url = https://github.com/orlp/ed25519.git diff --git a/3rdparty/dependencies.bkl b/3rdparty/dependencies.bkl index 579d948e..3ed56e6a 100644 --- a/3rdparty/dependencies.bkl +++ b/3rdparty/dependencies.bkl @@ -11,5 +11,6 @@ template t_3rdparty { submodule expat.bkl; submodule libcrypto.bkl; submodule wxWidgets.bkl; +submodule ed25519.bkl; msvs.generate-solution = false; diff --git a/3rdparty/ed25519 b/3rdparty/ed25519 new file mode 160000 index 00000000..7fa6712e --- /dev/null +++ b/3rdparty/ed25519 @@ -0,0 +1 @@ +Subproject commit 7fa6712ef5d581a6981ec2b08ee623314cd1d1c4 diff --git a/3rdparty/ed25519.bkl b/3rdparty/ed25519.bkl new file mode 100644 index 00000000..e802058d --- /dev/null +++ b/3rdparty/ed25519.bkl @@ -0,0 +1,31 @@ + +srcdir ed25519/src; + +msvs.generate-solution = false; + +library WinSparkle_ed25519 : t_3rdparty { + msvs.projectfile = ../../ed25519.vcxproj; + + headers { + ed25519.h + fe.h + fixedint.h + ge.h + precomp_data.h + sc.h + sha512.h + } + + sources { + add_scalar.c + fe.c + ge.c + key_exchange.c + keypair.c + sc.c + seed.c + sha512.c + sign.c + verify.c + } +} diff --git a/3rdparty/ed25519.vcxproj b/3rdparty/ed25519.vcxproj new file mode 100644 index 00000000..1346db2a --- /dev/null +++ b/3rdparty/ed25519.vcxproj @@ -0,0 +1,283 @@ + + + + + + Debug + ARM64 + + + Debug + Win32 + + + Debug + x64 + + + Release + ARM64 + + + Release + Win32 + + + Release + x64 + + + + {6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2} + Win32Proj + WinSparkle_ed25519 + WinSparkle_ed25519 + + + + StaticLibrary + true + Unicode + v110 + v120 + v140 + v141 + v142 + v143 + false + + + StaticLibrary + true + Unicode + v110 + v120 + v140 + v141 + v142 + v143 + false + + + StaticLibrary + true + Unicode + v110 + v120 + v140 + v141 + v142 + v143 + false + + + StaticLibrary + false + Unicode + v110 + v120 + v140 + v141 + v142 + v143 + false + true + + + StaticLibrary + false + Unicode + v110 + v120 + v140 + v141 + v142 + v143 + false + true + + + StaticLibrary + false + Unicode + v110 + v120 + v140 + v141 + v142 + v143 + false + true + + + + + + + + + + + + + + + + + + + + + + + + + ..\$(Configuration)\WinSparkle_ed25519\ + + + ..\$(Platform)\$(Configuration)\WinSparkle_ed25519\ + + + ..\$(Configuration)\WinSparkle_ed25519\ + + + ..\$(Platform)\$(Configuration)\WinSparkle_ed25519\ + + + + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + false + MultiThreadedDebug + /Zc:threadSafeInit- %(AdditionalOptions) + NoExtensions + + + Windows + true + + + + + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + false + MultiThreadedDebug + + + Windows + true + + + + + Level3 + Disabled + _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + false + MultiThreadedDebug + + + Windows + true + + + + + Level3 + MinSpace + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + false + MultiThreaded + /Zc:threadSafeInit- %(AdditionalOptions) + NoExtensions + Size + true + true + + + Windows + true + true + true + UseLinkTimeCodeGeneration + + + + + Level3 + MinSpace + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + false + MultiThreaded + Size + true + true + + + Windows + true + true + true + UseLinkTimeCodeGeneration + + + + + Level3 + MinSpace + true + true + _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + false + MultiThreaded + Size + true + true + + + Windows + true + true + true + UseLinkTimeCodeGeneration + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/3rdparty/ed25519.vcxproj.filters b/3rdparty/ed25519.vcxproj.filters new file mode 100644 index 00000000..fec2ec73 --- /dev/null +++ b/3rdparty/ed25519.vcxproj.filters @@ -0,0 +1,74 @@ + + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + diff --git a/3rdparty/expat.vcxproj b/3rdparty/expat.vcxproj index 63fdd9ec..78094e42 100644 --- a/3rdparty/expat.vcxproj +++ b/3rdparty/expat.vcxproj @@ -39,10 +39,10 @@ StaticLibrary true Unicode - v110_xp - v120_xp - v140_xp - v141_xp + v110 + v120 + v140 + v141 v142 v143 false @@ -75,10 +75,10 @@ StaticLibrary false Unicode - v110_xp - v120_xp - v140_xp - v141_xp + v110 + v120 + v140 + v141 v142 v143 false @@ -132,19 +132,20 @@ - + ..\$(Configuration)\WinSparkle_expat\ - + ..\$(Platform)\$(Configuration)\WinSparkle_expat\ ..\$(Platform)\$(Configuration)\WinSparkle_expat\ + $(SolutionDir)$(Platform)\$(Configuration)\ ..\$(Configuration)\WinSparkle_expat\ - + ..\$(Platform)\$(Configuration)\WinSparkle_expat\ @@ -158,9 +159,8 @@ true false MultiThreadedDebug - /Zc:threadSafeInit- %(AdditionalOptions) - /Zc:threadSafeInit- %(AdditionalOptions) - NoExtensions + /Zc:threadSafeInit- %(AdditionalOptions) + NoExtensions Windows @@ -205,9 +205,8 @@ true false MultiThreaded - /Zc:threadSafeInit- %(AdditionalOptions) - /Zc:threadSafeInit- %(AdditionalOptions) - NoExtensions + /Zc:threadSafeInit- %(AdditionalOptions) + NoExtensions Size true true diff --git a/3rdparty/libcrypto.vcxproj b/3rdparty/libcrypto.vcxproj index 9e27a45b..6bbaf53c 100644 --- a/3rdparty/libcrypto.vcxproj +++ b/3rdparty/libcrypto.vcxproj @@ -39,10 +39,10 @@ StaticLibrary true Unicode - v110_xp - v120_xp - v140_xp - v141_xp + v110 + v120 + v140 + v141 v142 v143 false @@ -75,10 +75,10 @@ StaticLibrary false Unicode - v110_xp - v120_xp - v140_xp - v141_xp + v110 + v120 + v140 + v141 v142 v143 false @@ -132,19 +132,20 @@ - + ..\$(Configuration)\WinSparkle_libcrypto\ - + ..\$(Platform)\$(Configuration)\WinSparkle_libcrypto\ ..\$(Platform)\$(Configuration)\WinSparkle_libcrypto\ + $(SolutionDir)$(Platform)\$(Configuration)\ ..\$(Configuration)\WinSparkle_libcrypto\ - + ..\$(Platform)\$(Configuration)\WinSparkle_libcrypto\ @@ -159,9 +160,8 @@ false openssl-win32;openssl-win32\openssl;%(AdditionalIncludeDirectories) MultiThreadedDebug - /Zc:threadSafeInit- %(AdditionalOptions) - /Zc:threadSafeInit- %(AdditionalOptions) - NoExtensions + /Zc:threadSafeInit- %(AdditionalOptions) + NoExtensions Windows @@ -209,9 +209,8 @@ false openssl-win32;openssl-win32\openssl;%(AdditionalIncludeDirectories) MultiThreaded - /Zc:threadSafeInit- %(AdditionalOptions) - /Zc:threadSafeInit- %(AdditionalOptions) - NoExtensions + /Zc:threadSafeInit- %(AdditionalOptions) + NoExtensions Size true true @@ -639,4 +638,4 @@ - \ No newline at end of file + diff --git a/3rdparty/libcrypto.vcxproj.filters b/3rdparty/libcrypto.vcxproj.filters index 650a5892..80581717 100644 --- a/3rdparty/libcrypto.vcxproj.filters +++ b/3rdparty/libcrypto.vcxproj.filters @@ -1110,4 +1110,4 @@ Source Files - \ No newline at end of file + diff --git a/3rdparty/wx.vcxproj b/3rdparty/wx.vcxproj index 4a5ac1be..7c46631f 100644 --- a/3rdparty/wx.vcxproj +++ b/3rdparty/wx.vcxproj @@ -33,17 +33,17 @@ Win32Proj WinSparkle_wx WinSparkle_wx - 10.0 + 10.0 StaticLibrary true Unicode - v110_xp - v120_xp - v140_xp - v141_xp + v110 + v120 + v140 + v141 v142 v143 false @@ -76,10 +76,10 @@ StaticLibrary false Unicode - v110_xp - v120_xp - v140_xp - v141_xp + v110 + v120 + v140 + v141 v142 v143 false @@ -133,19 +133,20 @@ - + ..\$(Configuration)\WinSparkle_wx\ - + ..\$(Platform)\$(Configuration)\WinSparkle_wx\ ..\$(Platform)\$(Configuration)\WinSparkle_wx\ + $(SolutionDir)$(Platform)\$(Configuration)\ ..\$(Configuration)\WinSparkle_wx\ - + ..\$(Platform)\$(Configuration)\WinSparkle_wx\ @@ -160,9 +161,8 @@ false wxWidgets_setup_h;wxWidgets\include;%(AdditionalIncludeDirectories) MultiThreadedDebug - /Zc:threadSafeInit- %(AdditionalOptions) - /Zc:threadSafeInit- %(AdditionalOptions) - NoExtensions + /Zc:threadSafeInit- %(AdditionalOptions) + NoExtensions Windows @@ -210,9 +210,8 @@ false wxWidgets_setup_h;wxWidgets\include;%(AdditionalIncludeDirectories) MultiThreaded - /Zc:threadSafeInit- %(AdditionalOptions) - /Zc:threadSafeInit- %(AdditionalOptions) - NoExtensions + /Zc:threadSafeInit- %(AdditionalOptions) + NoExtensions Size true true @@ -478,4 +477,4 @@ - \ No newline at end of file + diff --git a/3rdparty/wx.vcxproj.filters b/3rdparty/wx.vcxproj.filters index 3dff3ec7..5afb618f 100644 --- a/3rdparty/wx.vcxproj.filters +++ b/3rdparty/wx.vcxproj.filters @@ -581,4 +581,4 @@ - \ No newline at end of file + diff --git a/WinSparkle.bkl b/WinSparkle.bkl index cb5c1ff4..bf45995b 100644 --- a/WinSparkle.bkl +++ b/WinSparkle.bkl @@ -48,6 +48,9 @@ shared-library WinSparkle { includedirs += 3rdparty/wxWidgets_setup_h 3rdparty/wxWidgets/include; deps += WinSparkle_wx; + includedirs += 3rdparty/ed25519/src; + deps += WinSparkle_ed25519; + libs += comctl32 kernel32 user32 comctl32 rpcrt4 version wininet shlwapi; defines += BUILDING_WIN_SPARKLE; diff --git a/WinSparkle.sln b/WinSparkle.sln index b8c35140..16c347cc 100644 --- a/WinSparkle.sln +++ b/WinSparkle.sln @@ -23,6 +23,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example_psdk", "examples\ex EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dependencies", "dependencies", "{2C4E4846-FF11-55AD-AFD1-BC1F3AF74724}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinSparkle_ed25519", "3rdparty\ed25519.vcxproj", "{6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|ARM64 = Debug|ARM64 @@ -93,6 +95,18 @@ Global {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|Win32.Build.0 = Release|Win32 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|x64.ActiveCfg = Release|x64 {AFBD6C55-82AB-5746-BABD-D254BE893418}.Release|x64.Build.0 = Release|x64 + {6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2}.Debug|ARM64.Build.0 = Debug|ARM64 + {6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2}.Debug|Win32.ActiveCfg = Debug|Win32 + {6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2}.Debug|Win32.Build.0 = Debug|Win32 + {6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2}.Debug|x64.ActiveCfg = Debug|x64 + {6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2}.Debug|x64.Build.0 = Debug|x64 + {6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2}.Release|ARM64.ActiveCfg = Release|ARM64 + {6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2}.Release|ARM64.Build.0 = Release|ARM64 + {6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2}.Release|Win32.ActiveCfg = Release|Win32 + {6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2}.Release|Win32.Build.0 = Release|Win32 + {6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2}.Release|x64.ActiveCfg = Release|x64 + {6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -101,6 +115,7 @@ Global {47B228CB-24FE-5250-B1FC-DFC81D3E69DF} = {2C4E4846-FF11-55AD-AFD1-BC1F3AF74724} {A0326E8B-57A0-548E-AB4A-2DB2B6704D70} = {2C4E4846-FF11-55AD-AFD1-BC1F3AF74724} {499A5238-5AAC-5FD3-8902-819D787108A5} = {2C4E4846-FF11-55AD-AFD1-BC1F3AF74724} + {6A5FB0FA-2A9C-5A84-AA43-7814DC08D5B2} = {2C4E4846-FF11-55AD-AFD1-BC1F3AF74724} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {737E8E06-943F-41A9-A859-EB2CD4CE0C79} diff --git a/WinSparkle.vcxproj b/WinSparkle.vcxproj index 3830ce2c..2e376e3f 100644 --- a/WinSparkle.vcxproj +++ b/WinSparkle.vcxproj @@ -34,17 +34,17 @@ Win32Proj WinSparkle WinSparkle - 10.0 + 10.0 DynamicLibrary true Unicode - v110_xp - v120_xp - v140_xp - v141_xp + v110 + v120 + v140 + v141 v142 v143 false @@ -77,10 +77,10 @@ DynamicLibrary false Unicode - v110_xp - v120_xp - v140_xp - v141_xp + v110 + v120 + v140 + v141 v142 v143 false @@ -113,7 +113,8 @@ true - + + @@ -141,6 +142,7 @@ true + $(SolutionDir)$(Platform)\$(Configuration)\ false @@ -158,14 +160,13 @@ _CRT_SECURE_NO_WARNINGS;XML_STATIC;BUILDING_WIN_SPARKLE;WIN32;_DEBUG;WINSPARKLE_EXPORTS;%(PreprocessorDefinitions) true false - 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;include;%(AdditionalIncludeDirectories) + 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;3rdparty\ed25519\src;include;%(AdditionalIncludeDirectories) MultiThreadedDebug - /Zc:threadSafeInit- %(AdditionalOptions) - /Zc:threadSafeInit- %(AdditionalOptions) - NoExtensions + /Zc:threadSafeInit- %(AdditionalOptions) + NoExtensions - 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;include;%(AdditionalIncludeDirectories) + 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;3rdparty\ed25519\src;include;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;XML_STATIC;BUILDING_WIN_SPARKLE;_UNICODE;UNICODE;_DEBUG;%(PreprocessorDefinitions) @@ -181,11 +182,11 @@ _CRT_SECURE_NO_WARNINGS;XML_STATIC;BUILDING_WIN_SPARKLE;WIN32;_DEBUG;WINSPARKLE_EXPORTS;%(PreprocessorDefinitions) true false - 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;include;%(AdditionalIncludeDirectories) + 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;3rdparty\ed25519\src;include;%(AdditionalIncludeDirectories) MultiThreadedDebug - 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;include;%(AdditionalIncludeDirectories) + 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;3rdparty\ed25519\src;include;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;XML_STATIC;BUILDING_WIN_SPARKLE;_UNICODE;UNICODE;_DEBUG;%(PreprocessorDefinitions) @@ -201,7 +202,7 @@ _CRT_SECURE_NO_WARNINGS;XML_STATIC;BUILDING_WIN_SPARKLE;WIN32;_DEBUG;WINSPARKLE_EXPORTS;%(PreprocessorDefinitions) true false - 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;include;%(AdditionalIncludeDirectories) + 3rdparty\expat\expat\lib;3rdparty\ed25519\src;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;include;%(AdditionalIncludeDirectories) MultiThreadedDebug @@ -223,17 +224,16 @@ _CRT_SECURE_NO_WARNINGS;XML_STATIC;BUILDING_WIN_SPARKLE;WIN32;NDEBUG;WINSPARKLE_EXPORTS;%(PreprocessorDefinitions) true false - 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;include;%(AdditionalIncludeDirectories) + 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;3rdparty\ed25519\src;include;%(AdditionalIncludeDirectories) MultiThreaded - /Zc:threadSafeInit- %(AdditionalOptions) - /Zc:threadSafeInit- %(AdditionalOptions) - NoExtensions + /Zc:threadSafeInit- %(AdditionalOptions) + NoExtensions Size true true - 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;include;%(AdditionalIncludeDirectories) + 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;3rdparty\ed25519\src;include;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;XML_STATIC;BUILDING_WIN_SPARKLE;_UNICODE;UNICODE;NDEBUG;%(PreprocessorDefinitions) @@ -254,14 +254,14 @@ _CRT_SECURE_NO_WARNINGS;XML_STATIC;BUILDING_WIN_SPARKLE;WIN32;NDEBUG;WINSPARKLE_EXPORTS;%(PreprocessorDefinitions) true false - 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;include;%(AdditionalIncludeDirectories) + 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;3rdparty\ed25519\src;include;%(AdditionalIncludeDirectories) MultiThreaded Size true true - 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;include;%(AdditionalIncludeDirectories) + 3rdparty\expat\expat\lib;3rdparty\openssl-win32;3rdparty\wxWidgets_setup_h;3rdparty\wxWidgets\include;3rdparty\ed25519\src;include;%(AdditionalIncludeDirectories) _CRT_SECURE_NO_WARNINGS;XML_STATIC;BUILDING_WIN_SPARKLE;_UNICODE;UNICODE;NDEBUG;%(PreprocessorDefinitions) @@ -334,25 +334,18 @@ - - - - Designer - - {47b228cb-24fe-5250-b1fc-dfc81d3e69df} - false - true {a0326e8b-57a0-548e-ab4a-2db2b6704d70} {499a5238-5aac-5fd3-8902-819d787108a5} - false - true + + + {6a5fb0fa-2a9c-5a84-aa43-7814dc08d5b2} diff --git a/WinSparkle.vcxproj.filters b/WinSparkle.vcxproj.filters index bcc3e42e..cb53c229 100644 --- a/WinSparkle.vcxproj.filters +++ b/WinSparkle.vcxproj.filters @@ -103,8 +103,4 @@ Resource Files - - - - - \ No newline at end of file + diff --git a/examples/example_psdk.vcxproj b/examples/example_psdk.vcxproj index 60d004ae..d04cdc00 100644 --- a/examples/example_psdk.vcxproj +++ b/examples/example_psdk.vcxproj @@ -111,7 +111,8 @@ true - + + @@ -139,6 +140,7 @@ true + $(SolutionDir)$(Platform)\$(Configuration)\ false @@ -302,9 +304,6 @@ {524cccf2-61ea-5b64-a1d9-ff5497027b5f} - - - - \ No newline at end of file + diff --git a/examples/example_psdk.vcxproj.filters b/examples/example_psdk.vcxproj.filters index 261cac7b..9b60fef3 100644 --- a/examples/example_psdk.vcxproj.filters +++ b/examples/example_psdk.vcxproj.filters @@ -26,7 +26,4 @@ Resource Files - - - diff --git a/include/winsparkle.h b/include/winsparkle.h index 5a614187..39f15fce 100644 --- a/include/winsparkle.h +++ b/include/winsparkle.h @@ -185,6 +185,25 @@ WIN_SPARKLE_API void __cdecl win_sparkle_set_appcast_url(const char *url); */ WIN_SPARKLE_API int __cdecl win_sparkle_set_dsa_pub_pem(const char *dsa_pub_pem); +/** + Sets EdDSA public key. + + Only base64 encoded format is supported. + + Public key will be used to verify EdDSA signature of the update file. + It will be set only if it contains valid EdDSA public key. + + If this function isn't called by the app, public key is obtained from + Windows resource named "EdDSAPub" of type "EDDSA". + + @param eddsa_pub_base64 EdDSA public key in base64 encoded format. + + @return 1 if valid EdDSA public key provided, 0 otherwise. + + @since 0.8.0 + */ +WIN_SPARKLE_API int __cdecl win_sparkle_set_eddsa_pub_base64(const char* eddsa_pub_base64); + /** Sets application metadata. diff --git a/src/appcast.cpp b/src/appcast.cpp index 9e5279e0..0cf311d4 100644 --- a/src/appcast.cpp +++ b/src/appcast.cpp @@ -61,11 +61,13 @@ namespace #define ATTR_VERSION NS_SPARKLE_NAME("version") #define ATTR_SHORTVERSION NS_SPARKLE_NAME("shortVersionString") #define ATTR_DSASIGNATURE NS_SPARKLE_NAME("dsaSignature") +#define ATTR_EDDSASIGNATURE NS_SPARKLE_NAME("edSignature") #define ATTR_OS NS_SPARKLE_NAME("os") #define ATTR_ARGUMENTS NS_SPARKLE_NAME("installerArguments") #define NODE_VERSION ATTR_VERSION // These can be nodes or #define NODE_SHORTVERSION ATTR_SHORTVERSION // attributes. #define NODE_DSASIGNATURE ATTR_DSASIGNATURE +#define NODE_EDDSASIGNATURE ATTR_EDDSASIGNATURE #define OS_MARKER "windows" #define OS_MARKER_LEN 7 @@ -75,7 +77,7 @@ struct ContextData ContextData(XML_Parser& p) : parser(p), in_channel(0), in_item(0), in_relnotes(0), in_title(0), in_description(0), in_link(0), - in_version(0), in_shortversion(0), in_dsasignature(0), in_min_os_version(0) + in_version(0), in_shortversion(0), in_dsasignature(0), in_eddsasignature(0), in_min_os_version(0) {} // the parser we're using @@ -85,7 +87,7 @@ struct ContextData int in_channel, in_item, in_relnotes, in_title, in_description, in_link; // is inside or node? - int in_version, in_shortversion, in_dsasignature, in_min_os_version; + int in_version, in_shortversion, in_dsasignature, in_eddsasignature, in_min_os_version; // parsed s std::vector items; @@ -155,6 +157,10 @@ void XMLCALL OnStartElement(void *data, const char *name, const char **attrs) { ctxt.in_dsasignature++; } + else if (strcmp(name, NODE_EDDSASIGNATURE) == 0) + { + ctxt.in_eddsasignature++; + } else if (strcmp(name, NODE_MIN_OS_VERSION) == 0) { ctxt.in_min_os_version++; @@ -177,6 +183,8 @@ void XMLCALL OnStartElement(void *data, const char *name, const char **attrs) item.ShortVersionString = value; else if (strcmp(name, ATTR_DSASIGNATURE) == 0) item.DsaSignature = value; + else if (strcmp(name, ATTR_EDDSASIGNATURE) == 0) + item.EdDsaSignature = value; else if (strcmp(name, ATTR_OS) == 0) item.Os = value; else if (strcmp(name, ATTR_ARGUMENTS) == 0) @@ -268,6 +276,10 @@ void XMLCALL OnEndElement(void *data, const char *name) { ctxt.in_dsasignature--; } + else if (strcmp(name, NODE_EDDSASIGNATURE) == 0) + { + ctxt.in_eddsasignature--; + } } else if (ctxt.in_channel && strcmp(name, NODE_ITEM) == 0) { @@ -323,6 +335,10 @@ void XMLCALL OnText(void *data, const char *s, int len) { item.DsaSignature.append(s, len); } + else if (ctxt.in_eddsasignature) + { + item.EdDsaSignature.append(s, len); + } else if (ctxt.in_min_os_version) { item.MinOSVersion.append(s, len); diff --git a/src/appcast.h b/src/appcast.h index 359dc9c3..8efacda0 100644 --- a/src/appcast.h +++ b/src/appcast.h @@ -43,9 +43,12 @@ struct Appcast /// URL of the update std::string DownloadURL; - /// Signing signature of the update + /// Signing DSA signature of the update std::string DsaSignature; + /// Signing EdDSA signature of the update + std::string EdDsaSignature; + /// URL of the release notes page std::string ReleaseNotesURL; diff --git a/src/dll_api.cpp b/src/dll_api.cpp index 65560e71..ed1d069d 100644 --- a/src/dll_api.cpp +++ b/src/dll_api.cpp @@ -161,6 +161,17 @@ WIN_SPARKLE_API int __cdecl win_sparkle_set_dsa_pub_pem(const char *dsa_pub_pem) return 0; } +WIN_SPARKLE_API int __cdecl win_sparkle_set_eddsa_pub_base64(const char* eddsa_pub_base64) +{ + try + { + Settings::SetEdDSAPubKey(eddsa_pub_base64); + return 1; + } + CATCH_ALL_EXCEPTIONS + return 0; +} + WIN_SPARKLE_API void __cdecl win_sparkle_set_app_details(const wchar_t *company_name, const wchar_t *app_name, const wchar_t *app_version) diff --git a/src/settings.cpp b/src/settings.cpp index 610eee73..d4d4a39d 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -43,6 +43,7 @@ std::wstring Settings::ms_appName; std::wstring Settings::ms_appVersion; std::wstring Settings::ms_appBuildVersion; std::string Settings::ms_DSAPubKey; +std::string Settings::ms_EdDSAPubKey; std::map Settings::ms_httpHeaders; win_sparkle_config_methods_t Settings::ms_configMethods = GetDefaultConfigMethods(); @@ -351,4 +352,11 @@ void Settings::SetDSAPubKeyPem(const std::string &pem) ms_DSAPubKey = pem; } +void Settings::SetEdDSAPubKey(const std::string& pubkey_base64) +{ + CriticalSectionLocker lock(ms_csVars); + SignatureVerifier::VerifyEdDSAPubKey(pubkey_base64); + ms_EdDSAPubKey = pubkey_base64; +} + } // namespace winsparkle diff --git a/src/settings.h b/src/settings.h index aed922ad..2501c902 100644 --- a/src/settings.h +++ b/src/settings.h @@ -122,6 +122,15 @@ class Settings return ms_DSAPubKey; } + /// Return EdDSA public key to verify update file signature + static const std::string& GetEdDSAPubKey() + { + CriticalSectionLocker lock(ms_csVars); + if (ms_EdDSAPubKey.empty()) + ms_EdDSAPubKey = GetCustomResource("EdDSAPub", "EDDSA"); + return ms_EdDSAPubKey; + } + /// Return true if DSA public key is available static bool HasDSAPubKeyPem() { @@ -133,6 +142,17 @@ class Settings return false; } + /// Return true if EdDSA public key is available + static bool HasEdDSAPubKey() + { + try + { + return !GetEdDSAPubKey().empty(); + } + CATCH_ALL_EXCEPTIONS + return false; + } + //@} /** @@ -265,6 +285,9 @@ class Settings static void SetDSAPubKeyPem(const std::string &pem); //@} + /// Set PEM data and verify in contains valid EdDSA public key + static void SetEdDSAPubKey(const std::string& pubkey_base64); + //@} /** Access to runtime configuration. @@ -371,6 +394,7 @@ class Settings static std::wstring ms_appVersion; static std::wstring ms_appBuildVersion; static std::string ms_DSAPubKey; + static std::string ms_EdDSAPubKey; static std::map ms_httpHeaders; static win_sparkle_config_methods_t ms_configMethods; }; diff --git a/src/signatureverifier.cpp b/src/signatureverifier.cpp index d7c1e3de..b4105a11 100644 --- a/src/signatureverifier.cpp +++ b/src/signatureverifier.cpp @@ -34,7 +34,10 @@ #include #include +#include + #include +#include #include #include @@ -293,6 +296,14 @@ void SignatureVerifier::VerifyDSAPubKeyPem(const std::string &pem) (void)dsa_pub; } +void SignatureVerifier::VerifyEdDSAPubKey(const std::string& pubkey_base64) +{ + const std::string pubkey = Base64ToBin(Settings::GetEdDSAPubKey()); + if (pubkey.size() != 32) { + throw BadSignatureException("Invalid public key size."); + } +} + void SignatureVerifier::VerifyDSASHA1SignatureValid(const std::wstring &filename, const std::string &signature_base64) { try @@ -315,4 +326,44 @@ void SignatureVerifier::VerifyDSASHA1SignatureValid(const std::wstring &filename } } +void SignatureVerifier::VerifyEdDSASignatureValid(const std::wstring& filename, const std::string& signature_base64) +{ + if (signature_base64.size() == 0) + throw BadSignatureException("Missing EdDSA signature!"); + + CFile payload = _wfopen(filename.c_str(), L"rb"); + if (payload == nullptr) { + throw BadSignatureException("Could not open payload!"); + } + + DWORD size = GetFileSize(payload, NULL); + std::vector buffer; + buffer.resize(size); + size_t bytes_read = fread(buffer.data(), 1, size, payload); + if (bytes_read < size) { + throw BadSignatureException("Could not read payload!"); + } + fclose(payload); + + const std::string signature = Base64ToBin(signature_base64); + if (signature.size() != 64) { + throw BadSignatureException("Invalid signature size."); + } + + const std::string pubkey = Base64ToBin(Settings::GetEdDSAPubKey()); + if (pubkey.size() != 32) { + throw BadSignatureException("Invalid public key size."); + } + + int result = ed25519_verify(reinterpret_cast(signature.data()), + buffer.data(), + bytes_read, + reinterpret_cast(pubkey.data())); + + CloseHandle(payload); + + if (result != 1) + throw BadSignatureException(); +} + } // namespace winsparkle diff --git a/src/signatureverifier.h b/src/signatureverifier.h index 2d52613f..628de960 100644 --- a/src/signatureverifier.h +++ b/src/signatureverifier.h @@ -45,10 +45,17 @@ class SignatureVerifier // Throws an exception if pem is not a valid DSA public key in PEM format static void VerifyDSAPubKeyPem(const std::string &pem); + // Throws an exception if pem is not a valid EdDSA public key in base64 format + static void VerifyEdDSAPubKey(const std::string& pubkey_base64); + // Verify DSA signature of SHA1 hash of the file. Equivalent to: // openssl dgst -sha1 -binary < filename | openssl dgst -sha1 -verify dsa_pub.pem -signature signature.bin // Throws BadSignatureException on failure. static void VerifyDSASHA1SignatureValid(const std::wstring &filename, const std::string &signature_base64); + + // Verify EdDSA signature of the file. Equivalent to: + // Throws BadSignatureException on failure. + static void VerifyEdDSASignatureValid(const std::wstring& filename, const std::string& signature_base64); }; } // namespace winsparkle diff --git a/src/updatedownloader.cpp b/src/updatedownloader.cpp index ee37d82a..e77ccc68 100644 --- a/src/updatedownloader.cpp +++ b/src/updatedownloader.cpp @@ -180,7 +180,11 @@ void UpdateDownloader::Run() DownloadFile(m_appcast.DownloadURL, &sink, this); sink.Close(); - if (Settings::HasDSAPubKeyPem()) + if (Settings::HasEdDSAPubKey()) + { + SignatureVerifier::VerifyEdDSASignatureValid(sink.GetFilePath(), m_appcast.EdDsaSignature); + } + else if (Settings::HasDSAPubKeyPem()) { SignatureVerifier::VerifyDSASHA1SignatureValid(sink.GetFilePath(), m_appcast.DsaSignature); }