MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / ProcessDestGenerate

Method ProcessDestGenerate

libi2pd_client/SAM.cpp:806–829  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

804 }
805
806 void SAMSocket::ProcessDestGenerate (std::string_view buf)
807 {
808 LogPrint (eLogDebug, "SAM: Dest generate");
809 auto params = ExtractParams (buf);
810 // extract signature type
811 i2p::data::SigningKeyType signatureType = i2p::data::SIGNING_KEY_TYPE_DSA_SHA1;
812 i2p::data::CryptoKeyType cryptoType = i2p::data::CRYPTO_KEY_TYPE_ELGAMAL;
813 auto signatureTypeStr = params[SAM_PARAM_SIGNATURE_TYPE];
814 if (!signatureTypeStr.empty ())
815 {
816 if (!m_Owner.ResolveSignatureType (signatureTypeStr, signatureType))
817 LogPrint (eLogWarning, "SAM: ", SAM_PARAM_SIGNATURE_TYPE, " is invalid ", signatureTypeStr);
818 }
819 params.Get (SAM_PARAM_CRYPTO_TYPE, cryptoType);
820 auto keys = i2p::data::PrivateKeys::CreateRandomKeys (signatureType, cryptoType, true);
821#ifdef _MSC_VER
822 size_t l = sprintf_s (m_Buffer, SAM_SOCKET_BUFFER_SIZE, SAM_DEST_REPLY,
823 keys.GetPublic ()->ToBase64 ().c_str (), keys.ToBase64 ().c_str ());
824#else
825 size_t l = snprintf (m_Buffer, SAM_SOCKET_BUFFER_SIZE, SAM_DEST_REPLY,
826 keys.GetPublic ()->ToBase64 ().c_str (), keys.ToBase64 ().c_str ());
827#endif
828 SendMessageReply ({m_Buffer, l}, false);
829 }
830
831 void SAMSocket::ProcessNamingLookup (std::string_view buf)
832 {

Callers

nothing calls this directly

Calls 6

LogPrintFunction · 0.85
CreateRandomKeysFunction · 0.85
ResolveSignatureTypeMethod · 0.80
ToBase64Method · 0.80
GetPublicMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected