VirtualBox

Changeset 65269 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Jan 12, 2017 7:13:14 PM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: when downloading an Extension Pack or Guest Additions, verify the hash sum automatically

Location:
trunk/src/VBox/Frontends/VirtualBox/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp

    r65268 r65269  
    21722172             "from <nobr><a href=\"%1\">%1</a></nobr> "
    21732173             "and saved locally as <nobr><b>%2</b>, </nobr>"
    2174              "but the SHA-256 checksum verification failed.</p>"
     2174             "but SHA-256 checksum verification failed.</p>"
    21752175             "<p>Please do the download, installation and verification manually.</p>")
    21762176             .arg(strUrl, strSrc));
     
    22662266}
    22672267
     2268void UIMessageCenter::cannotValidateExtentionPackSHA256Sum(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const
     2269{
     2270    alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Error,
     2271          tr("<p>The <b><nobr>%1</nobr></b> has been successfully downloaded "
     2272             "from <nobr><a href=\"%2\">%2</a></nobr> "
     2273             "and saved locally as <nobr><b>%3</b>, </nobr>"
     2274             "but SHA-256 checksum verification failed.</p>"
     2275             "<p>Please do the download, installation and verification manually.</p>")
     2276             .arg(strExtPackName, strFrom, strTo));
     2277}
     2278
    22682279bool UIMessageCenter::proposeDeleteExtentionPack(const QString &strTo) const
    22692280{
     
    22822293                          0 /* auto-confirm id */,
    22832294                          tr("Delete", "extension pack"));
    2284 }
    2285 
    2286 void UIMessageCenter::cannotValidateExtentionPackSHA256Sum(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const
    2287 {
    2288     alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Error,
    2289           tr("<p>The <b><nobr>%1</nobr></b> has been successfully downloaded "
    2290              "from <nobr><a href=\"%2\">%2</a></nobr> "
    2291              "and saved locally as <nobr><b>%3</b>, </nobr>"
    2292              "but the SHA-256 checksum verification failed.</p>"
    2293              "<p>Please do the download, installation and verification manually.</p>")
    2294              .arg(strExtPackName, strFrom, strTo));
    22952295}
    22962296#endif /* VBOX_GUI_WITH_NETWORK_MANAGER */
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderAdditions.cpp

    r65268 r65269  
    2323# include <QDir>
    2424# include <QFile>
     25# include <QCryptographicHash>
    2526
    2627/* Local includes: */
     
    3334
    3435#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    35 
    36 #include <iprt/sha.h>
    3736
    3837
     
    142141            const QString strFileName = strRecord.section(" *", 1);
    143142            const QString strDownloadedSumm = strRecord.section(" *", 0, 0);
    144             if (strFileName == QFileInfo(source().toString()).fileName())
     143            if (strFileName == source().fileName())
    145144            {
    146                 /* Calculate the SHA-256 on the bytes, creating a string: */
    147                 uint8_t abHash[RTSHA256_HASH_SIZE];
    148                 RTSha256(m_receivedData.constData(), m_receivedData.length(), abHash);
    149                 char szDigest[RTSHA256_DIGEST_LEN + 1];
    150                 int rc = RTSha256ToString(abHash, szDigest, sizeof(szDigest));
    151                 if (RT_FAILURE(rc))
    152                 {
    153                     AssertRC(rc);
    154                     szDigest[0] = '\0';
    155                 }
    156 
    157                 const QString strCalculatedSumm(szDigest);
    158                 // printf("Downloaded SHA-256 summ: [%s]\n", strDownloadedSumm.toUtf8().constData());
    159                 // printf("Calculated SHA-256 summ: [%s]\n", strCalculatedSumm.toUtf8().constData());
     145                /* Calculate the SHA-256 hash ourselves: */
     146                QCryptographicHash hashSHA256(QCryptographicHash::Sha256);
     147                hashSHA256.addData(m_receivedData);
     148                const QString strCalculatedSumm(hashSHA256.result().toHex());
     149                //printf("Downloaded SHA-256 summ: [%s]\n", strDownloadedSumm.toUtf8().constData());
     150                //printf("Calculated SHA-256 summ: [%s]\n", strCalculatedSumm.toUtf8().constData());
    160151                /* Make sure checksum is valid: */
    161152                fSuccess = strDownloadedSumm == strCalculatedSumm;
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderExtensionPack.cpp

    r65268 r65269  
    2323# include <QDir>
    2424# include <QFile>
     25# include <QCryptographicHash>
    2526
    2627/* Local includes: */
     
    6162
    6263    /* Prepare source/target: */
    63     QString strVersion = vboxGlobal().vboxVersionStringNormalized();
    6464    QString strExtPackUnderscoredName(QString(GUI_ExtPackName).replace(' ', '_'));
    6565    QString strTemplateSourcePath("http://download.virtualbox.org/virtualbox/%1/");
    6666    QString strTemplateSourceName(QString("%1-%2.vbox-extpack").arg(strExtPackUnderscoredName));
    67     QString strSourcePath(strTemplateSourcePath.arg(strVersion));
    68     QString strSourceName(strTemplateSourceName.arg(strVersion));
     67    QString strSourcePath(strTemplateSourcePath.arg(vboxGlobal().vboxVersionStringNormalized()));
     68    QString strSourceName(strTemplateSourceName.arg(vboxGlobal().vboxVersionStringNormalized()));
    6969    QString strSource(strSourcePath + strSourceName);
    70     QString strPathSHA256SumsFile = QString("https://www.virtualbox.org/download/hashes/%1/SHA256SUMS").arg(strVersion);
     70    QString strPathSHA256SumsFile = QString("https://www.virtualbox.org/download/hashes/%1/SHA256SUMS").arg(vboxGlobal().vboxVersionStringNormalized());
    7171    QString strTargetPath(vboxGlobal().homeFolder());
    7272    QString strTargetName(strSourceName);
     
    126126            const QString strFileName = strRecord.section(" *", 1);
    127127            const QString strDownloadedSumm = strRecord.section(" *", 0, 0);
    128             if (strFileName == QFileInfo(source().toString()).fileName())
     128            if (strFileName == source().fileName())
    129129            {
    130                 /* Calculate the SHA-256 on the bytes, creating a string: */
    131                 uint8_t abHash[RTSHA256_HASH_SIZE];
    132                 RTSha256(m_receivedData.constData(), m_receivedData.length(), abHash);
    133                 char szDigest[RTSHA256_DIGEST_LEN + 1];
    134                 int rc = RTSha256ToString(abHash, szDigest, sizeof(szDigest));
    135                 if (RT_FAILURE(rc))
    136                 {
    137                     AssertRC(rc);
    138                     szDigest[0] = '\0';
    139                 }
    140 
    141                 const QString strCalculatedSumm(szDigest);
    142                 // printf("Downloaded SHA-256 summ: [%s]\n", strDownloadedSumm.toUtf8().constData());
    143                 // printf("Calculated SHA-256 summ: [%s]\n", strCalculatedSumm.toUtf8().constData());
     130                /* Calculate the SHA-256 hash ourselves: */
     131                QCryptographicHash hashSHA256(QCryptographicHash::Sha256);
     132                hashSHA256.addData(m_receivedData);
     133                const QString strCalculatedSumm(hashSHA256.result().toHex());
     134                //printf("Downloaded SHA-256 summ: [%s]\n", strDownloadedSumm.toUtf8().constData());
     135                //printf("Calculated SHA-256 summ: [%s]\n", strCalculatedSumm.toUtf8().constData());
    144136                /* Make sure checksum is valid: */
    145137                fSuccess = strDownloadedSumm == strCalculatedSumm;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette