| 745 | |
| 746 | |
| 747 | const WCHAR * // get encrypted path |
| 748 | encrypt_path(CryptContext *con, const WCHAR *path, wstring& storage, string *actual_encrypted) |
| 749 | { |
| 750 | |
| 751 | storage.clear(); |
| 752 | storage.reserve(wcslen(path) * 2); |
| 753 | |
| 754 | const WCHAR *rval = NULL; |
| 755 | |
| 756 | CryptConfig *config = con->GetConfig(); |
| 757 | |
| 758 | try { |
| 759 | |
| 760 | if (!config->m_reverse) { |
| 761 | storage = config->GetBaseDir(); |
| 762 | } |
| 763 | |
| 764 | if (config->m_PlaintextNames || (path[0] == '\\' && path[1] == '\0')) { |
| 765 | |
| 766 | storage += path; |
| 767 | |
| 768 | } else { |
| 769 | |
| 770 | KeyDecryptor kdc(&config->m_keybuf_manager); |
| 771 | |
| 772 | if (*path && path[0] == '\\') { |
| 773 | storage.push_back('\\'); |
| 774 | path++; |
| 775 | } |
| 776 | |
| 777 | const TCHAR* p = path; |
| 778 | |
| 779 | |
| 780 | unsigned char dir_iv[DIR_IV_LEN]; |
| 781 | #if 0 |
| 782 | if (!get_dir_iv(con, &storage[0], dir_iv)) |
| 783 | throw(L"get_dir_iv failed for " + storage); |
| 784 | |
| 785 | #else |
| 786 | if (config->m_reverse) { |
| 787 | if (!derive_path_iv(con, &storage[0], dir_iv, TYPE_DIRIV)) |
| 788 | throw(L"get_dir_iv failed for " + storage); |
| 789 | } else { |
| 790 | if (!get_dir_iv(con, &storage[0], dir_iv)) |
| 791 | throw(L"get_dir_iv failed for " + storage); |
| 792 | } |
| 793 | #endif |
| 794 | |
| 795 | if (!con->GetConfig()->m_EMENames) { |
| 796 | // CBC names no longer supported |
| 797 | throw(wstring(L"CBC names no longer supported")); |
| 798 | } |
| 799 | |
| 800 | wstring s; |
| 801 | |
| 802 | wstring uni_crypt_elem; |
| 803 | |
| 804 | while (*p) { |
no test coverage detected