指定的初始化向量(IV)与此算法的块大小不匹配。参数名称:rgbIV [英] Specified initialization vector (IV) does not match the block size for this algorithm. Parameter name: rgbIV

查看:1403
本文介绍了指定的初始化向量(IV)与此算法的块大小不匹配。参数名称:rgbIV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,

Hello All,

最近我们将代码从.net Framework 4.0转换为.Net Core 2.0。所有的事情都工作得很好,除了下面。

Recently we convert our code from .net Framework 4.0 to .Net Core 2.0. all thing are working fine except below.

我们使用Triple DES算法,我得到了错误 在下面的行。 ivsize返回128和blockie只有64。

we are use Triple DES algorithm and i got error  on following line. ivsize return 128 and blocksie only 64.

if(ivSize!= BlockSize) 抛出新的ArgumentException(SR.Cryptography_InvalidIVSize,nameof(rgbIV));

if (ivSize != BlockSize)  throw new ArgumentException(SR.Cryptography_InvalidIVSize, nameof(rgbIV));

它在生产模式下的.net framework 4.0中工作正常。

It is working fine in .net framework 4.0 in production mode.

是.net Core 2.0中的三重DES算法有任何变化

Is there any change in Triple DES algorithm in .net Core 2.0

            if(rgbKey == null)

               抛出新的ArgumentNullException(nameof(rgbKey));
$


            long keySize = rgbKey.Length *(long)BitsPerByte;

           如果(密钥大小> int.MaxValue || IsLegalSize(((int)的密钥大小),LegalKeySizes)!)

         &NBSP ;     抛出新的ArgumentException(SR.Cryptography_InvalidKeySize,nameof(rgbKey));



             if(rgbIV!= null)

            {

                Int64 ivSize = rgbIV.Length *(Int64)BitsPerByte;

               如果(ivSize = BLOCKSIZE!)

                 &NBSP ; 抛出新的ArgumentException(SR.Cryptography_InvalidIVSize,nameof(rgbIV));

            }

            if (rgbKey == null)
                throw new ArgumentNullException(nameof(rgbKey));

            long keySize = rgbKey.Length * (long)BitsPerByte;
            if (keySize > int.MaxValue || !IsLegalSize(((int)keySize),LegalKeySizes))
                throw new ArgumentException(SR.Cryptography_InvalidKeySize, nameof(rgbKey));

            if (rgbIV != null)
            {
                Int64 ivSize = rgbIV.Length * (Int64)BitsPerByte;
                if (ivSize != BlockSize)
                    throw new ArgumentException(SR.Cryptography_InvalidIVSize, nameof(rgbIV));
            }

等待有用的回复。

谢谢,

Sanjay Patel

Sanjay Patel

谢谢,Sanjay Patel ------------

Thanks, Sanjay Patel ------------

推荐答案

嗯......但我认为
IV的长度通常与块大小相同

自.NET以来就已经详细说明
v2

This has been spelt out since the days of .NET v2


这篇关于指定的初始化向量(IV)与此算法的块大小不匹配。参数名称:rgbIV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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