/// <summary> /// Initialize the WopEx Encryption /// </summary> /// <param name="Key">The key to use</param> /// <param name="Salt">The Salt to use</param> /// <param name="InitialVector">The Salt to use</param> /// <param name="EncryptionCode">The encryption algorithm that was generated</param> /// <param name="DecryptionCode">The decryption algorithm that was generated</param> /// <param name="WopMode">The encryption mode</param> /// <param name="UseCompiler">Using the dynamic compiler will increase performance</param> public WopEx(byte[] Key, byte[] Salt, byte[] InitialVector, byte[] EncryptionCode, byte[] DecryptionCode, WopEncMode EncMode, uint Rounds, bool UseDynamicCompiler) { if (EncryptionCode.Length != DecryptionCode.Length) throw new Exception("Encryption and Decryption algorithms must be the same size"); if (Key.Length < 8 || Salt.Length < 8) throw new Exception("The Key and Salt must atleast have a size of 8"); if (InitialVector.Length < 32) throw new Exception("The Initial Vector must atleast have a size of 32"); if (Rounds == 0) throw new Exception("There must be atleast 1 round"); this.UseDynamicCompiler = UseDynamicCompiler; this.Key = new byte[Key.Length]; Array.Copy(Key, this.Key, Key.Length); this.Salt = new byte[Salt.Length]; Array.Copy(Salt, this.Salt, Salt.Length); this.Key = ExpandKey(this.Key); this.Salt = ExpandKey(this.Salt); this.Rounds = Rounds; this.EncMode = EncMode; this.EncState = new State(BytesToLongList(this.Key), BytesToLongList(this.Salt), BitConverter.ToInt32(this.Key, 0), BytesToLongList(ExpandKey(InitialVector)), false); this.EncState.Instructions = ReadAlgorithm(EncryptionCode); this.EncState.Compile(); this.DecState = new State(BytesToLongList(this.Key), BytesToLongList(this.Salt), BitConverter.ToInt32(this.Key, 0), BytesToLongList(ExpandKey(InitialVector)), true); this.DecState.Instructions = ReadAlgorithm(DecryptionCode); this.DecState.Compile(); }
/// <summary> /// Initialize the WopEx Encryption /// </summary> /// <param name="Key">The key to use</param> /// <param name="Salt">The Salt to use</param> /// <param name="InitialVector">The Salt to use</param> /// <param name="EncryptionCode">The encryption algorithm that was generated</param> /// <param name="DecryptionCode">The decryption algorithm that was generated</param> /// <param name="WopMode">The encryption mode</param> /// <param name="UseCompiler">Using the dynamic compiler will increase performance</param> public WopEx(byte[] Key, byte[] Salt, byte[] InitialVector, byte[] EncryptionCode, byte[] DecryptionCode, WopEncMode EncMode, uint Rounds, bool UseDynamicCompiler) { if (EncryptionCode.Length != DecryptionCode.Length) { throw new Exception("Encryption and Decryption algorithms must be the same size"); } if (Key.Length < 8 || Salt.Length < 8) { throw new Exception("The Key and Salt must atleast have a size of 8"); } if (InitialVector.Length < 32) { throw new Exception("The Initial Vector must atleast have a size of 32"); } if (Rounds == 0) { throw new Exception("There must be atleast 1 round"); } this.UseDynamicCompiler = UseDynamicCompiler; this.Key = new byte[Key.Length]; Array.Copy(Key, this.Key, Key.Length); this.Salt = new byte[Salt.Length]; Array.Copy(Salt, this.Salt, Salt.Length); this.Key = ExpandKey(this.Key); this.Salt = ExpandKey(this.Salt); this.Rounds = Rounds; this.EncMode = EncMode; this.EncState = new State(BytesToLongList(this.Key), BytesToLongList(this.Salt), BitConverter.ToInt32(this.Key, 0), BytesToLongList(ExpandKey(InitialVector)), false); this.EncState.Instructions = ReadAlgorithm(EncryptionCode); this.EncState.Compile(); this.DecState = new State(BytesToLongList(this.Key), BytesToLongList(this.Salt), BitConverter.ToInt32(this.Key, 0), BytesToLongList(ExpandKey(InitialVector)), true); this.DecState.Instructions = ReadAlgorithm(DecryptionCode); this.DecState.Compile(); }