Changeset 65315 in vbox
- Timestamp:
- Jan 16, 2017 11:01:37 AM (8 years ago)
- 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 23 23 # include <QDir> 24 24 # include <QFile> 25 # include <QCryptographicHash>26 25 27 26 /* Local includes: */ … … 34 33 35 34 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 35 36 /* Other VBox includes: */ 37 #include <iprt/sha.h> 36 38 37 39 … … 121 123 { 122 124 /* Try to verify the SHA-256 checksum: */ 125 QString strCalculatedSumm; 123 126 bool fSuccess = false; 124 127 do … … 143 146 if (strFileName == source().fileName()) 144 147 { 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]; 149 159 //printf("Downloaded SHA-256 summ: [%s]\n", strDownloadedSumm.toUtf8().constData()); 150 160 //printf("Calculated SHA-256 summ: [%s]\n", strCalculatedSumm.toUtf8().constData()); -
trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderExtensionPack.cpp
r65289 r65315 23 23 # include <QDir> 24 24 # include <QFile> 25 # include <QCryptographicHash>26 25 27 26 /* Local includes: */ … … 35 34 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 36 35 36 /* Other VBox includes: */ 37 37 #include <iprt/sha.h> 38 38 … … 107 107 { 108 108 /* Try to verify the SHA-256 checksum: */ 109 QString strCalculatedSumm; 109 110 bool fSuccess = false; 110 111 do … … 129 130 if (strFileName == source().fileName()) 130 131 { 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]; 135 143 //printf("Downloaded SHA-256 summ: [%s]\n", strDownloadedSumm.toUtf8().constData()); 136 144 //printf("Calculated SHA-256 summ: [%s]\n", strCalculatedSumm.toUtf8().constData()); … … 162 170 file.close(); 163 171 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 175 172 /* Warn the listener about extension-pack was downloaded: */ 176 emit sigDownloadFinished(source().toString(), target(), &szDigest[0]);173 emit sigDownloadFinished(source().toString(), target(), strCalculatedSumm); 177 174 break; 178 175 }
Note:
See TracChangeset
for help on using the changeset viewer.