Esempio n. 1
0
        /// <summary>
        /// Initializes encryptor and decryptor.
        /// </summary>
        protected override void SessionEstablished()
        {
            lock (this)
            {
                Rijndael rijndael = Rijndael.Create();
                rijndael.Key  = this.RijndaelKey;
                rijndael.Mode = CipherMode.ECB;

                if (this._encryptor == null)
                {
                    this._encryptor = rijndael.CreateEncryptor();
                    this._decryptor = rijndael.CreateDecryptor();
                }

                // LOG:
                BinaryLogWriter binaryLogWriter = GenuineLoggingServices.BinaryLogWriter;
                if (binaryLogWriter != null && binaryLogWriter[LogCategory.Security] > 0)
                {
                    binaryLogWriter.WriteEvent(LogCategory.Security, "SecuritySession_SelfEstablishingSymmetric.SessionEstablished",
                                               LogMessageType.SecuritySessionKey, null, null, this.Remote, null,
                                               GenuineUtility.CurrentThreadId, Thread.CurrentThread.Name, this,
                                               this.Name, -1,
                                               0, 0, 0, "Encryption with " + rijndael.GetType().ToString(), null, null, null,
                                               "Security Session security information is initialized.");
                }
            }

            base.SessionEstablished();
        }