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

Function encrypt_path

libcppcryptfs/filename/cryptfilename.cpp:747–852  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

745
746
747const WCHAR * // get encrypted path
748encrypt_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) {

Callers 4

ConvertMethod · 0.85
transform_pathFunction · 0.85
check_node_cleanMethod · 0.85
load_dirMethod · 0.85

Calls 6

get_dir_ivFunction · 0.85
derive_path_ivFunction · 0.85
encrypt_filenameFunction · 0.85
DbgPrintFunction · 0.85
GetConfigMethod · 0.80
GetBaseDirMethod · 0.80

Tested by

no test coverage detected