Ejemplo n.º 1
0
void MapleEncryption::nextIv(unsigned char *vector) {
	uint8_t x[4] = {0xF2, 0x53, 0x50, 0xC6};

	for (uint8_t i = 0; i < 4; i++) {
		uint8_t a = x[1];
		uint8_t b = a;
		uint32_t c, d;

		b = values[b];
		b -= vector[i];
		x[0] += b;
		b = x[2];
		b = b ^ values[vector[i]];
		a -= b;
		x[1] = a;
		a = x[3];
		b = a;
		a -= x[0];
		b = values[b];
		b += vector[i];
		b = b ^ x[2];
		x[2] = b;
		a += values[vector[i]];
		x[3] = a;

		c = x[0] + x[1] * 0x100 + x[2] * 0x10000 + x[3] * 0x1000000;
		d = c;
		c = c >> 0x1D;
		d = d << 0x03;
		c = c | d;
		x[0] = (uint8_t)(c % 0x100); // Guaranteed to be 0x00 to 0xFF, we want this cast
		c /= 0x100;
		x[1] = (uint8_t)(c % 0x100);
		c /= 0x100;
		x[2] = (uint8_t)(c % 0x100);
		x[3] = (uint8_t)(c / 0x100);
	}

	setIv(vector, x);
}
Ejemplo n.º 2
0
void Ledger::accountSuccess(QNetworkReply& reply) {
    // lets set the appropriate stuff in the wallet now
    auto wallet = DependencyManager::get<Wallet>();
    QByteArray response = reply.readAll();
    QJsonObject data = QJsonDocument::fromJson(response).object()["data"].toObject();

    auto salt = QByteArray::fromBase64(data["salt"].toString().toUtf8());
    auto iv = QByteArray::fromBase64(data["iv"].toString().toUtf8());
    auto ckey = QByteArray::fromBase64(data["ckey"].toString().toUtf8());
    QString remotePublicKey = data["public_key"].toString();
    bool isOverride = wallet->wasSoftReset();

    wallet->setSalt(salt);
    wallet->setIv(iv);
    wallet->setCKey(ckey);

    QString keyStatus = "ok";
    QStringList localPublicKeys = wallet->listPublicKeys();
    if (remotePublicKey.isEmpty() || isOverride) {
        if (!localPublicKeys.isEmpty()) {
            QString key = localPublicKeys.first();
            receiveAt(key, key);
        }
    } else {
        if (localPublicKeys.isEmpty()) {
            keyStatus = "preexisting";
        } else if (localPublicKeys.first() != remotePublicKey) {
            keyStatus = "conflicting";
        }
    }

    // none of the hfc account info should be emitted
    QJsonObject json;
    QJsonObject responseData{ { "status", "success"} };
    json["keyStatus"] = keyStatus;
    responseData["data"] = json;
    emit accountResult(responseData);
}