AES256 CTR-错误“此算法的指定密钥不是有效大小”

时间:2019-08-02 02:55:51

标签: c#

在我们的应用程序中,使用第三方工具对文件进行加密,而我们必须对文件进行解密。我们负责提供密钥和IV。但是我们无法将其解密回来,并且不会出现错误。

如果我使用openssl可以正常工作,并且能够成功解密文件

所有详细信息均附在此处,请帮助我丢失的内容。

public string Decrypt(string cipherText, string key, string IV)
{
    var rm = new RijndaelManaged();
    rm.BlockSize = 256;
    rm.KeySize = 256;
    rm.Mode = CipherMode.ECB;
    rm.Padding = PaddingMode.None;

    var encryptedValue = Encoding.ASCII.GetBytes(cipherText);
    var byteKey = ConvertStringToByte(key);
    var byteIV = ConvertStringToByte(IV);
    var DecryptorTransform = rm.CreateDecryptor(byteKey, byteIV); <-- **error is here**

code copied from here

示例键

  

密钥(64个字符):d3dda598fc93a90d3de733fd3de733fdc1bb863de733fdc1bb86fbdc1bb86fb   IV(32个字符):d3dda598fc93a90d3de733fdc1bb86fb

错误详细信息

"message": "Specified key is not a valid size for this algorithm.",
"details": "CryptographicException: Specified key is not a valid size for this algorithm.\r\nSTACK TRACE:    at
     

System.Security.Cryptography.RijndaelManagedTransform.GenerateKeyExpansion(Byte []   rgbKey)\ r \ n位于   System.Security.Cryptography.RijndaelManagedTransform..ctor(Byte []   rgbKey,CipherMode模式,Byte [] rgbIV,Int32 blockSize,Int32   feedbackSize,PaddingMode,PaddingValue,RijndaelManagedTransformMode   transformMode)\ r \ n位于   System.Security.Cryptography.RijndaelManaged.NewEncryptor(Byte []   rgbKey,CipherMode模式,Byte [] rgbIV,Int32 feedbackSize,   RijndaelManagedTransformMode cryptoMode)\ r \ n位于   System.Security.Cryptography.RijndaelManaged.CreateDecryptor(Byte []   rgbKey,字节[] rgbIV)\ r \ n在   Helix.Bdc.Services.AccessMaangement.SecretManager.Decrypt(String   cipherText,字符串密钥,字符串IV)

0 个答案:

没有答案