From 91a971f6b2145d6af10a03f6e734eeb305dcc2f6 Mon Sep 17 00:00:00 2001 From: Cinders Date: Wed, 20 Mar 2013 12:15:59 -0600 Subject: [PATCH] Performance improvement, encrypt asset ids when saving using cheesy encryption instead of hashing everything --- indra/newview/fswsassetblacklist.cpp | 29 ++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/indra/newview/fswsassetblacklist.cpp b/indra/newview/fswsassetblacklist.cpp index b0a8292044..0205074492 100644 --- a/indra/newview/fswsassetblacklist.cpp +++ b/indra/newview/fswsassetblacklist.cpp @@ -36,12 +36,14 @@ #include "llfloaterreg.h" #include "llvfs.h" #include "llaudioengine.h" - +#include "llxorcipher.h" std::string FSWSAssetBlacklist::blacklist_file_name; std::map FSWSAssetBlacklist::BlacklistData; BlacklistMAP FSWSAssetBlacklist::BlacklistIDs; +const LLUUID MAGIC_ID("3c115e51-04f4-523c-9fa6-98aff1034730"); + LLAssetType::EType S32toAssetType(S32 assetindex) { LLAssetType::EType type; @@ -74,8 +76,6 @@ bool FSWSAssetBlacklist::isBlacklisted(LLUUID id, LLAssetType::EType type) { return false; } - - id = LLUUID::generateNewID(id.asString() + "hash"); BlacklistMAP::iterator it; it = BlacklistIDs.find(type); @@ -107,7 +107,7 @@ void FSWSAssetBlacklist::addNewItemToBlacklist(LLUUID id, std::string name, std: data["asset_type"] = type; data["asset_date"] = input_date; - addNewItemToBlacklistData(LLUUID::generateNewID(id.asString() + "hash"), data, save); + addNewItemToBlacklistData(id, data, save); } void FSWSAssetBlacklist::removeItemFromBlacklist(LLUUID id) @@ -193,8 +193,13 @@ void FSWSAssetBlacklist::loadBlacklist() for(LLSD::map_iterator itr = data.beginMap(); itr != data.endMap(); ++itr) { LLUUID uid = LLUUID(itr->first); + LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES); + cipher.decrypt(uid.mData, UUID_BYTES); LLSD data = itr->second; - if(uid.isNull()) continue; + if(uid.isNull()) + { + continue; + } LLAssetType::EType type = S32toAssetType(data["asset_type"].asInteger()); if(type == LLAssetType::AT_NONE) continue; @@ -232,10 +237,10 @@ void FSWSAssetBlacklist::loadBlacklist() newdata["asset_type"] = type; newdata["asset_date"] = data["entry_date"].asString(); - if (!data["ID_hashed"].asBoolean()) - { - uid = LLUUID::generateNewID(uid.asString() + "hash"); - } + //if (!data["ID_hashed"].asBoolean()) + //{ + // uid = LLUUID::generateNewID(uid.asString() + "hash"); + //} addNewItemToBlacklistData(uid, newdata, false); } @@ -258,7 +263,11 @@ void FSWSAssetBlacklist::saveBlacklist() for (std::map::iterator itr = BlacklistData.begin(); itr != BlacklistData.end(); ++itr) { - savedata[itr->first.asString()] = itr->second; + // Apply "cheesy encryption" to obfuscate these to the user. + LLUUID shadow_id(itr->first); + LLXORCipher cipher(MAGIC_ID.mData, UUID_BYTES); + cipher.encrypt(shadow_id.mData, UUID_BYTES); + savedata[shadow_id.asString()] = itr->second; } LLSDSerialize::toPrettyXML(savedata, save_file);