public void WithInvalidKey_Throws() { var options = new ChannelOptions(new CipherParams(Crypto.DefaultAlgorithm, new byte[] { 1, 2, 3 })); var encoder = new CipherEncoder(); var error = Assert.Throws <AblyException>(delegate { encoder.Encode(new Message { Data = "string" }, options.ToDecodingContext()); }); error.InnerException.Should().BeOfType <CryptographicException>(); }
public void WithInvalidKeyLength_Throws() { var options = new ChannelOptions(new CipherParams(Crypto.DefaultAlgorithm, new byte[] { }, keyLength: 10)); var encoder = new CipherEncoder(Protocol.MsgPack); var error = Assert.Throws <AblyException>(delegate { encoder.Encode(new Message() { Data = "string" }, options); }); error.InnerException.Should().BeOfType <CryptographicException>(); }
public void WithInvalidAlgorithm_Throws() { var keyGen = new Rfc2898DeriveBytes("password", 8); var key = keyGen.GetBytes(Crypto.DefaultKeylength / 8); var options = new ChannelOptions(new CipherParams("mgg", key)); var encoder = new CipherEncoder(); var error = Assert.Throws <AblyException>(() => { encoder.Encode(new Message { Data = "string" }, options.ToDecodingContext()); }); error.Message.Should().Contain("Currently only the AES encryption algorithm is supported"); }