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

Method init_serial

libcppcryptfs/config/cryptconfig.cpp:363–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361}
362
363bool CryptConfig::init_serial(CryptContext *con)
364{
365 BYTE diriv[DIR_IV_LEN];
366
367 this->m_serial = 0;
368
369 if (!m_reverse && this->DirIV() && get_dir_iv(con, &this->m_basedir[0], diriv)) {
370
371 this->m_serial = *(DWORD*)diriv;
372
373 }
374
375 if (!this->m_serial) {
376
377 wstring str = L"XjyG7KDokdqpxtjUh6oCVJ92FmPFJ1Fg"; // salt
378
379 str += this->m_basedir;
380
381 BYTE sum[32];
382
383 string utf8;
384
385 if (unicode_to_utf8(&str[0], utf8)) {
386
387 if (sha256(utf8, sum))
388 this->m_serial = *(DWORD*)sum;
389 }
390 }
391
392 if (!this->m_serial) // ultimate fall-back
393 this->m_serial = DEFAULT_VOLUME_SERIAL_NUMBER;
394
395 return true;
396}
397
398bool CryptConfig::write_updated_config_file(const char *base64key, const char *scryptSalt, int scryptn)
399{

Callers 1

mount_crypt_fsFunction · 0.80

Calls 4

DirIVMethod · 0.95
get_dir_ivFunction · 0.85
unicode_to_utf8Function · 0.85
sha256Function · 0.85

Tested by

no test coverage detected