Esempio n. 1
0
// calculate secret key
BOOL CalculateKeyX(pUinKey ptr,MCONTACT hContact)
{
	int agr = cpp_calc_keyx(ptr->cntx);
	if (agr) {
		// do this only if key exchanged is ok
		// we use a 192bit key
		int keysize = cpp_size_keyx();
		PBYTE buffer = (PBYTE) alloca(keysize); // buffer for hash

		// store key
		cpp_get_keyx(ptr->cntx,buffer);

		// store key in database
		db_set_blob(hContact, MODULENAME, "offlineKey", buffer, keysize);

		// store timeout of key in database (2 days)
		db_set_dw(hContact, MODULENAME, "offlineKeyTimeout", gettime()+(60*60*24*db_get_w(0,MODULENAME,"okt",2)));

		// key exchange is finished
		showPopupEC(ptr->hContact);
	}
	else {
		// agree value problem
		showPopup(sim002,hContact,g_hPOP[POP_PU_DIS],0);
	}
	return agr != 0;
}
Esempio n. 2
0
void __cdecl rsa_notify(HANDLE context, int state)
{
	pUinKey ptr = getUinCtx(context); if (!ptr) return;
	LPCSTR msg = NULL;

	Sent_NetLog("rsa_notify: 0x%x", state);

	switch (state) {
	case 1:
		showPopupEC(ptr->hContact);
		ShowStatusIconNotify(ptr->hContact);
		waitForExchange(ptr, 2); // досылаем сообщения из очереди
		return;

	case -1: // сессия разорвана по ошибке, неверный тип сообщения
		msg = sim501; break;
	case -2: // сессия разорвана по ошибке другой стороной
		msg = sim502; break;
	case -5: // ошибка декодирования AES сообщения
		msg = sim505; break;
	case -6: // ошибка декодирования RSA сообщения
		msg = sim506; break;
	case -7: // таймаут установки соединения (10 секунд)
		msg = sim507; break;
	case -8: // сессия разорвана по причине "disabled"
		msg = sim508; break;
	case -0x10: // сессия разорвана по ошибке
	case -0x21:
	case -0x22:
	case -0x23:
	case -0x24:
	case -0x32:
	case -0x33:
	case -0x34:
	case -0x40:
	case -0x50:
	case -0x60:
	{
		char buf[1024];
		mir_snprintf(buf, sim510, -state);
		showPopupDCmsg(ptr->hContact, buf);
		ShowStatusIconNotify(ptr->hContact);
		if (ptr->cntx) deleteRSAcntx(ptr);
		waitForExchange(ptr, 3); // досылаем нешифровано
	}
		return;

	case -3: // соединение разорвано вручную
	case -4: // соединение разорвано вручную другой стороной
		showPopupDC(ptr->hContact);
		ShowStatusIconNotify(ptr->hContact);
		if (ptr->cntx) deleteRSAcntx(ptr);
		waitForExchange(ptr, 3); // досылаем нешифровано
		return;

	default:
		return;
	}
	showPopupDCmsg(ptr->hContact, msg);
	ShowStatusIconNotify(ptr->hContact);
	if (ptr->cntx) deleteRSAcntx(ptr);
	waitForExchange(ptr, 3); // досылаем нешифровано
}