M2Crypto,立即加密和签名?

发布于 2024-10-21 16:59:50 字数 351 浏览 0 评论 0原文

这可能是我所缺少的明显的东西。

我想让我的主机使用客户端的公钥加密发送给客户端的消息,并使用主机的私钥对该消息进行签名。

这似乎是一个显而易见的场景,但也许我的概念根本就是错误的。我认为您应该能够使用一条消息来完成,就像您使用 PGP 所看到的那样。使用 M2Crypto 可以轻松完成此操作吗?

我尝试先加密消息,然后对其进行签名,但收到消息“RSAError:摘要对于 rsa 密钥来说太大”。

我宁愿不将加密消息及其签名作为两个单独的数据发送。

编辑: 目前我正在使用自定义分隔符,将消息与签名分开,但我觉得这是不好的形式,并且该格式应该对我正在尝试的内容进行规定。

This might be something obvious that I'm missing.

I would like to have my host encrypt a message to a client using the client's public key, and also have that message signed using the hosts private key.

It seems like an obvious scenario, but perhaps my concept is simply wrong. I think that you should be able to do with with a single message, much like you see using PGP. Can this be done with M2Crypto easily?

I tried first encrypting the message and then signing it but I get the message "RSAError: digest too big for rsa key".

I would rather not send the encrypted message and its signature as two separate pieces of data.

Edit:
For the time being I'm using a custom delimiter, to separate the message from the signature, but I feel like this is bad form, and that the format should have provisions for what I'm attempting.

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

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

发布评论

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

评论(1

鸠书 2024-10-28 16:59:50

听起来您正在寻找一种混合加密系统,它可以同时处理加密和签名,使用适当的加密原语以使其能够在任何数据大小的情况下工作,并封装该系统的所有组件。密码在一处。 PGP、HTTPS 和 DHIES 就是很好的例子。虽然在我看来您可以使用 m2crypto 实现这样的系统,但您可能不应该;重用现有协议比推出自己的协议要好得多。很容易犯一些难以发现的错误,从而使安全措施变得毫无用处。

It sounds like you're looking for a hybrid cryptosystem which takes care of encryption and signature together, using appropriate crypto primitives to allow it to work whatever the size of the data, and encapsulating all the components of the cryptogram in one place. PGP, HTTPS and DHIES are good examples. While it seems to me that you could implement such a system using m2crypto, you probably shouldn't; you're much better off reusing an existing protocol than rolling your own. It's far too easy to make mistakes which are hard to spot and render the security useless.

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