Skip to content

Commit

Permalink
Version 1.4.0: Fix beta to stable updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Sep 28, 2018
1 parent b66f32f commit 8c440cc
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions Telegram/SourceFiles/core/update_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,18 +398,15 @@ bool UnpackUpdate(const QString &filepath) {
}
if (RSA_verify(NID_sha1, (const uchar*)(compressed.constData() + hSigLen), hShaLen, (const uchar*)(compressed.constData()), hSigLen, pbKey) != 1) { // verify signature
RSA_free(pbKey);
if (cInstallBetaVersion() || cAlphaVersion()) { // try other public key, if we are in beta or alpha version
pbKey = PEM_read_bio_RSAPublicKey(BIO_new_mem_buf(const_cast<char*>(AppBetaVersion ? UpdatesPublicKey : UpdatesPublicBetaKey), -1), 0, 0, 0);
if (!pbKey) {
LOG(("Update Error: cant read public rsa key!"));
return false;
}
if (RSA_verify(NID_sha1, (const uchar*)(compressed.constData() + hSigLen), hShaLen, (const uchar*)(compressed.constData()), hSigLen, pbKey) != 1) { // verify signature
RSA_free(pbKey);
LOG(("Update Error: bad RSA signature of update file!"));
return false;
}
} else {

// try other public key, if we update from beta to stable or vice versa
pbKey = PEM_read_bio_RSAPublicKey(BIO_new_mem_buf(const_cast<char*>(AppBetaVersion ? UpdatesPublicKey : UpdatesPublicBetaKey), -1), 0, 0, 0);
if (!pbKey) {
LOG(("Update Error: cant read public rsa key!"));
return false;
}
if (RSA_verify(NID_sha1, (const uchar*)(compressed.constData() + hSigLen), hShaLen, (const uchar*)(compressed.constData()), hSigLen, pbKey) != 1) { // verify signature
RSA_free(pbKey);
LOG(("Update Error: bad RSA signature of update file!"));
return false;
}
Expand Down

0 comments on commit 8c440cc

Please sign in to comment.