示例#1
0
        public Boolean Initialise()
        {
            Boolean retVal = false;

            try
            {
                _state = Common.NodeState.Initialising;
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Initialising AESEncryptNode.");
                //Clear outputs
                EncryptedData.SetValue(null);

                retVal = true;
            }
            finally
            {
                _state = retVal ? Common.NodeState.Ready : Common.NodeState.Error;
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Initialised AESEncryptNode.");
            }
            return(retVal);
        }
示例#2
0
        public Boolean Initialise()
        {
            Boolean retVal = false;

            try
            {
                _state = Common.NodeState.Initialising;
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Initialising FileReaderNode.");

                //Clear outputs
                StringContents.SetValue(String.Empty);

                retVal = true;
            }
            finally
            {
                _state = retVal ? Common.NodeState.Ready : Common.NodeState.Error;
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Initialised FileReaderNode.");
            }
            return(retVal);
        }
示例#3
0
        public bool Process()
        {
            Boolean retVal = false;

            try
            {
                _state = Common.NodeState.Processing;
                using (Rfc2898DeriveBytes derive = new Rfc2898DeriveBytes((String)_password.Value, _salt.Value, _iterations.Value))
                {
                    Byte[] key = derive.GetBytes(_keyLength.Value);
                    _derivedKey.SetValue(key);
                    retVal = true;
                }
            }
            finally
            {
                _state = Common.NodeState.Processed;
                if (retVal)
                {
                    Processed?.Invoke(this, EventArgs.Empty);
                }
            }
            if (retVal)
            {
                if (_next != null && _next.Length > 0)
                {
                    return(_next[0].Process());
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
示例#4
0
        public bool Process()
        {
            Boolean retVal = false;

            try
            {
                _state = Common.NodeState.Processing;
                SCrypt scrypt = new SCrypt(Iterations.Value, BlockSize.Value, ThreadCount.Value);
                byte[] saltOut;
                byte[] bytes = scrypt.DeriveBytes((String)_password.Value, _salt.Value, out saltOut);
                _derivedKey.SetValue(bytes);
                retVal = true;
            }
            finally
            {
                _state = Common.NodeState.Processed;
                if (retVal)
                {
                    Processed?.Invoke(this, EventArgs.Empty);
                }
            }
            if (retVal)
            {
                if (_next != null && _next.Length > 0)
                {
                    return(_next[0].Process());
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
示例#5
0
        public bool Process()
        {
            Boolean retVal = false;

            try
            {
                _state = Common.NodeState.Processing;
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Base64 encoding.");
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Input = {0}.", ((Byte[])UnencodedData.Value).ToPrettyString());
                _encodedData.SetValue(Convert.ToBase64String((Byte[])UnencodedData.Value));
                retVal = true;
            }
            finally
            {
                _state = Common.NodeState.Processed;
                if (retVal)
                {
                    Processed?.Invoke(this, EventArgs.Empty);
                }
            }
            if (retVal)
            {
                if (_next != null && _next.Length > 0)
                {
                    return(_next[0].Process());
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
示例#6
0
        public Boolean Process()
        {
            Boolean retVal = false;

            try
            {
                _state = Common.NodeState.Processing;
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Processing AESDecryptNode.");

                if (IV.Value == null)
                {
                    //Split IV from the data
                    using (MemoryStream dataWithIV = new MemoryStream(EncryptedData.Value))
                    {
                        Byte[] iv = new Byte[16];
                        dataWithIV.Read(iv, 0, iv.Length);
                        Byte[] dataBlock = new Byte[dataWithIV.Length - iv.Length];
                        dataWithIV.Read(dataBlock, 0, dataBlock.Length);
                        IV.SetValue(iv);
                        EncryptedData.SetValue(dataBlock);
                    }
                }

                Byte[] inBlock = (Byte[])EncryptedData.Value;
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Creating AES decryptor.");
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Key = {0}.", ((Byte[])Key.Value).ToPrettyString());
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "IV = {0}.", ((Byte[])IV.Value).ToPrettyString());
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Input = {0}.", inBlock.ToPrettyString());

                Byte[] outBlock = AESUtility.DecryptBytes(inBlock, (Byte[])Key.Value, (Byte[])IV.Value);
                _unencryptedData.SetValue(UnicodeEncoding.Unicode.GetString(outBlock));
                retVal = true;
            }
            catch (Exception ex)
            {
                _state = Common.NodeState.Error;
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.Fail | DFramework.Logging.Interfaces.LoggerMessageType.Exception | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Exception occurred in AESDecryptNode :: {0}", ex.ToString());
                retVal = false;
            }
            finally
            {
                _state = Common.NodeState.Processed;
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Processed AESDecryptNode.");
                if (retVal)
                {
                    Processed?.Invoke(this, EventArgs.Empty);
                }
            }
            if (retVal)
            {
                if (_next != null && _next.Length > 0)
                {
                    return(_next[0].Process());
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
示例#7
0
        public Boolean Process()
        {
            Boolean retVal = false;

            try
            {
                _state = Common.NodeState.Processing;

                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Processing AESEncryptNode.");

                Boolean randomIV = false;
                if (IV.Value == null)
                {
                    Byte[] iv = SimpleRandomGenerator.QuickGetRandomBytes(16);
                    IV.SetValue(iv);
                    randomIV = true;
                }

                Byte[] inBlock = UnicodeEncoding.Unicode.GetBytes((String)PlainText.Value);
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Creating AES encryptor.");
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Key = {0}.", ((Byte[])Key.Value).ToPrettyString());
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "IV = {0}.", ((Byte[])IV.Value).ToPrettyString());
                DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information | DFramework.Logging.Interfaces.LoggerMessageType.Sensitive, "Input = {0}.", inBlock.ToPrettyString());

                Byte[] outBlock = AESUtility.EncryptBytes(inBlock, (Byte[])Key.Value, (Byte[])IV.Value);

                if (randomIV)
                {
                    using (MemoryStream dataWithIV = new MemoryStream())
                    {
                        dataWithIV.Write(IV.Value, 0, IV.Value.Length);
                        dataWithIV.Write(outBlock, 0, outBlock.Length);
                        dataWithIV.Flush();
                        _encryptedData.SetValue(dataWithIV.ToArray());
                    }
                }
                else
                {
                    _encryptedData.SetValue(outBlock);
                }

                retVal = true;
            }
            finally
            {
                _state = Common.NodeState.Processed;
                if (retVal)
                {
                    Processed?.Invoke(this, EventArgs.Empty);
                }
            }
            if (retVal)
            {
                if (_next != null && _next.Length > 0)
                {
                    return(_next[0].Process());
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }