| 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 | { |
nothing calls this directly
no test coverage detected