MCPcopy Create free account
hub / github.com/LUX-Core/lux / Resync

Method Resync

src/cryptopp/gcm.cpp:437–480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

435}
436
437void GCM_Base::Resync(const byte *iv, size_t len)
438{
439 BlockCipher &cipher = AccessBlockCipher();
440 byte *hashBuffer = HashBuffer();
441
442 if (len == 12)
443 {
444 memcpy(hashBuffer, iv, len);
445 memset(hashBuffer+len, 0, 3);
446 hashBuffer[len+3] = 1;
447 }
448 else
449 {
450 size_t origLen = len;
451 memset(hashBuffer, 0, HASH_BLOCKSIZE);
452
453 if (len >= HASH_BLOCKSIZE)
454 {
455 len = GCM_Base::AuthenticateBlocks(iv, len);
456 iv += (origLen - len);
457 }
458
459 if (len > 0)
460 {
461 memcpy(m_buffer, iv, len);
462 memset(m_buffer+len, 0, HASH_BLOCKSIZE-len);
463 GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE);
464 }
465
466 PutBlock<word64, BigEndian, true>(NULL, m_buffer)(0)(origLen*8);
467 GCM_Base::AuthenticateBlocks(m_buffer, HASH_BLOCKSIZE);
468
469 ReverseHashBufferIfNeeded();
470 }
471
472 if (m_state >= State_IVSet)
473 m_ctr.Resynchronize(hashBuffer, REQUIRED_BLOCKSIZE);
474 else
475 m_ctr.SetCipherWithIV(cipher, hashBuffer);
476
477 m_ctr.Seek(HASH_BLOCKSIZE);
478
479 memset(hashBuffer, 0, HASH_BLOCKSIZE);
480}
481
482unsigned int GCM_Base::OptimalDataAlignment() const
483{

Callers

nothing calls this directly

Calls 4

HashBufferFunction · 0.85
memcpyFunction · 0.85
ResynchronizeMethod · 0.45
SeekMethod · 0.45

Tested by

no test coverage detected