email - 多个收件人的 SMIME 解密

标签 email encryption jakarta-mail smime

我想用JAVA开发一个基于SMIME的应用程序。在某些领域,我需要对 SMIME 加密/解密进行更多说明。 我了解在单个收件人的情况下如何对消息进行加密和解密。

如果只有一个收件人

  • 随机生成的 session key ,用于加密消息内容。
  • 然后,该随机 session key 将使用接收者的公钥进行加密,然后发送 SMIME 消息。
  • 加密的消息将使用接收者的私钥解密并检索 用于在接收方加密消息的 session key 。

如果有多个收件人,则

  • 随机生成的 session key ,用于加密消息内容。
  • 如果将消息发送给多个收件人,则对称 key 将由每个收件人的公钥单独加密。封装的消息和所有加密的对称 key 使用 PKCS#7 格式打包在一起。
  • 然后,该随机 session key 将使用每个接收者的公钥进行加密,然后发送 SMIME 消息。

如果多个接收者加密 session key 带有相同的消息,

  • 接收端的解密是如何完成的?
  • 接收方是否迭代所有加密的 session key 并尝试解密 session key ?
  • 如果有 50 个接收者,那么接收者是否需要解密所有接收者的密文以获得 session key ?

有人可以帮助我找到任何有用的资源或为我的问题提供答案吗?

最佳答案

If a message is being sent to multiple recipients, the symmetric key is encrypted separately by every recipient's public key.

对称 session key 还可以选择对发送者进行非对称加密。

all encrypted symmetric keys are packaged together

每个接收者都有一个 block ,其中包含加密 key 、所用证书的序列号等。

Then this random session key will be encrypted using each receiver's public key then send SMIME message.

事实并非如此。上面的步骤就足够了。生成的对称 session key 需要对每个接收者(和发送者)进行非对称加密,而不是更多。

它在 CMS RFC5652 中定义和 S/MIME RFC5751 。 S/MIME 消息由 MIME 主体和 CMS 内容类型组成。对于每个收件人(和发件人),必须有一个 CMS RecipientInfo Type 。该类型中包含哪个加密 key 属于哪个接收者的信息。

openssl cms -inform smime -in Test_enc.mbox -cmsout -print
CMS_ContentInfo: 
  contentType: pkcs7-envelopedData (1.2.840.113549.1.7.3)
  d.envelopedData: 
    version: <ABSENT>
    originatorInfo: <ABSENT>
    recipientInfos:
      d.ktri: 
        version: <ABSENT>
        d.issuerAndSerialNumber: 
          issuer: C=.., ST=.., L=.., O=.., OU=.., CN=..
          serialNumber: 16756039346226544442
        keyEncryptionAlgorithm:
          algorithm: rsaEncryption (1.2.840.113549.1.1.1)
          parameter: NULL
        encryptedKey:
          0000 - 07 b9 dc b8 97 ed ea b0-8f 9c 30 fa 0c f6 a0   ..........0....
          ...
          01fe - f0 62                                          .b
        
      d.ktri: 
        version: <ABSENT>
        d.issuerAndSerialNumber: 
          issuer: C=.., ST=.., L=.., O=.., OU=.., CN=..
          serialNumber: 16756039346226544442
        keyEncryptionAlgorithm:
          algorithm: rsaEncryption (1.2.840.113549.1.1.1)
          parameter: NULL
        encryptedKey:
          0000 - 07 b9 dc b8 97 ed ea b0-8f 9c 30 fa 0c f6 a0   ..........0....
          ...
          01fe - f0 62                                          .b

由于这封邮件是为我自己加密的,因此该 block 被包含两次,作为发送者和接收者。

  • How the decryption in receiver side is done?
  • Is the receiver iterate all encrypted session key and try to decrypt for session key?
  • If there are 50 recipients, then does the receiver need to decrypt all recipient's encrypted text for session key?

接收者只需搜索适当的 issuerserial numberrecipientInfos列表以查找正确的加密 key 。

关于email - 多个收件人的 SMIME 解密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18953707/

相关文章:

c++ - mailto:在没有安装邮件客户端的 URL 中

没有 SMTP 的 JavaMail

spring-boot - 如何让 JavaMailSender 不会因为错误的邮件密码而导致应用程序上下文加载失败?

linux - 使用mailx时如何重命名附件?

java - 如何在Java中反序列化xml文件中的电子邮件列表?

asp.net - 纯文本电子邮件中的英镑符号

java - 在 Java Web 应用程序中存储密码变量的不同方法?

performance - 是否可以通过HTTPS运行所有网络流量?

php - 为什么重置后散列不同?

java - 在 AWT 应用程序中处理图像解密 key