UDP 加密 - 简单且安全

发布于 2024-10-01 03:01:34 字数 311 浏览 5 评论 0原文

嘿嘿!

我正在用 Qt/C++ 编写一个应用程序,用于在对等点之间创建连接。我的协议的第一步是让新的对等点广播其信息,请求来自已建立的对等点的连接。这些同伴的位置未知。

为此,我使用 UDP 广播。由于该广播包含有关对等方的信息,因此我希望对其进行加密。然而,当对等点之间建立 TCP 连接时,就会发生对等身份验证,因此除了 UDP 广播之外,仍然有很多安全性,但我只是不想太容易被第 3 方拦截和解释。

我正在寻找一种加密数据报的简单方法。

任何人都可以建议一种可靠的方法吗?

谢谢一百万!

Heyo!

I am writing an application in Qt/C++ that creates connections between peers. The first step in my protocol is for a new peer to broadcast it's information, soliciting connections from established peers. The location of these peers is unknown.

To do this I am using a UDP Broadcast. Since this broadcast contains information about the peer, I would like it to be encrypted. However, peer authentication happens when a TCP connection is established between peers, so there is still plenty of security beyond the UDP broadcast, but I just don't want to be too easily intercepted and interpreted by a 3rd party.

What I am looking for is a simple way to encrypt the datagram.

Can anyone suggest a reliable method?

Thanks a million!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

最单纯的乌龟 2024-10-08 03:01:34

您几乎可以使用任何您想要的加密方法,更重要/更困难的是密钥分发。

EG 如果所有客户端都使用相同的对称加密方法(例如 AES),那么广播信息将被加密,但任何反编译您的客户端的人都可能能够找到密钥。

看一下:

如何加密和解密文件使用 Qt/C++?

You can use pretty much any encryption method you want what is more important/difficult is key distribution.

E.G. if all the clients just use the same symmetric encryption method like AES then the broadcast information will be encrypted but anyone who decompiles your client may be able to find out the key.

Have a look at :

How to encrypt and decrypt a file with Qt/C++?

ま柒月 2024-10-08 03:01:34

当向未知主机广播消息时,您将放弃您的 IP 地址和端口号。您必须拥有预共享密钥才能使广播有意义,正如“大脑”指出的那样,这限制了您的安全能力。如果您感觉足够安全,所有客户端都能够解密,并且任何人都可以解密,那么您就可以了。您可以使用任何对称形式的加密并且相对安全。对于非常简单的情况,在这种情况下对数据进行异或就足够了。

如果您希望广播更加安全,请将广播消息设为 Diffie-Hellman 密钥交换消息。此后的其余交换可以是单播的,并为每个客户端使用不同的号码。这将允许每个单独的连接都有一个新密钥。假设有人可以重新实现您的协议并假装成为对等点,但他们将无法从任何其他对等点获取信息。

When broadcasting a message to unknown hosts, you will be giving up your IP address and port number. You would have to have a pre-shared key for a broadcast to be meaningful, and as "brain" pointed out, that limits your ability to be secure. If you are feeling sufficiently secure with all clients being able to decrypt as well as anybody who reverses it, then you'll be ok. You can use any symmetric form of encryption and be relatively safe. For the very simplistic, XORing the data could be sufficient in this case.

If you want to be more secure in your broadcast, make your broadcast message a Diffie-Hellman key exchange message. The rest of the exchange after that can be unicast and use different numbers for each client. This would permit a new key for every individual connection. Granted somebody could re-implement your protocols and fake being a peer, but they wouldn't be able to get information from any other peers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文