Ejemplo n.º 1
0
tABC_CC ABC_LoginServerGetCarePackage(const Lobby &lobby,
                                      CarePackage &result,
                                      tABC_Error *pError)
{
    tABC_CC cc = ABC_CC_Ok;

    std::string url = ABC_SERVER_ROOT "/" ABC_SERVER_GET_CARE_PACKAGE_PATH;
    char *szCarePackage = NULL;

    ABC_CHECK_RET(ABC_LoginServerGetString(lobby, U08Buf(), U08Buf(), url.c_str(), JSON_ACCT_CARE_PACKAGE, &szCarePackage, pError));
    ABC_CHECK_NEW(result.decode(szCarePackage));

exit:
    ABC_FREE_STR(szCarePackage);

    return cc;
}
Ejemplo n.º 2
0
void U08BufFree(U08Buf &self)
{
    if (self.data())
    {
        ABC_UtilGuaranteedMemset(self.data(), 0, self.size());
        free(self.data());
    }
    self = U08Buf();
}
Ejemplo n.º 3
0
/**
 * Request Reset 2 Factor authentication
 *
 * @param LP1  Password hash for the account
 */
tABC_CC ABC_LoginServerOtpReset(const Lobby &lobby, tABC_Error *pError)
{
    tABC_CC cc = ABC_CC_Ok;
    std::string url = ABC_SERVER_ROOT "/otp/reset";
    ABC_CHECK_RET(ABC_LoginServerOtpRequest(url.c_str(), lobby, U08Buf(), NULL, pError));

exit:
    return cc;
}
Ejemplo n.º 4
0
Status
loginRecovery(std::shared_ptr<Login> &result,
              Lobby &lobby, const std::string &recoveryAnswers,
              AuthError &authError)
{
    std::string LRA = lobby.username() + recoveryAnswers;

    // Get the CarePackage:
    CarePackage carePackage;
    ABC_CHECK(loginServerGetCarePackage(lobby, carePackage));

    // Make recoveryAuthKey (unlocks the server):
    DataChunk recoveryAuthKey;
    ABC_CHECK(usernameSnrp().hash(recoveryAuthKey, LRA));

    // Get the LoginPackage:
    LoginPackage loginPackage;
    JsonPtr rootKeyBox;
    ABC_CHECK(loginServerGetLoginPackage(lobby, U08Buf(), recoveryAuthKey,
                                         loginPackage, rootKeyBox,
                                         authError));

    // Make recoveryKey (unlocks dataKey):
    DataChunk recoveryKey;
    ABC_CHECK(carePackage.snrp3().hash(recoveryKey, LRA));

    // Decrypt dataKey (unlocks the account):
    DataChunk dataKey;
    ABC_CHECK(loginPackage.recoveryBox().decrypt(dataKey, recoveryKey));

    // Create the Login object:
    std::shared_ptr<Login> out;
    ABC_CHECK(Login::create(out, lobby, dataKey,
                            loginPackage, rootKeyBox, false));

    // Set up the on-disk login:
    ABC_CHECK(carePackage.save(out->paths.carePackagePath()));
    ABC_CHECK(loginPackage.save(out->paths.loginPackagePath()));

    result = std::move(out);
    return Status();
}
Ejemplo n.º 5
0
/**
 * Casts new-style data to an old-style U08Buf type.
 * DANGER! THIS IS NOT CONST-CORRECT!
 */
inline U08Buf
toU08Buf(DataSlice slice)
{
    return U08Buf(const_cast<uint8_t *>(slice.data()), slice.size());
}