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

Function decrypt_path

libcppcryptfs/filename/cryptfilename.cpp:488–607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488const WCHAR * // get decrypted path (used only in reverse mode)
489decrypt_path(CryptContext *con, const WCHAR *path, wstring& storage)
490{
491 const WCHAR *rval = NULL;
492
493 HANDLE hFind = NULL;
494
495 CryptConfig *config = con->GetConfig();
496
497 bool done = false;
498
499 try {
500
501 if (!config->m_reverse)
502 throw(-1);
503
504 storage = config->GetBaseDir();
505
506 if (config->m_PlaintextNames || (path[0] == '\\' && path[1] == '\0')) {
507
508 storage += path;
509
510 } else {
511
512 KeyDecryptor kdc(&config->m_keybuf_manager);
513
514 // we can short-circuit the process in the case where the final file or dir is a long file name
515 // and it is found in the long file name (lfn) cache
516
517 const WCHAR *last_elem = wcsrchr(path, '\\');
518
519 if (last_elem) {
520 last_elem++;
521 if (is_long_name(last_elem)) {
522 wstring base64_hash;
523 if (!extract_lfn_base64_hash(&last_elem[0], base64_hash)) {
524 throw(-1);
525 }
526 wstring lfn_path;
527 if (con->m_lfn_cache.lookup(&base64_hash[0], &storage, NULL)) {
528 done = true;
529 }
530 }
531 }
532
533
534
535 if (!done) {
536
537 wstring diriv_path = L"";
538
539 if (*path && path[0] == '\\') {
540 storage.push_back('\\');
541 path++;
542 }
543
544 const TCHAR *p = path;
545

Callers 3

ConvertMethod · 0.85
get_file_informationFunction · 0.85

Calls 8

is_long_nameFunction · 0.85
extract_lfn_base64_hashFunction · 0.85
derive_path_ivFunction · 0.85
decrypt_filenameFunction · 0.85
decrypt_reverse_longnameFunction · 0.85
GetConfigMethod · 0.80
GetBaseDirMethod · 0.80
lookupMethod · 0.45

Tested by

no test coverage detected