MimeKit使用AES加密消息 [英] MimeKit encrypt Message with AES

查看:64
本文介绍了MimeKit使用AES加密消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用MimeKit加密并签署邮件.

I want du encrypt and sign a mail with MimeKit.

生成消息的工作原理:

        CmsRecipient CmsRecipient = new CmsRecipient("mail.cer");
        CmsRecipient.EncryptionAlgorithms = new EncryptionAlgorithm[] { EncryptionAlgorithm.Aes192 };
        to1.Add(CmsRecipient);

        var signed = MultipartSigned.Create(ctx, signer, multipart);
        var encrypted = ApplicationPkcs7Mime.Encrypt(ctx, to1, signed);
        message.Body = MultipartSigned.Create(ctx, signer, encrypted);

在Outlook中,它们以168位3DES加密但是我需要AES265.如何管理它?

In Outlook they arrive encrypted with: 168 Bit 3DES But I need AES 265. How can I manage this?

我可以使用

        signer.DigestAlgorithm = DigestAlgorithm.Sha512;

但不加密.

已更新为我的解决方案

推荐答案

CmsSigner指定DigestAlgorithm,但是CmsRecipient指定收件人支持的加密算法.

The CmsSigner specifies the DigestAlgorithm, but it's the CmsRecipient that specifies which encryption algorithm(s) that the recipient supports.

MimeKit选择加密算法的方式是,找出每个收件人所支持的最佳加密算法,然后使用它.

The way that the encryption algorithm is chosen by MimeKit is that it figures out the best encryption algorithm supported by each recipient and then uses that.

换句话说,如果您要加密5个收件人,并且所有收件人都支持AES256,则MimeKit将使用AES256.但是,如果其中一个收件人仅支持3DES(而其他所有收件人 也都支持3DES和AES256),则选择3DES.

In other words, if you are encrypting to 5 recipients and all of them support AES256, then MimeKit will use AES256. But if one of the recipients only supports, for example, 3DES (and all of the other recipients also support 3DES as well as AES256), then 3DES is chosen instead.

这篇关于MimeKit使用AES加密消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆