| 543 | } |
| 544 | |
| 545 | std::size_t CNetworkClient::RecvPreCryptKeyInfo(const void* data, std::size_t maxlength) |
| 546 | { |
| 547 | if (maxlength < TPacketPreCryptKeyInfo::size()) |
| 548 | return 0; |
| 549 | |
| 550 | NETWORK_LOG(LL_SYS, "Got pre crypt key packet!"); |
| 551 | |
| 552 | auto packet = reinterpret_cast<const TPacketPreCryptKeyInfo*>(data); |
| 553 | |
| 554 | // Register crypt key |
| 555 | memcpy(&m_pPreCryptKey, packet->preCryptKey, NET_CRYPT_KEY_LENGTH); |
| 556 | // DecryptBuffer(m_pPreCryptKey, NET_CRYPT_KEY_LENGTH, NETWORK_BODY_CRYPT_KEY); |
| 557 | m_bPreCryptCompleted = true; |
| 558 | |
| 559 | // Start rsa initilziation |
| 560 | auto rsaInitPacket = std::make_shared<TPacketRsaInit>(); |
| 561 | if (IS_VALID_SMART_PTR(rsaInitPacket)) |
| 562 | { |
| 563 | m_pRSAClient.create_keypair(); |
| 564 | |
| 565 | memcpy(rsaInitPacket->publicExponent, m_pRSAClient.get_public_exponent().get_data(), m_pRSAClient.get_public_exponent().get_size()); |
| 566 | rsaInitPacket->publicExponentSize = m_pRSAClient.get_public_exponent().get_size(); |
| 567 | memcpy(rsaInitPacket->modulus, m_pRSAClient.get_modulus().get_data(), m_pRSAClient.get_modulus().get_size()); |
| 568 | rsaInitPacket->modulusSize = m_pRSAClient.get_modulus().get_size(); |
| 569 | |
| 570 | SendCrypted(HEADER_CS_RSA_INIT, rsaInitPacket.get(), rsaInitPacket->size()); |
| 571 | } |
| 572 | |
| 573 | return TPacketPreCryptKeyInfo::size(); |
| 574 | } |
| 575 | |
| 576 | std::size_t CNetworkClient::RecvRSAKeyInfo(const void* data, std::size_t maxlength) |
| 577 | { |
nothing calls this directly
no test coverage detected