MCPcopy Create free account
hub / github.com/amule-project/amule / SendSignaturePacket

Method SendSignaturePacket

src/BaseClient.cpp:2065–2122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2063
2064
2065void CUpDownClient::SendSignaturePacket()
2066{
2067 // signate the public key of this client and send it
2068 wxCHECK2(m_socket != NULL, return);
2069 wxCHECK2(credits != NULL, return);
2070 wxCHECK2(m_SecureIdentState != 0, return);
2071
2072 if (!theApp->CryptoAvailable()) {
2073 return;
2074 }
2075 if (credits->GetSecIDKeyLen() == 0) {
2076 return; // We don't have his public key yet, will be back here later
2077 }
2078 // do we have a challenge value received (actually we should if we are in this function)
2079 if (credits->m_dwCryptRndChallengeFrom == 0){
2080 AddDebugLogLineN( logClient, wxString("Want to send signature but challenge value is invalid - User ") + GetUserName());
2081 return;
2082 }
2083 // v2
2084 // we will use v1 as default, except if only v2 is supported
2085 bool bUseV2;
2086 if ( (m_bySupportSecIdent&1) == 1 )
2087 bUseV2 = false;
2088 else
2089 bUseV2 = true;
2090
2091 uint8 byChaIPKind = 0;
2092 uint32 ChallengeIP = 0;
2093 if (bUseV2){
2094 if (::IsLowID(theApp->GetED2KID())) {
2095 // we cannot do not know for sure our public ip, so use the remote clients one
2096 ChallengeIP = GetIP();
2097 byChaIPKind = CRYPT_CIP_REMOTECLIENT;
2098 } else {
2099 ChallengeIP = theApp->GetED2KID();
2100 byChaIPKind = CRYPT_CIP_LOCALCLIENT;
2101 }
2102 }
2103 //end v2
2104 uint8_t achBuffer[250];
2105
2106 uint8 siglen = theApp->clientcredits->CreateSignature(credits, achBuffer, 250, ChallengeIP, byChaIPKind );
2107 wxCHECK2(siglen != 0, return);
2108
2109 CMemFile data;
2110 data.WriteUInt8(siglen);
2111 data.Write(achBuffer, siglen);
2112 if (bUseV2) {
2113 data.WriteUInt8(byChaIPKind);
2114 }
2115
2116 CPacket* packet = new CPacket(data, OP_EMULEPROT, OP_SIGNATURE);
2117
2118 theStats::AddUpOverheadOther(packet->GetPacketSize());
2119 AddDebugLogLineN( logLocalClient, "Local Client: OP_SIGNATURE to " + GetFullIP() );
2120 SendPacket(packet,true,true);
2121 m_SecureIdentState = IS_ALLREQUESTSSEND;
2122}

Callers 1

ProcessExtPacketMethod · 0.80

Calls 9

IsLowIDFunction · 0.85
GetSecIDKeyLenMethod · 0.80
CreateSignatureMethod · 0.80
WriteUInt8Method · 0.80
GetPacketSizeMethod · 0.80
wxStringClass · 0.70
CryptoAvailableMethod · 0.45
GetED2KIDMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected