RSA可以同时用作加密和签名吗?

发布于 2024-10-26 09:25:11 字数 204 浏览 0 评论 0 原文

很抱歉,但我的脑子突然对这个问题一片空白......

编辑(场景)

如果我希望信息绕过像 f-ck 这样的简单过滤器,可以用公钥加密信息吗,并用私钥签名?

公钥可能已经被双方交换过了,而且公钥也很难得到。

编辑2

信息本身可能没有那么多凭据。

加密和签名的目的是为了绕过和完整性。

I am sorry but my mind suddenly goes blank for this question....

EDIT (Scenario)

If I want information to bypass simple filters like f-ck, is it OK to encrypt the information with public key, and sign by private key?

The public key may have already exchanged by both sides, and it is even hard to get the public key.

EDIT 2

The information itself may not that much credential.

The point of encryption and signature is for bypassing and integrity.

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

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

发布评论

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

评论(2

靑春怀旧 2024-11-02 09:25:11

RSA 是两种算法:一种用于非对称加密,另一种用于签名。碰巧这两种算法可以使用相同的私钥结构(这是混乱的根源:许多文档,包括 RSA 标准,尝试将签名解释为“用私钥加密”,这充其量是不准确的)。

对两种用途使用相同的密钥是可能的,但并不真正推荐,因为两种用途之间的交互尚未得到充分探索;此外,加密密钥和签名密钥通常具有不同的生命周期,具有不同的保护机制(例如,您通常希望保留用于加密的私钥的备份,以防止数据丢失:丢失私钥意味着丢失所有数据)已使用该密钥加密;而您不需要签名密钥的备份)。

你的场景有点不清楚。非对称加密使用公钥,而生成签名则使用私钥。如果 A 想要向 B 发送一条带有加密(为了机密性)和签名(为了完整性)的消息,那么 A 将使用 B 知道其私钥的公钥对数据进行加密; A 将使用 B 知道其公钥的私钥对数据进行签名。这需要两对密钥:一对用于加密和解密(A 加密,B 解密,B 知道私钥),另一对用于签名(A 签名,B验证,A 知道私钥)。如果 A 和 B 都知道私钥,那么他们就有一个共享的秘密,并且使用对称加密(AES) 和完整性检查 ( HMAC)。

标准免责声明:您看起来像是在设计自己的加密协议。不要这样做。这条道路会导致无数其他聪明人偶然发现的同样的安全失败。使用经过验证的协议,例如 SSL/TLSOpenPGP

RSA is two algorithms: one for asymmetric encryption and one for signatures. It so happens that both algorithms can use the same private key structure (this is a source of confusion: many documentations, including the RSA standard, try to explain the signature as "an encryption with the private key", which is, at best, inaccurate).

Using the same key for both usages is possible, but not really recommended, because interactions between both kind of usages have not been fully explored; also, keys for encryption and keys for signatures usually have different life cycles with distinct protection mechanisms (for instance, you normally want to keep a backup of the private key for encryption, to prevent data loss: losing the private key means losing all data which has been encrypted with that key; while you do not want a backup of the signature key).

Your scenario is a bit unclear. Asymmetric encryption uses the public key, while generating the signature uses the private key. If A wants to send a message to B with encryption (for confidentiality) and a signature (for integrity), then A will encrypt the data with a public key for which B knows the private key; and A will sign the data with a private key for which B knows the public key. This calls for two pairs of key: one pair is used for encryption and decryption (A encrypts, B decrypts, B knows the private key), and the other pair is used for signatures (A signs, B verifies, A knows the private key). If both A and B know the private key, then they have a shared secret, and it is much simpler (and faster) to use symmetric encryption (AES) and integrity checks (HMAC).

Standard disclaimer: you look like you are designing your own cryptographic protocol. Do not do this. This road leads to the same security failures that countless other smart people have stumbled upon. Use a tried-and-proven protocol such as SSL/TLS or OpenPGP.

与他有关 2024-11-02 09:25:11

是:

  • 加密:您使用公共加密
    密钥,使用私有(显然)
  • 签名进行解密:使用私钥加密内容摘要(哈希),使用公共密钥进行验证

请参阅 http://en.wikipedia.org/wiki/RSA#Signing_messages

Yes:

  • encryption: you encrypt with public
    key, decrypt with private (obviously)
  • signing: you encrypt the content digest (hash) with private key, verify with public

See http://en.wikipedia.org/wiki/RSA#Signing_messages

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