我正在尝试使用身份证书加密最终的mdm配置文件(在SCEP有效负载之后得到响应)。 我有以下代码:
context.Request.InputStream.CopyTo(deviceResponse);
var signer = new SignedCms();
signer.Decode(deviceResponse.ToArray());
X509Certificate2 certificate = signer.Certificates[0];
string str= sonething; //my final configuraton profile
encryptedProfile = AESEncryption(str, cerificate.GetPublicKeyString(), true, Encoding.Default, pkcs);
我得到了例外:密钥长度不是128/192/256位。
如何加密最终的个人资料(我正在使用Bouncy Castle图书馆)?
此致
马格
答案 0 :(得分:1)
看起来你的“cerificate.GetPublicKeyString()”没有返回一个具有propper长度(128/192/256位)的密钥。您需要的最小值是128位(16字节= 16长度)。
答案 1 :(得分:0)
这不应该是AES加密。它必须是CMSAlgorithm.DES_EDE3_CBC加密。