MCPcopy Create free account
hub / github.com/bailey27/cppcryptfs / WriteVersionAndFileId

Method WriteVersionAndFileId

libcppcryptfs/file/cryptfile.cpp:335–364  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333// write version and fileid to empty file before writing to it
334
335BOOL CryptFileForward::WriteVersionAndFileId()
336{
337 if (m_real_file_size == (long long)-1)
338 return FALSE;
339
340 OVERLAPPED ov;
341 memset(&ov, 0, sizeof(ov));
342
343 if (!get_random_bytes(m_con, m_header.fileid, FILE_ID_LEN))
344 return FALSE;
345
346 unsigned short version = CRYPT_VERSION;
347
348 m_header.version = MakeBigEndian(version);
349
350 DWORD nWritten = 0;
351
352 if (!WriteFile(m_handle, &m_header, sizeof(m_header), &nWritten, &ov)) {
353 m_header.version = CRYPT_VERSION;
354 return FALSE;
355 }
356
357 m_header.version = CRYPT_VERSION;
358
359 m_real_file_size = FILE_HEADER_LEN;
360
361 m_is_empty = false;
362
363 return nWritten == FILE_HEADER_LEN;
364}
365
366
367BOOL CryptFileForward::Write(const unsigned char *buf, DWORD buflen, LPDWORD pNwritten, LONGLONG offset, BOOL bWriteToEndOfFile, BOOL bPagingIo)

Callers

nothing calls this directly

Calls 2

get_random_bytesFunction · 0.85
MakeBigEndianFunction · 0.85

Tested by

no test coverage detected