public void WhenDataSizeIsGreaterThanMaximumAllowedForKeyAndRSAParametersThenShouldThrowArgumentException()
        {
            int keySize = 384;

            byte[] data = new byte[AsymmetricCryptoUtil.GetMaxDataLength(384) * 2];

            Random random = new Random();

            random.NextBytes(data);

            AsymmetricCryptoUtil.GenerateKeys(keySize, out RSAParameters publicKey, out RSAParameters publicAndPrivateKey);

            Assert.ThrowsException <ArgumentOutOfRangeException>(() => AsymmetricCryptoUtil.Encrypt(data, keySize, publicKey));
        }
 public void WhenKeySizeIsOutOfRangeThenShouldThrowArgumentOutOfRangeException()
 {
     Assert.ThrowsException <ArgumentOutOfRangeException>(() => AsymmetricCryptoUtil.GetMaxDataLength(int.MaxValue));
 }
 public void WhenKeySizeIs2048ThenShouldReturnMaxDataLength215()
 {
     Assert.AreEqual(215, AsymmetricCryptoUtil.GetMaxDataLength(2048));
 }
 public void WhenKeySizeIs4096ThenShouldReturnMaxDataLength471()
 {
     Assert.AreEqual(471, AsymmetricCryptoUtil.GetMaxDataLength(4096));
 }