bool pfMacPasswordStore::SetPassword(const plString& username, const plString& password) { plString service = GetServerDisplayName(); return SecKeychainAddGenericPassword(nullptr, service.GetSize(), service.c_str(), username.GetSize(), username.c_str(), password.GetSize(), password.c_str(), nullptr) == errSecSuccess; }
/***************************************************************************** ** pfMacPasswordStore ** *****************************************************************************/ const plString pfMacPasswordStore::GetPassword(const plString& username) { plString service = GetServerDisplayName(); void* passwd = nullptr; uint32_t passwd_len = 0; if (SecKeychainFindGenericPassword(nullptr, service.GetSize(), service.c_str(), username.GetSize(), username.c_str(), &passwd_len, &passwd, nullptr) != errSecSuccess) { return plString::Null; } plString ret(reinterpret_cast<const char*>(passwd), size_t(passwd_len)); SecKeychainItemFreeContent(nullptr, passwd); return ret; }
uint32_t hsStream::WriteSafeStringLong(const plString &string) { uint32_t len = string.GetSize(); WriteLE32(len); if (len > 0) { const char *buffp = string.c_str(); uint32_t i; for (i = 0; i < len; i++) { WriteByte(~buffp[i]); } return i; } else return 0; }
uint32_t hsStream::WriteSafeString(const plString &string) { int len = string.GetSize(); hsAssert(len<0xf000, plString::Format("string len of %d is too long for WriteSafeString %s, use WriteSafeStringLong", len, string.c_str()).c_str() ); WriteLE16(len | 0xf000); if (len > 0) { uint32_t i; const char *buffp = string.c_str(); for (i = 0; i < len; i++) { WriteByte(~buffp[i]); } return i; } else return 0; }
static void StoreHash(const plString& username, const plString& password, LoginDialogParam *pLoginParam) { // Hash username and password before sending over the 'net. // -- Legacy compatibility: @gametap (and other usernames with domains in them) need // to be hashed differently. std::vector<plString> match = username.RESearch("[^@]+@([^.]+\\.)*([^.]+)\\.[^.]+"); if (match.empty() || match[2].CompareI("gametap") == 0) { // Plain Usernames... plSHA1Checksum shasum(password.GetSize(), reinterpret_cast<const uint8_t*>(password.c_str())); uint32_t* dest = reinterpret_cast<uint32_t*>(pLoginParam->namePassHash); const uint32_t* from = reinterpret_cast<const uint32_t*>(shasum.GetValue()); dest[0] = hsToBE32(from[0]); dest[1] = hsToBE32(from[1]); dest[2] = hsToBE32(from[2]); dest[3] = hsToBE32(from[3]); dest[4] = hsToBE32(from[4]); } else { // Domain-based Usernames... CryptHashPassword(username, password, pLoginParam->namePassHash); } }
bool plAutoProfileImp::MsgReceive(plMessage* msg) { plEvalMsg* evalMsg = plEvalMsg::ConvertNoRef(msg); if (evalMsg) { if (fStatusMessage.GetSize() > 0) plDebugText::Instance().DrawString(10, 10, fStatusMessage.c_str()); } plAgeLoadedMsg* ageLoaded = plAgeLoadedMsg::ConvertNoRef(msg); if (ageLoaded) { if (!ageLoaded->fLoaded) { fLinkTime = hsTimer::GetTicks(); hsStatusMessage("Age unloaded"); } return true; } plInitialAgeStateLoadedMsg* ageStateLoaded = plInitialAgeStateLoadedMsg::ConvertNoRef(msg); if (ageStateLoaded) { if (fNextAge > 0) { fLinkTime = hsTimer::GetTicks() - fLinkTime; float ms = hsTimer::GetMilliSeconds<float>(fLinkTime); hsStatusMessageF("Age %s finished load, took %.1f ms", fAges[fNextAge-1].c_str(), ms); plStatusLog::AddLineS("agetimings.log", "Age %s took %.1f ms", fAges[fNextAge-1].c_str(), ms); } fStatusMessage = "Age loaded. Preparing to profile."; // Age is loaded, start profiling in 5 seconds (to make sure the avatar is linked in all the way) plTimerCallbackMsg* timerMsg = new plTimerCallbackMsg(GetKey()); plgTimerCallbackMgr::NewTimer(5, timerMsg); return true; } plTimerCallbackMsg* timerMsg = plTimerCallbackMsg::ConvertNoRef(msg); if (timerMsg) { INextProfile(); return true; } // When the first age starts to load, register the stupid avatar customization variable // so the calibration screen won't pop up and ruin everything. I'm sure I could try // and do this earlier, but I'm not sure when that player folder is set so screw it, it works here. plAgeBeginLoadingMsg* ageBeginLoadingMsg = plAgeBeginLoadingMsg::ConvertNoRef(msg); if (ageBeginLoadingMsg) { plgDispatch::Dispatch()->UnRegisterForExactType(plAgeBeginLoadingMsg::Index(), GetKey()); VaultAddChronicleEntryAndWait("InitialAvCursomizationsDone", 0, "1"); return true; } return false; }