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

Function get_actual_encrypted

libcppcryptfs/filename/cryptfilename.cpp:964–1001  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

962}
963
964bool
965get_actual_encrypted(CryptContext *con, LPCWSTR FileName, string& actual_encrypted)
966{
967
968 wstring encrypted_name;
969
970 if (!get_bare_filename(FileName, encrypted_name))
971 return false;
972
973 wstring base64_hash;
974
975 if (extract_lfn_base64_hash(&encrypted_name[0], base64_hash)) {
976 if (con->m_lfn_cache.lookup(&base64_hash[0], NULL, &actual_encrypted)) {
977 return true;
978 }
979 }
980
981 wstring dirpath;
982 wstring decrypted_name;
983
984 BYTE dir_iv[DIR_IV_LEN];
985
986 if (!get_file_directory(FileName, dirpath))
987 return false;
988
989 if (!derive_path_iv(con, &dirpath[0], dir_iv, TYPE_DIRIV))
990 return false;
991
992 //encrypted_name = encrypted_name.substr(0, encrypted_name.length() - sizeof(LONGNAME_SUFFIX_W) / sizeof(WCHAR) - 1);
993
994 if (!decrypt_filename(con, dir_iv, &dirpath[0], &encrypted_name[0], decrypted_name))
995 return false;
996
997 if (!encrypt_filename(con, dir_iv, &decrypted_name[0], encrypted_name, &actual_encrypted))
998 return false;
999
1000 return true;
1001}
1002
1003bool
1004get_bare_filename(LPCWSTR filepath, wstring& filename)

Callers 2

read_virtual_fileFunction · 0.85
get_file_informationFunction · 0.85

Calls 7

get_bare_filenameFunction · 0.85
extract_lfn_base64_hashFunction · 0.85
get_file_directoryFunction · 0.85
derive_path_ivFunction · 0.85
decrypt_filenameFunction · 0.85
encrypt_filenameFunction · 0.85
lookupMethod · 0.45

Tested by

no test coverage detected