MCPcopy Create free account
hub / github.com/OpenFOAM/OpenFOAM-dev / finalize

Function finalize

src/OpenFOAM/primitives/hashes/SHA1/SHA1.C:354–390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352
353
354bool Foam::SHA1::finalize()
355{
356 if (!finalized_)
357 {
358 finalized_ = true;
359
360 // account for unprocessed bytes
361 uint32_t bytes = bufLen_;
362 size_t size = (bytes < 56 ? 64 : 128) / sizeof(uint32_t);
363
364 // count remaining bytes.
365 bufTotal_[0] += bytes;
366 if (bufTotal_[0] < bytes)
367 {
368 ++bufTotal_[1];
369 }
370
371 // finalized, but no data!
372 if (!bufTotal_[0] && !bufTotal_[1])
373 {
374 return false;
375 }
376
377 // place the 64-bit file length in *bits* at the end of the buffer.
378 buffer_[size-2] = swapBytes((bufTotal_[1] << 3) | (bufTotal_[0] >> 29));
379 buffer_[size-1] = swapBytes(bufTotal_[0] << 3);
380
381 unsigned char* bufp = reinterpret_cast<unsigned char *>(buffer_);
382
383 memcpy(&bufp[bytes], fillbuf, (size-2) * sizeof(uint32_t) - bytes);
384
385 // Process remaining bytes
386 processBlock(buffer_, size * sizeof(uint32_t));
387 }
388
389 return true;
390}
391
392
393Foam::SHA1Digest Foam::SHA1::digest() const

Callers

nothing calls this directly

Calls 2

swapBytesFunction · 0.85
processBlockFunction · 0.85

Tested by

no test coverage detected