MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / authchallenge_cb

Method authchallenge_cb

src/torcontrol.cpp:574–607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

572}
573
574void TorController::authchallenge_cb(TorControlConnection& _conn, const TorControlReply& reply)
575{
576 if (reply.code == 250) {
577 LogPrint(BCLog::TOR, "tor: SAFECOOKIE authentication challenge successful\n");
578 std::pair<std::string,std::string> l = SplitTorReplyLine(reply.lines[0]);
579 if (l.first == "AUTHCHALLENGE") {
580 std::map<std::string,std::string> m = ParseTorReplyMapping(l.second);
581 if (m.empty()) {
582 LogPrintf("tor: Error parsing AUTHCHALLENGE parameters: %s\n", SanitizeString(l.second));
583 return;
584 }
585 std::vector<uint8_t> serverHash = ParseHex(m["SERVERHASH"]);
586 std::vector<uint8_t> serverNonce = ParseHex(m["SERVERNONCE"]);
587 LogPrint(BCLog::TOR, "tor: AUTHCHALLENGE ServerHash %s ServerNonce %s\n", HexStr(serverHash), HexStr(serverNonce));
588 if (serverNonce.size() != 32) {
589 LogPrintf("tor: ServerNonce is not 32 bytes, as required by spec\n");
590 return;
591 }
592
593 std::vector<uint8_t> computedServerHash = ComputeResponse(TOR_SAFE_SERVERKEY, cookie, clientNonce, serverNonce);
594 if (computedServerHash != serverHash) {
595 LogPrintf("tor: ServerHash %s does not match expected ServerHash %s\n", HexStr(serverHash), HexStr(computedServerHash));
596 return;
597 }
598
599 std::vector<uint8_t> computedClientHash = ComputeResponse(TOR_SAFE_CLIENTKEY, cookie, clientNonce, serverNonce);
600 _conn.Command("AUTHENTICATE " + HexStr(computedClientHash), boost::bind(&TorController::auth_cb, this, _1, _2));
601 } else {
602 LogPrintf("tor: Invalid reply to AUTHCHALLENGE\n");
603 }
604 } else {
605 LogPrintf("tor: SAFECOOKIE authentication challenge failed\n");
606 }
607}
608
609void TorController::protocolinfo_cb(TorControlConnection& _conn, const TorControlReply& reply)
610{

Callers

nothing calls this directly

Calls 9

SplitTorReplyLineFunction · 0.85
ParseTorReplyMappingFunction · 0.85
SanitizeStringFunction · 0.85
ParseHexFunction · 0.85
HexStrFunction · 0.85
ComputeResponseFunction · 0.85
CommandMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected