Support for multiple package URLs added
Packages are verified against SHA1 hash instead of signature now
This commit is contained in:
parent
453a1c08e2
commit
bdf071f5d7
@ -199,8 +199,8 @@ int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In
|
|||||||
// Iterate over packages.
|
// Iterate over packages.
|
||||||
wxUint32 versionMax = 0;
|
wxUint32 versionMax = 0;
|
||||||
wxString versionStrMax;
|
wxString versionStrMax;
|
||||||
wxString urlMax;
|
std::vector<wxString> urlsMax;
|
||||||
std::vector<BYTE> sigMax;
|
std::vector<BYTE> hashMax;
|
||||||
for (wxXmlNode *elPackage = elRoot->GetChildren(); elPackage; elPackage = elPackage->GetNext()) {
|
for (wxXmlNode *elPackage = elRoot->GetChildren(); elPackage; elPackage = elPackage->GetNext()) {
|
||||||
if (elPackage->GetType() == wxXML_ELEMENT_NODE && elPackage->GetName() == wxT("Package")) {
|
if (elPackage->GetType() == wxXML_ELEMENT_NODE && elPackage->GetName() == wxT("Package")) {
|
||||||
// Get package version.
|
// Get package version.
|
||||||
@ -235,8 +235,8 @@ int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In
|
|||||||
platformId += wxT("-x86");
|
platformId += wxT("-x86");
|
||||||
#endif
|
#endif
|
||||||
wxString languageId(initializer.m_locale.GetCanonicalName());
|
wxString languageId(initializer.m_locale.GetCanonicalName());
|
||||||
wxString url;
|
std::vector<wxString> urls;
|
||||||
std::vector<BYTE> sig;
|
std::vector<BYTE> hash;
|
||||||
for (wxXmlNode *elDownloads = elPackage->GetChildren(); elDownloads; elDownloads = elDownloads->GetNext()) {
|
for (wxXmlNode *elDownloads = elPackage->GetChildren(); elDownloads; elDownloads = elDownloads->GetNext()) {
|
||||||
if (elDownloads->GetType() == wxXML_ELEMENT_NODE && elDownloads->GetName() == wxT("Downloads")) {
|
if (elDownloads->GetType() == wxXML_ELEMENT_NODE && elDownloads->GetName() == wxT("Downloads")) {
|
||||||
for (wxXmlNode *elPlatform = elDownloads->GetChildren(); elPlatform; elPlatform = elPlatform->GetNext()) {
|
for (wxXmlNode *elPlatform = elDownloads->GetChildren(); elPlatform; elPlatform = elPlatform->GetNext()) {
|
||||||
@ -249,12 +249,12 @@ int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In
|
|||||||
if (elLocaleNote->GetType() == wxXML_ELEMENT_NODE) {
|
if (elLocaleNote->GetType() == wxXML_ELEMENT_NODE) {
|
||||||
const wxString &name = elLocaleNote->GetName();
|
const wxString &name = elLocaleNote->GetName();
|
||||||
if (name == wxT("url"))
|
if (name == wxT("url"))
|
||||||
url = elLocaleNote->GetNodeContent();
|
urls.push_back(elLocaleNote->GetNodeContent());
|
||||||
else if (name == wxT("signature")) {
|
else if (name == wxT("hash")) {
|
||||||
// Read the signature.
|
// Read the hash.
|
||||||
wxString content(elLocaleNote->GetNodeContent());
|
wxString content(elLocaleNote->GetNodeContent());
|
||||||
sig.resize(wxBase64DecodedSize(content.length()));
|
hash.resize(wxHexDecodedSize(content.length()));
|
||||||
size_t res = wxBase64Decode(sig.data(), sig.capacity(), content, wxBase64DecodeMode_SkipWS);
|
size_t res = wxHexDecode(sig.data(), sig.capacity(), content, wxHexDecodeMode_SkipWS);
|
||||||
if (res != wxCONV_FAILED)
|
if (res != wxCONV_FAILED)
|
||||||
sig.resize(res);
|
sig.resize(res);
|
||||||
else
|
else
|
||||||
@ -269,21 +269,21 @@ int CALLBACK WinMain(_In_ HINSTANCE hInstance, _In_ HINSTANCE hPrevInstance, _In
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (url.IsEmpty() || sig.empty()) {
|
if (urls.empty() || hash.empty()) {
|
||||||
// This package is for different architecture and/or language.
|
// This package is for different architecture and/or language.
|
||||||
// ... or missing URL and/or signature.
|
// ... or missing URL and/or hash.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
versionMax = version;
|
versionMax = version;
|
||||||
versionStrMax = versionStr;
|
versionStrMax = versionStr;
|
||||||
urlMax = url;
|
urlsMax = urls;
|
||||||
sigMax = sig;
|
hashMax = hash;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (versionMax) {
|
if (versionMax) {
|
||||||
wxLogMessage(wxT("Update package found (version: %s, URL: %s)."), versionStrMax.c_str(), urlMax.c_str());
|
wxLogMessage(wxT("Update package found (version: %s)."), versionStrMax.c_str());
|
||||||
|
|
||||||
|
|
||||||
} else
|
} else
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
#include <wxex/common.h>
|
#include <wxex/common.h>
|
||||||
#include <wxex/crypto.h>
|
#include <wxex/crypto.h>
|
||||||
|
#include <wxex/hex.h>
|
||||||
#include <wxex/xml.h>
|
#include <wxex/xml.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user