public void FailWithNotEqualsIvs() { var encoded = Xor.Encode("12345678901234567890123456789012", "12345678", "message", SBlockTypes.GOST); var decoded = Xor.Decode("12345678901234567890123456789012", "00000000", "message", SBlockTypes.GOST); Assert.IsNotNull(encoded); Assert.IsNotNull(decoded); Assert.IsNotEmpty(encoded); Assert.IsNotEmpty(decoded); Assert.AreNotEqual(decoded, encoded); }
public void PassWithStrings() { var encoded = Xor.Encode("12345678901234567890123456789012", "12345678", "message", SBlockTypes.GOST); var decoded = Xor.Decode("12345678901234567890123456789012", "12345678", "message", SBlockTypes.GOST); Assert.IsNotNull(encoded); Assert.IsNotNull(decoded); Assert.IsNotEmpty(encoded); Assert.IsNotEmpty(decoded); Assert.AreEqual(decoded, encoded); }
public void PassWithBytes() { byte[] key = Encoding.UTF8.GetBytes("12345678901234567890123456789012"); byte[] iv = Encoding.Default.GetBytes("12345678"); byte[] message = Encoding.Default.GetBytes("message"); var encoded = Xor.Encode(key, iv, message, SBlockTypes.GOST); var decoded = Xor.Decode(key, iv, message, SBlockTypes.GOST); Assert.IsNotNull(encoded); Assert.IsNotNull(decoded); Assert.IsNotEmpty(encoded); Assert.IsNotEmpty(decoded); Assert.AreEqual(decoded, encoded); }
private byte[] DecryptGost(Stream s) { using (var key = new Rfc2898DeriveBytes(Key, Salt)) { using (var aesAlg = new RijndaelManaged()) { var gostIV = ReadByteArray(s); var gostKey = key.GetBytes(aesAlg.KeySize / 8); var encrypted = new byte[s.Length - s.Position]; s.Read(encrypted, 0, encrypted.Length); return(Xor.Decode(gostKey, gostIV, encrypted, SBlockTypes.GOST)); } } }