| 361 | } |
| 362 | |
| 363 | bool 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 | |
| 398 | bool CryptConfig::write_updated_config_file(const char *base64key, const char *scryptSalt, int scryptn) |
| 399 | { |
no test coverage detected