public void encryptUsingPublicKeyAndDoesNotDecryptUsingDifferentPrivateKey()
    {
        RSAAsymmetricCryptography asymmetricCryptographyOther = new RSAAsymmetricCryptography("");
        Encryption encryption = new Encryption();

        byte[] encryptedText = encryption.encrypt(TEXT, asymmetricCryptography.getPublicKey());

        var ex = Assert.Throws <Exception>(() => encryption.decryption(encryptedText,
                                                                       asymmetricCryptographyOther.getPrivateKey()));

        Assert.That(ex.Message, Is.EqualTo("Private key wrong"));
    }
Exemple #2
0
    public void deleteKey(string name)
    {
        RSAAsymmetricCryptography rSAAsymmetricCryptographyRemoved = null;

        foreach (RSAAsymmetricCryptography rSAAsymmetricCryptography in rSAAsymmetricCryptographies)
        {
            if (rSAAsymmetricCryptography.name.Equals(name))
            {
                rSAAsymmetricCryptographyRemoved = rSAAsymmetricCryptography;
            }
        }
        rSAAsymmetricCryptographies.Remove(rSAAsymmetricCryptographyRemoved);
    }
Exemple #3
0
 public override string action()
 {
     name = getCommandInformation(commandDistributeds[1]);
     rsa  = rSAController.getKey(name);
     if (rsa == null)
     {
         return(THE_KEY_DOES_NOT_EXIST + name);
     }
     else
     {
         return("\n Key private: " + rsa.getPrivateKey());
     }
 }
Exemple #4
0
    public override string action()
    {
        string keyName = getCommandInformation(commandDistributeds[1]);

        rsa = rSAController.getKey(keyName);

        if (rsa == null)
        {
            return(THE_KEY_DOES_NOT_EXIST + keyName);
        }
        else
        {
            return(keyAlreadyExists());
        }
    }