File indexing completed on 2025-01-05 04:37:18
0001 /* 0002 SPDX-FileCopyrightText: 2005 Joris Guisson <joris.guisson@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #ifndef MSEENCRYPTEDSERVERAUTHENTICATE_H 0007 #define MSEENCRYPTEDSERVERAUTHENTICATE_H 0008 0009 #include "bigint.h" 0010 #include <peer/serverauthenticate.h> 0011 #include <util/sha1hash.h> 0012 0013 namespace mse 0014 { 0015 class RC4Encryptor; 0016 0017 const Uint32 MAX_SEA_BUF_SIZE = 608 + 20 + 20 + 8 + 4 + 2 + 512 + 2 + 68; 0018 /** 0019 @author Joris Guisson <joris.guisson@gmail.com> 0020 */ 0021 class EncryptedServerAuthenticate : public bt::ServerAuthenticate 0022 { 0023 Q_OBJECT 0024 public: 0025 EncryptedServerAuthenticate(mse::EncryptedPacketSocket::Ptr sock); 0026 ~EncryptedServerAuthenticate() override; 0027 0028 private Q_SLOTS: 0029 void onReadyRead() override; 0030 0031 private: 0032 void handleYA(); 0033 void sendYB(); 0034 void findReq1(); 0035 void calculateSKey(); 0036 void processVC(); 0037 void handlePadC(); 0038 void handleIA(); 0039 0040 private: 0041 enum State { 0042 WAITING_FOR_YA, 0043 WAITING_FOR_REQ1, 0044 FOUND_REQ1, 0045 FOUND_INFO_HASH, 0046 WAIT_FOR_PAD_C, 0047 WAIT_FOR_IA, 0048 NON_ENCRYPTED_HANDSHAKE, 0049 }; 0050 BigInt xb, yb, s, ya; 0051 bt::SHA1Hash skey, info_hash; 0052 State state; 0053 Uint8 buf[MAX_SEA_BUF_SIZE]; 0054 Uint32 buf_size; 0055 Uint32 req1_off; 0056 Uint32 crypto_provide, crypto_select; 0057 Uint16 pad_C_len; 0058 Uint16 ia_len; 0059 RC4Encryptor *our_rc4; 0060 }; 0061 0062 } 0063 0064 #endif