Exemplo n.º 1
0
        public static bool IsSemiWeakKey(byte[] rgbKey)
        {
            if (!IsLegalKeySize(rgbKey))
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
            }
            byte[] rgbOddParityKey = Utils.FixupKeyParity(rgbKey);
            UInt64 key             = QuadWordFromBigEndian(rgbOddParityKey);

            if ((key == 0x01fe01fe01fe01fe) ||
                (key == 0xfe01fe01fe01fe01) ||
                (key == 0x1fe01fe00ef10ef1) ||
                (key == 0xe01fe01ff10ef10e) ||
                (key == 0x01e001e001f101f1) ||
                (key == 0xe001e001f101f101) ||
                (key == 0x1ffe1ffe0efe0efe) ||
                (key == 0xfe1ffe1ffe0efe0e) ||
                (key == 0x011f011f010e010e) ||
                (key == 0x1f011f010e010e01) ||
                (key == 0xe0fee0fef1fef1fe) ||
                (key == 0xfee0fee0fef1fef1))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
 /// <summary>Determines whether the specified key is weak.</summary>
 /// <param name="rgbKey">The secret key to test for weakness. </param>
 /// <returns>
 ///     <see langword="true" /> if the key is weak; otherwise, <see langword="false" />.</returns>
 /// <exception cref="T:System.Security.Cryptography.CryptographicException">The size of the <paramref name="rgbKey" /> parameter is not valid. </exception>
 // Token: 0x060023CB RID: 9163 RVA: 0x000824C8 File Offset: 0x000806C8
 public static bool IsWeakKey(byte[] rgbKey)
 {
     if (!TripleDES.IsLegalKeySize(rgbKey))
     {
         throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
     }
     byte[] array = Utils.FixupKeyParity(rgbKey);
     return(TripleDES.EqualBytes(array, 0, 8, 8) || (array.Length == 24 && TripleDES.EqualBytes(array, 8, 16, 8)));
 }
Exemplo n.º 4
0
 public static bool IsWeakKey(byte[] rgbKey)
 {
     if (!IsLegalKeySize(rgbKey))
     {
         throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
     }
     byte[] buffer = Utils.FixupKeyParity(rgbKey);
     return(EqualBytes(buffer, 0, 8, 8) || ((buffer.Length == 0x18) && EqualBytes(buffer, 8, 0x10, 8)));
 }
Exemplo n.º 5
0
        /// <summary>Determines whether the specified key is weak.</summary>
        /// <param name="rgbKey">The secret key to test for weakness. </param>
        /// <returns>
        ///     <see langword="true" /> if the key is weak; otherwise, <see langword="false" />.</returns>
        /// <exception cref="T:System.Security.Cryptography.CryptographicException">The size of the <paramref name="rgbKey" /> parameter is not valid. </exception>
        // Token: 0x06002159 RID: 8537 RVA: 0x00075F30 File Offset: 0x00074130
        public static bool IsWeakKey(byte[] rgbKey)
        {
            if (!DES.IsLegalKeySize(rgbKey))
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
            }
            byte[] block = Utils.FixupKeyParity(rgbKey);
            ulong  num   = DES.QuadWordFromBigEndian(block);

            return(num == 72340172838076673UL || num == 18374403900871474942UL || num == 2242545357694045710UL || num == 16204198716015505905UL);
        }
Exemplo n.º 6
0
        /// <summary>Determines whether the specified key is semi-weak.</summary>
        /// <param name="rgbKey">The secret key to test for semi-weakness. </param>
        /// <returns>
        ///     <see langword="true" /> if the key is semi-weak; otherwise, <see langword="false" />.</returns>
        /// <exception cref="T:System.Security.Cryptography.CryptographicException">The size of the <paramref name="rgbKey" /> parameter is not valid. </exception>
        // Token: 0x0600215A RID: 8538 RVA: 0x00075F98 File Offset: 0x00074198
        public static bool IsSemiWeakKey(byte[] rgbKey)
        {
            if (!DES.IsLegalKeySize(rgbKey))
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
            }
            byte[] block = Utils.FixupKeyParity(rgbKey);
            ulong  num   = DES.QuadWordFromBigEndian(block);

            return(num == 143554428589179390UL || num == 18303189645120372225UL || num == 2296870857142767345UL || num == 16149873216566784270UL || num == 135110050437988849UL || num == 16141428838415593729UL || num == 2305315235293957886UL || num == 18311634023271562766UL || num == 80784550989267214UL || num == 2234100979542855169UL || num == 16212643094166696446UL || num == 18365959522720284401UL);
        }
Exemplo n.º 7
0
        public static bool IsWeakKey(byte[] rgbKey)
        {
            if (!IsLegalKeySize(rgbKey))
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
            }
            ulong num = QuadWordFromBigEndian(Utils.FixupKeyParity(rgbKey));

            if (((num != 0x101010101010101L) && (num != 18374403900871474942L)) && ((num != 0x1f1f1f1f0e0e0e0eL) && (num != 16204198716015505905L)))
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 8
0
        public static bool IsSemiWeakKey(byte[] rgbKey)
        {
            if (!IsLegalKeySize(rgbKey))
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
            }
            ulong num = QuadWordFromBigEndian(Utils.FixupKeyParity(rgbKey));

            if (((((num != 0x1fe01fe01fe01feL) && (num != 18303189645120372225L)) && ((num != 0x1fe01fe00ef10ef1L) && (num != 16149873216566784270L))) && (((num != 0x1e001e001f101f1L) && (num != 16141428838415593729L)) && ((num != 0x1ffe1ffe0efe0efeL) && (num != 18311634023271562766L)))) && (((num != 0x11f011f010e010eL) && (num != 0x1f011f010e010e01L)) && ((num != 16212643094166696446L) && (num != 18365959522720284401L))))
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 9
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 IsWeakKey(byte[] rgbKey)
        {
            if (!DES.IsLegalKeySize(rgbKey))
            {
                throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
            }
            switch (DES.QuadWordFromBigEndian(Utils.FixupKeyParity(rgbKey)))
            {
            case 72340172838076673:
            case 18374403900871474942:
            case 2242545357694045710:
            case 16204198716015505905:
                return(true);

            default:
                return(false);
            }
        }
Exemplo n.º 10
0
 public static bool IsWeakKey(byte[] rgbKey)
 {
     // All we have to check for here is (a) we're in 3-key mode (192 bits), and
     // (b) either K1 == K2 or K2 == K3
     if (!IsLegalKeySize(rgbKey))
     {
         throw new CryptographicException(Environment.GetResourceString("Cryptography_InvalidKeySize"));
     }
     byte[] rgbOddParityKey = Utils.FixupKeyParity(rgbKey);
     if (EqualBytes(rgbOddParityKey, 0, 8, 8))
     {
         return(true);
     }
     if ((rgbOddParityKey.Length == 24) && EqualBytes(rgbOddParityKey, 8, 16, 8))
     {
         return(true);
     }
     return(false);
 }