Lines Matching refs:handshake

422 bool HdcDaemon::HandDaemonAuthInit(HSession hSession, const uint32_t channelId, SessionHandShake &handshake)
425 handshake.authType = AUTH_PUBLICKEY;
429 * Notice, before here is "handshake.buf = hSession->tokenRSA", but the server not use it
432 handshake.buf.clear();
433 Base::TlvAppend(handshake.buf, TAG_AUTH_TYPE, std::to_string(AuthVerifyType::RSA_3072_SHA512));
436 string bufString = SerialStruct::SerializeToString(handshake);
445 bool HdcDaemon::HandDaemonAuthPubkey(HSession hSession, const uint32_t channelId, SessionHandShake &handshake)
451 if (!GetHostPubkeyInfo(handshake.buf, hostname, pubkey)) {
464 std::thread notifymsg([this, &handshake, channelId, sessionId = hSession->sessionId, &confirmmsg]() {
465 this->EchoHandshakeMsg(handshake, channelId, sessionId, confirmmsg);
484 SendAuthSignMsg(handshake, channelId, hSession->sessionId, pubkey, hSession->tokenRSA);
490 EchoHandshakeMsg(handshake, channelId, hSession->sessionId, notifymsg);
645 bool HdcDaemon::HandDaemonAuthSignature(HSession hSession, const uint32_t channelId, SessionHandShake &handshake)
656 if (!AuthVerify(hSession, handshake.buf, token, pubkey)) {
659 EchoHandshakeMsg(handshake, channelId, hSession->sessionId, "[E000010]:Auth failed, cannt login the device.");
666 SendAuthOkMsg(handshake, channelId, hSession->sessionId);
678 bool HdcDaemon::HandDaemonAuth(HSession hSession, const uint32_t channelId, SessionHandShake &handshake)
683 SendAuthOkMsg(handshake, channelId, hSession->sessionId);
688 SendAuthOkMsg(handshake, channelId, hSession->sessionId);
690 } else if (handshake.version < "Ver: 3.0.0b") {
692 hSession->sessionId, handshake.version.c_str(), handshake.authType);
693 AuthRejectLowClient(handshake, channelId, hSession->sessionId);
700 if (handshake.authType == AUTH_NONE) {
701 return HandDaemonAuthInit(hSession, channelId, handshake);
702 } else if (handshake.authType == AUTH_PUBLICKEY) {
703 return HandDaemonAuthPubkey(hSession, channelId, handshake);
704 } else if (handshake.authType == AUTH_SIGNATURE) {
705 return HandDaemonAuthSignature(hSession, channelId, handshake);
707 WRITE_LOG(LOG_FATAL, "invalid auth state %d for session %u", handshake.authType, hSession->sessionId);
715 void HdcDaemon::GetServerCapability(HSession &hSession, SessionHandShake &handshake)
723 if (!Base::TlvToStringMap(handshake.buf, tlvMap)) {
734 void HdcDaemon::DaemonSessionHandshakeInit(HSession &hSession, SessionHandShake &handshake)
736 // daemon handshake 1st packet
738 hSession->sessionId = handshake.sessionId;
739 hSession->connectKey = handshake.connectKey;
745 handshake.ToDebugString().c_str());
755 handshake.sessionId = 0;
756 handshake.connectKey = "";
758 GetServerCapability(hSession, handshake);
764 // session handshake step2
766 SessionHandShake handshake;
768 SerialStruct::ParseFromString(handshake, s);
770 WRITE_LOG(LOG_DEBUG, "session %s try to handshake", hSession->ToDebugString().c_str());
773 if (handshake.banner != HANDSHAKE_MESSAGE) {
778 if (handshake.authType == AUTH_NONE) {
779 DaemonSessionHandshakeInit(hSession, handshake);
781 if (!HandDaemonAuth(hSession, channelId, handshake)) {
787 WRITE_LOG(LOG_DEBUG, "receive hs version = %s", handshake.version.c_str());
789 if (!handshake.version.empty() && handshake.version != version) {
791 handshake.version.c_str(), version.c_str());
794 handshake.banner = HANDSHAKE_FAILED;
795 string failedString = SerialStruct::SerializeToString(handshake);
801 if (handshake.version.empty()) {
802 handshake.version = Base::GetVersion();
803 WRITE_LOG(LOG_FATAL, "set version if check mode = %s", handshake.version.c_str());
805 // handshake auth OK.Can append the sending device information to HOST
893 // session handshake step2
1086 void HdcDaemon::SendAuthOkMsg(SessionHandShake &handshake, uint32_t channelid,
1093 if (handshake.version < "Ver: 3.0.0b") {
1097 handshake.buf = msg;
1103 handshake.buf = emgmsg;
1106 handshake.authType = AUTH_OK;
1107 string bufString = SerialStruct::SerializeToString(handshake);
1113 void HdcDaemon::SendAuthSignMsg(SessionHandShake &handshake,
1117 handshake.authType = AUTH_SIGNATURE;
1118 handshake.buf = token;
1119 string bufString = SerialStruct::SerializeToString(handshake);
1123 void HdcDaemon::EchoHandshakeMsg(SessionHandShake &handshake, uint32_t channelid, uint32_t sessionid, string msg)
1125 SendAuthOkMsg(handshake, channelid, sessionid, msg, DAEOMN_UNAUTHORIZED);
1129 void HdcDaemon::AuthRejectLowClient(SessionHandShake &handshake, uint32_t channelid, uint32_t sessionid)
1132 EchoHandshakeMsg(handshake, channelid, sessionid, msg);