Neos.IdentityServer 3.0/Neos.IdentityServer.Common/Neos.IdentityServer.MultiFactor.ServiceUtils.cs
/// <summary>
/// EncryptBuffer method implementation (compress)
/// </summary>
EncryptBuffer method implementation (compress)
EncryptBuffer method implementation ( compress )
private ArraySegment<byte> EncryptBuffer(ArraySegment<byte> buffer, BufferManager bufferManager, int messageOffset)
            {
                byte[] unencryptedBytes = new byte[buffer.Count];
                Array.Copy(buffer.Array, buffer.Offset, unencryptedBytes, 0, unencryptedBytes.Length);
                byte[] cryptedBytes = null;
                using (AESSystemEncryption aes = new AESSystemEncryption())
                {
                    cryptedBytes = aes.Encrypt(unencryptedBytes);
                }
                int totalLength = messageOffset + cryptedBytes.Length;
                byte[] bufferManagerBuffer = bufferManager.TakeBuffer(totalLength);
                Array.Clear(bufferManagerBuffer, 0, bufferManagerBuffer.Length);
                Array.Copy(cryptedBytes, 0, bufferManagerBuffer, messageOffset, cryptedBytes.Length);
                bufferManager.ReturnBuffer(buffer.Array);
                ArraySegment<byte> byteArray = new ArraySegment<byte>(bufferManagerBuffer, messageOffset, cryptedBytes.Length);               
                return byteArray;
            }
private ArraySegment < byte > EncryptBuffer ( ArraySegment < byte > buffer , BufferManager bufferManager , int messageOffset ) { byte [ ] unencryptedBytes = new byte [ buffer . Count ] ; Array . Copy ( buffer . Array , buffer . Offset , unencryptedBytes , 0 , unencryptedBytes . Length ) ; byte [ ] cryptedBytes = null ; using ( AESSystemEncryption aes = new AESSystemEncryption ( ) ) { cryptedBytes = aes . Encrypt ( unencryptedBytes ) ; } int totalLength = messageOffset + cryptedBytes . Length ; byte [ ] bufferManagerBuffer = bufferManager . TakeBuffer ( totalLength ) ; Array . Clear ( bufferManagerBuffer , 0 , bufferManagerBuffer . Length ) ; Array . Copy ( cryptedBytes , 0 , bufferManagerBuffer , messageOffset , cryptedBytes . Length ) ; bufferManager . ReturnBuffer ( buffer . Array ) ; ArraySegment < byte > byteArray = new ArraySegment < byte > ( bufferManagerBuffer , messageOffset , cryptedBytes . Length ) ; return byteArray ; }
EncryptBuffer method implementation (compress)
EncryptBuffer method implementation ( compress )
buffer
ArraySegment<byte>
bufferManager
BufferManager
messageOffset
int