VirtualBox

Changeset 65315 in vbox


Ignore:
Timestamp:
Jan 16, 2017 11:01:37 AM (8 years ago)
Author:
vboxsync
Message:

FE/Qt: bugref:8646: Guest Additions and Extension Pack downloaders: Replace the sum calculation algorithm from Qt one to our own, get rid of superfluous call.

Location:
trunk/src/VBox/Frontends/VirtualBox/src/net
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderAdditions.cpp

    r65269 r65315  
    2323# include <QDir>
    2424# include <QFile>
    25 # include <QCryptographicHash>
    2625
    2726/* Local includes: */
     
    3433
    3534#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
     35
     36/* Other VBox includes: */
     37#include <iprt/sha.h>
    3638
    3739
     
    121123{
    122124    /* Try to verify the SHA-256 checksum: */
     125    QString strCalculatedSumm;
    123126    bool fSuccess = false;
    124127    do
     
    143146            if (strFileName == source().fileName())
    144147            {
    145                 /* Calculate the SHA-256 hash ourselves: */
    146                 QCryptographicHash hashSHA256(QCryptographicHash::Sha256);
    147                 hashSHA256.addData(m_receivedData);
    148                 const QString strCalculatedSumm(hashSHA256.result().toHex());
     148                /* Calc the SHA-256 on the bytes, creating a string: */
     149                uint8_t abHash[RTSHA256_HASH_SIZE];
     150                RTSha256(m_receivedData.constData(), m_receivedData.length(), abHash);
     151                char szDigest[RTSHA256_DIGEST_LEN + 1];
     152                int rc = RTSha256ToString(abHash, szDigest, sizeof(szDigest));
     153                if (RT_FAILURE(rc))
     154                {
     155                    AssertRC(rc);
     156                    szDigest[0] = '\0';
     157                }
     158                strCalculatedSumm = &szDigest[0];
    149159                //printf("Downloaded SHA-256 summ: [%s]\n", strDownloadedSumm.toUtf8().constData());
    150160                //printf("Calculated SHA-256 summ: [%s]\n", strCalculatedSumm.toUtf8().constData());
  • trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderExtensionPack.cpp

    r65289 r65315  
    2323# include <QDir>
    2424# include <QFile>
    25 # include <QCryptographicHash>
    2625
    2726/* Local includes: */
     
    3534#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
    3635
     36/* Other VBox includes: */
    3737#include <iprt/sha.h>
    3838
     
    107107{
    108108    /* Try to verify the SHA-256 checksum: */
     109    QString strCalculatedSumm;
    109110    bool fSuccess = false;
    110111    do
     
    129130            if (strFileName == source().fileName())
    130131            {
    131                 /* Calculate the SHA-256 hash ourselves: */
    132                 QCryptographicHash hashSHA256(QCryptographicHash::Sha256);
    133                 hashSHA256.addData(m_receivedData);
    134                 const QString strCalculatedSumm(hashSHA256.result().toHex());
     132                /* Calc the SHA-256 on the bytes, creating a string: */
     133                uint8_t abHash[RTSHA256_HASH_SIZE];
     134                RTSha256(m_receivedData.constData(), m_receivedData.length(), abHash);
     135                char szDigest[RTSHA256_DIGEST_LEN + 1];
     136                int rc = RTSha256ToString(abHash, szDigest, sizeof(szDigest));
     137                if (RT_FAILURE(rc))
     138                {
     139                    AssertRC(rc);
     140                    szDigest[0] = '\0';
     141                }
     142                strCalculatedSumm = &szDigest[0];
    135143                //printf("Downloaded SHA-256 summ: [%s]\n", strDownloadedSumm.toUtf8().constData());
    136144                //printf("Calculated SHA-256 summ: [%s]\n", strCalculatedSumm.toUtf8().constData());
     
    162170            file.close();
    163171
    164             /* Calc the SHA-256 on the bytes, creating a string: */
    165             uint8_t abHash[RTSHA256_HASH_SIZE];
    166             RTSha256(m_receivedData.constData(), m_receivedData.length(), abHash);
    167             char szDigest[RTSHA256_DIGEST_LEN + 1];
    168             int rc = RTSha256ToString(abHash, szDigest, sizeof(szDigest));
    169             if (RT_FAILURE(rc))
    170             {
    171                 AssertRC(rc);
    172                 szDigest[0] = '\0';
    173             }
    174 
    175172            /* Warn the listener about extension-pack was downloaded: */
    176             emit sigDownloadFinished(source().toString(), target(), &szDigest[0]);
     173            emit sigDownloadFinished(source().toString(), target(), strCalculatedSumm);
    177174            break;
    178175        }
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