예제 #1
0
파일: DES.cs 프로젝트: ForNeVeR/pnet
 // Determine if a DES key value is "semi-weak".
 public static bool IsSemiWeakKey(byte[] rgbKey)
 {
     if (rgbKey == null || rgbKey.Length != 8)
     {
         throw new CryptographicException
                   (_("Crypto_InvalidKeySize"),
                   ((rgbKey == null) ? 0 : rgbKey.Length).ToString());
     }
     return(CryptoMethods.IsSemiWeakKey(rgbKey, 0));
 }
예제 #2
0
 // Generate a random key value.
 public override void GenerateKey()
 {
     byte[] key = new byte [8];
     do
     {
         CryptoMethods.GenerateRandom(key, 0, 8);
     }while(CryptoMethods.IsSemiWeakKey(key, 0) ||
            CryptoMethods.IsWeakKey(key, 0));
     if (KeyValue != null)
     {
         // Clear the previous key value.
         Array.Clear(KeyValue, 0, KeyValue.Length);
     }
     KeyValue = key;
 }