Ejemplo n.º 1
0
        public void Initialize()
        {
            if (SecurityParameters.Cipher.BulkEncryptionAlgorithm == TLS.BulkEncryptionAlgorithm.aes)
            {
                //EncryptionAlgorithm = new AesManaged();
                EncryptionAlgorithm           = new Mono.Security.Cryptography.RijndaelManaged();
                EncryptionAlgorithm.BlockSize = SecurityParameters.Cipher.BlockSizeBytes * 8;
                EncryptionAlgorithm.KeySize   = SecurityParameters.Cipher.KeySizeBits;
                EncryptionAlgorithm.Key       = ClientWriteKey;
                EncryptionAlgorithm.IV        = ClientWriteIV;
                EncryptionAlgorithm.Padding   = Mono.Security.Cryptography.PaddingMode.None;
                //EncryptionTransform = EncryptionAlgorithm.CreateEncryptor(ClientWriteKey, ClientWriteIV);
                EncryptionTransform = EncryptionAlgorithm.CreateEncryptor();

                //Mono.Security.Cryptography.RSAManaged DecryptionAlgorithm = new Mono.Security.Cryptography.RSAManaged();
                DecryptionAlgorithm = new Mono.Security.Cryptography.RijndaelManaged();
                //DecryptionAlgorithm = new AesManaged();
                DecryptionAlgorithm.BlockSize = SecurityParameters.Cipher.BlockSizeBytes * 8;
                DecryptionAlgorithm.KeySize   = SecurityParameters.Cipher.KeySizeBits;
                DecryptionAlgorithm.Key       = ServerWriteKey;
                DecryptionAlgorithm.IV        = ServerWriteIV;
                LastCipherTextBlock           = ServerWriteIV;
                DecryptionAlgorithm.Padding   = Mono.Security.Cryptography.PaddingMode.None;
                DecryptionTransform           = DecryptionAlgorithm.CreateDecryptor(ServerWriteKey, ServerWriteIV);
            }
            /// TODO, add other sym encryption methods

            if (SecurityParameters.Cipher.MACAlgorithm == MACAlgorithm.sha)
            {
                ClientHMAC = new HMACSHA1(ClientWriteMACSecret);
                ServerHMAC = new HMACSHA1(ServerWriteMACSecret);
            }
        }
Ejemplo n.º 2
0
        public void Initialize()
        {
            if (SecurityParameters.Cipher.BulkEncryptionAlgorithm == TLS.BulkEncryptionAlgorithm.aes)
            {
                //EncryptionAlgorithm = new AesManaged();
                EncryptionAlgorithm = new Mono.Security.Cryptography.RijndaelManaged();
                EncryptionAlgorithm.BlockSize = SecurityParameters.Cipher.BlockSizeBytes * 8;
                EncryptionAlgorithm.KeySize = SecurityParameters.Cipher.KeySizeBits;
                EncryptionAlgorithm.Key = ClientWriteKey;
                EncryptionAlgorithm.IV = ClientWriteIV;
                EncryptionAlgorithm.Padding = Mono.Security.Cryptography.PaddingMode.None;
                //EncryptionTransform = EncryptionAlgorithm.CreateEncryptor(ClientWriteKey, ClientWriteIV);
                EncryptionTransform = EncryptionAlgorithm.CreateEncryptor();

                //Mono.Security.Cryptography.RSAManaged DecryptionAlgorithm = new Mono.Security.Cryptography.RSAManaged();
                DecryptionAlgorithm = new Mono.Security.Cryptography.RijndaelManaged();
                //DecryptionAlgorithm = new AesManaged();
                DecryptionAlgorithm.BlockSize = SecurityParameters.Cipher.BlockSizeBytes * 8;
                DecryptionAlgorithm.KeySize = SecurityParameters.Cipher.KeySizeBits;
                DecryptionAlgorithm.Key = ServerWriteKey;
                DecryptionAlgorithm.IV = ServerWriteIV;
                LastCipherTextBlock = ServerWriteIV;
                DecryptionAlgorithm.Padding = Mono.Security.Cryptography.PaddingMode.None;
                DecryptionTransform = DecryptionAlgorithm.CreateDecryptor(ServerWriteKey, ServerWriteIV);
            }
            /// TODO, add other sym encryption methods

            if (SecurityParameters.Cipher.MACAlgorithm == MACAlgorithm.sha)
            {
                ClientHMAC = new HMACSHA1(ClientWriteMACSecret);
                ServerHMAC = new HMACSHA1(ServerWriteMACSecret);
            }
        }