System.Security.Cryptography.DES.IsLegalKeySize C# (CSharp) Method

IsLegalKeySize() private static method

private static IsLegalKeySize ( byte rgbKey ) : bool
rgbKey byte
return bool
        private static bool IsLegalKeySize(byte[] rgbKey)
        {
            if (rgbKey != null && rgbKey.Length == 8)
                return true;

            return false;
        }

Usage Example

Beispiel #1
0
        /// <summary>确定指定的密钥是否为半弱密钥。</summary>
        /// <returns>如果该密钥为半弱密钥,则为 true;否则,为 false。</returns>
        /// <param name="rgbKey">要进行半弱漏洞测试的机密密钥。</param>
        /// <exception cref="T:System.Security.Cryptography.CryptographicException">
        /// <paramref name="rgbKey" /> 参数的大小无效。</exception>
        public static bool IsSemiWeakKey(byte[] rgbKey)
        {
            if (!DES.IsLegalKeySize(rgbKey))
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
            }
            switch (DES.QuadWordFromBigEndian(Utils.FixupKeyParity(rgbKey)))
            {
            case 143554428589179390:
            case 18303189645120372225:
            case 2296870857142767345:
            case 16149873216566784270:
            case 135110050437988849:
            case 16141428838415593729:
            case 2305315235293957886:
            case 18311634023271562766:
            case 80784550989267214:
            case 2234100979542855169:
            case 16212643094166696446:
            case 18365959522720284401:
                return(true);

            default:
                return(false);
            }
        }
All Usage Examples Of System.Security.Cryptography.DES::IsLegalKeySize