MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / crypt_write_block

Function crypt_write_block

src/burp/mvol.cpp:313–355  ·  view source on GitHub ↗

____________________________________________________________

Source from the content-addressed store, hash-verified

311//
312//
313static void crypt_write_block(BurpGlobals* tdgbl, const UCHAR* buffer, FB_SIZE_T buffer_length, bool flash)
314{
315 if (!(tdgbl->gbl_sw_keyholder))
316 {
317 mvol_write_block(tdgbl, buffer, buffer_length);
318 return;
319 }
320
321 start_crypt(tdgbl);
322 fb_assert(tdgbl->gbl_crypt);
323
324 while (buffer_length)
325 {
326 ULONG step = MIN(buffer_length + tdgbl->gbl_crypt_left, ZC_BUFSIZE);
327 fb_assert(CRYPT_STEP < ZC_BUFSIZE);
328
329 ULONG move = step - tdgbl->gbl_crypt_left;
330 memcpy(tdgbl->gbl_crypt_buffer + tdgbl->gbl_crypt_left, buffer, move);
331 buffer_length -= move;
332 buffer += move;
333
334 tdgbl->gbl_crypt_left = step % CRYPT_STEP;
335 step -= tdgbl->gbl_crypt_left;
336
337 if (flash && buffer_length == 0 && tdgbl->gbl_crypt_left)
338 {
339 step += CRYPT_STEP;
340 tdgbl->gbl_crypt_left = 0;
341 }
342
343 FbLocalStatus status;
344
345 for (ULONG offset = 0; offset < step; offset += CRYPT_STEP)
346 {
347 UCHAR* b = &tdgbl->gbl_crypt_buffer[offset];
348 tdgbl->gbl_crypt->crypt_plugin->encrypt(&status, CRYPT_STEP, b, b);
349 check(&status);
350 }
351
352 mvol_write_block(tdgbl, tdgbl->gbl_crypt_buffer, step);
353 memmove(tdgbl->gbl_crypt_buffer, &tdgbl->gbl_crypt_buffer[step], tdgbl->gbl_crypt_left);
354 }
355}
356
357
358//____________________________________________________________

Callers 1

zip_write_blockFunction · 0.85

Calls 4

mvol_write_blockFunction · 0.85
start_cryptFunction · 0.85
checkFunction · 0.50
encryptMethod · 0.45

Tested by

no test coverage detected