Changeset 45227 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Mar 28, 2013 12:22:11 PM (12 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/Makefile.kmk
r45211 r45227 269 269 common/checksum/manifest-file.cpp \ 270 270 common/checksum/RTSha1Digest.cpp \ 271 common/checksum/RTSha256Digest.cpp \ 271 272 common/checksum/sha1.cpp \ 272 273 common/checksum/sha1str.cpp \ -
trunk/src/VBox/Runtime/VBox/VBoxRTImp.def
r44529 r45227 1008 1008 RTSha256ToString 1009 1009 RTSha256Update 1010 RTSha256Digest 1011 RTSha256DigestFromFile 1010 1012 RTSha512 1011 1013 RTSha512Final -
trunk/src/VBox/Runtime/common/checksum/manifest.cpp
r44529 r45227 268 268 } 269 269 270 271 RTR3DECL(int) RTManifestVerifyDigestType(void *pvBuf, size_t cbSize, RTDIGESTTYPE &digestType) 272 { 273 /* Validate input */ 274 AssertPtrReturn(pvBuf, VERR_INVALID_POINTER); 275 AssertReturn(cbSize > 0, VERR_INVALID_PARAMETER); 276 277 int rc = VINF_SUCCESS; 278 279 char *pcBuf = (char*)pvBuf; 280 size_t cbRead = 0; 281 /* Parse the manifest file line by line */ 282 for (;;) 283 { 284 if (cbRead >= cbSize) 285 { 286 digestType = RTDIGESTTYPE_UNKNOWN; 287 rc = VERR_MANIFEST_UNSUPPORTED_DIGEST_TYPE; 288 break; 289 } 290 291 size_t cch = rtManifestIndexOfCharInBuf(pcBuf, cbSize - cbRead, '\n') + 1; 292 293 /* Skip empty lines (UNIX/DOS format) */ 294 if ( ( cch == 1 295 && pcBuf[0] == '\n') 296 || ( cch == 2 297 && pcBuf[0] == '\r' 298 && pcBuf[1] == '\n')) 299 { 300 pcBuf += cch; 301 cbRead += cch; 302 continue; 303 } 304 305 /* Check for the digest algorithm */ 306 if (pcBuf[0] == 'S' 307 && pcBuf[1] == 'H' 308 && pcBuf[2] == 'A' 309 && pcBuf[3] == '1') 310 { 311 digestType = RTDIGESTTYPE_SHA1; 312 break; 313 } 314 else if (pcBuf[0] == 'S' 315 && pcBuf[1] == 'H' 316 && pcBuf[2] == 'A' 317 && pcBuf[3] == '2' 318 && pcBuf[4] == '5' 319 && pcBuf[5] == '6') 320 { 321 digestType = RTDIGESTTYPE_SHA256; 322 break; 323 } 324 } 325 326 return rc; 327 } 328 270 329 RTR3DECL(int) RTManifestVerifyFilesBuf(void *pvBuf, size_t cbSize, PRTMANIFESTTEST paTests, size_t cTests, size_t *piFailed) 271 330 { … … 318 377 319 378 /* Check for the digest algorithm */ 320 if ( cch < 4 321 ||!( pcBuf[0] == 'S'379 if ( cch < 4 || 380 (!( pcBuf[0] == 'S' 322 381 && pcBuf[1] == 'H' 323 382 && pcBuf[2] == 'A' 324 && pcBuf[3] == '1')) 383 && pcBuf[3] == '1') 384 && 385 !( pcBuf[0] == 'S' 386 && pcBuf[1] == 'H' 387 && pcBuf[2] == 'A' 388 && pcBuf[3] == '2' 389 && pcBuf[4] == '5' 390 && pcBuf[5] == '6')) 391 ) 325 392 { 326 393 /* Digest unsupported */ -
trunk/src/VBox/Runtime/testcase/tstRTDigest.cpp
r44529 r45227 160 160 } 161 161 162 case kDigestType_SHA256: 163 { 164 char *pszDigest; 165 int rc = RTSha256DigestFromFile(ValueUnion.psz, &pszDigest, NULL, NULL); 166 if (RT_FAILURE(rc)) 167 return Error("RTSha256Digest(%s,) -> %Rrc\n", ValueUnion.psz, rc); 168 RTPrintf("%s %s\n", pszDigest, ValueUnion.psz); 169 RTStrFree(pszDigest); 170 break; 171 } 162 172 default: 163 173 return Error("The file method isn't implemented for this digest\n");
Note:
See TracChangeset
for help on using the changeset viewer.