예제 #1
0
 /// <summary>
 /// Checks if the instance has a valid key
 /// </summary>
 /// <returns>true, if key is valid</returns>
 public bool IsValid()
 {
     //We currently don't allow keys that only have the private key parts set.
     //This means a key must either have the public part only, or both parts.
     //"x || (x && y)" can be simplified as just "x" due to the 4 possibilities collapsing:
     //true || (true && false)   --> true
     //true || (true && true)    --> true
     //false || (false && false) --> false
     //false || (false && true)  --> false
     return(RSAEncryption.HasPublicKey(Key));
 }
예제 #2
0
 private void InitRSA()
 {
     lvRSA.Items.Clear();
     foreach (var Key in Settings.LoadRSAKeys())
     {
         var Item = lvRSA.Items.Add(Key.Name);
         Item.Tag = Key;
         Item.SubItems.Add(Key.Size.ToString());
         Item.SubItems.Add(RSAEncryption.HasPublicKey(Key.Key) ? "Yes" : "No");
         Item.SubItems.Add(RSAEncryption.HasPrivateKey(Key.Key) ? "Yes" : "No");
     }
 }
예제 #3
0
 /// <summary>
 /// Encrypts data using the given RSA public key
 /// </summary>
 /// <param name="Data">Data to encrypt</param>
 /// <param name="Password">Key to encrypt the data with</param>
 /// <returns>Encrypted data</returns>
 private static AesCryptoData EncryptWithRSAKey(byte[] Data, RSAParameters Params)
 {
     if (RSAEncryption.HasPublicKey(Params))
     {
         return(new AesCryptoData()
         {
             IV = null,
             Salt = null,
             Data = RSAEncryption.Encrypt(Params, Data)
         });
     }
     throw new CryptographicException("The supplied RSA key lacks the public key parts");
 }
예제 #4
0
 private void InitRSA()
 {
     lvRSA.Items.Clear();
     foreach (var Key in Settings.LoadRSAKeys())
     {
         var Item = lvRSA.Items.Add(Key.Name);
         Item.Tag = Key;
         Item.SubItems.Add(Key.Size.ToString());
         Item.SubItems.Add(RSAEncryption.HasPublicKey(Key.Key) ? "Yes" : "No");
         Item.SubItems.Add(RSAEncryption.HasPrivateKey(Key.Key) ? "Yes" : "No");
     }
     foreach (var Key in AppSettings.GetAdministrativeKeys())
     {
         var Item = lvRSA.Items.Add(Key.Name);
         Item.Tag       = null;
         Item.BackColor = System.Drawing.Color.FromArgb(0xFF, 0xAA, 0xAA);
         Item.SubItems.Add(Key.Size.ToString());
         Item.SubItems.Add(RSAEncryption.HasPublicKey(Key.Key) ? "Yes" : "No");
         Item.SubItems.Add(RSAEncryption.HasPrivateKey(Key.Key) ? "Yes" : "No");
     }
 }