| 607 | } |
| 608 | |
| 609 | const WCHAR* // get decrypted path (used only by the --transform flag) |
| 610 | unencrypt_path(CryptContext* con, const WCHAR* path, wstring& storage) |
| 611 | { |
| 612 | const WCHAR* rval = NULL; |
| 613 | |
| 614 | HANDLE hFind = NULL; |
| 615 | |
| 616 | CryptConfig* config = con->GetConfig(); |
| 617 | |
| 618 | bool done = false; |
| 619 | |
| 620 | try { |
| 621 | |
| 622 | if (0 && !config->m_reverse) |
| 623 | throw(-1); |
| 624 | |
| 625 | storage.clear(); |
| 626 | |
| 627 | if (config->m_PlaintextNames || (path[0] == '\\' && path[1] == '\0')) { |
| 628 | |
| 629 | storage += path; |
| 630 | |
| 631 | } else { |
| 632 | |
| 633 | KeyDecryptor kdc(&config->m_keybuf_manager); |
| 634 | |
| 635 | // in reverse mode we can short-circuit the process in the case where the final file or dir is a long file name |
| 636 | // and it is found in the long file name (lfn) cache |
| 637 | |
| 638 | if (config->m_reverse) { |
| 639 | const WCHAR* last_elem = wcsrchr(path, '\\'); |
| 640 | |
| 641 | if (last_elem) { |
| 642 | last_elem++; |
| 643 | if (is_long_name(last_elem)) { |
| 644 | wstring base64_hash; |
| 645 | if (!extract_lfn_base64_hash(&last_elem[0], base64_hash)) { |
| 646 | throw(-1); |
| 647 | } |
| 648 | wstring lfn_path; |
| 649 | if (con->m_lfn_cache.lookup(&base64_hash[0], &storage, NULL)) { |
| 650 | done = true; |
| 651 | } |
| 652 | } |
| 653 | } |
| 654 | } |
| 655 | |
| 656 | if (!done) { |
| 657 | |
| 658 | wstring diriv_path = L""; |
| 659 | |
| 660 | if (!config->m_reverse) { |
| 661 | diriv_path = config->m_basedir + L"\\"; |
| 662 | } |
| 663 | |
| 664 | if (*path && path[0] == '\\') { |
| 665 | storage.push_back('\\'); |
| 666 | path++; |
no test coverage detected