Neos.IdentityServer 3.1/Neos.IdentityServer.MultiFactor.Security/Neos.IdentityServer.MultiFactor.Security.Services.cs
/// <summary>
/// DecryptBuffer method implementation (decompress)
/// </summary>
DecryptBuffer method implementation (decompress)
DecryptBuffer method implementation ( decompress )
private ArraySegment<byte> DecryptBuffer(ArraySegment<byte> buffer, BufferManager bufferManager)
            {
                byte[] cryptedBytes = new byte[buffer.Count];
                Array.Copy(buffer.Array, buffer.Offset, cryptedBytes, 0, cryptedBytes.Length);
                byte[] unencryptedBytes = null;
                using (AESSystemEncryption aes = new AESSystemEncryption())
                {
                    unencryptedBytes = aes.Decrypt(cryptedBytes);
                }
                int totalLength = unencryptedBytes.Length + buffer.Offset;
                byte[] bufferManagerBuffer = bufferManager.TakeBuffer(totalLength);
                Array.Clear(bufferManagerBuffer, 0, bufferManagerBuffer.Length);
                Array.Copy(buffer.Array, 0, bufferManagerBuffer, 0, buffer.Offset);
                Array.Copy(unencryptedBytes, 0, bufferManagerBuffer, buffer.Offset, unencryptedBytes.Length);
                ArraySegment<byte> byteArray = new ArraySegment<byte>(bufferManagerBuffer, buffer.Offset, unencryptedBytes.Length);
                bufferManager.ReturnBuffer(buffer.Array);
                return byteArray;
            }
private ArraySegment < byte > DecryptBuffer ( ArraySegment < byte > buffer , BufferManager bufferManager ) { byte [ ] cryptedBytes = new byte [ buffer . Count ] ; Array . Copy ( buffer . Array , buffer . Offset , cryptedBytes , 0 , cryptedBytes . Length ) ; byte [ ] unencryptedBytes = null ; using ( AESSystemEncryption aes = new AESSystemEncryption ( ) ) { unencryptedBytes = aes . Decrypt ( cryptedBytes ) ; } int totalLength = unencryptedBytes . Length + buffer . Offset ; byte [ ] bufferManagerBuffer = bufferManager . TakeBuffer ( totalLength ) ; Array . Clear ( bufferManagerBuffer , 0 , bufferManagerBuffer . Length ) ; Array . Copy ( buffer . Array , 0 , bufferManagerBuffer , 0 , buffer . Offset ) ; Array . Copy ( unencryptedBytes , 0 , bufferManagerBuffer , buffer . Offset , unencryptedBytes . Length ) ; ArraySegment < byte > byteArray = new ArraySegment < byte > ( bufferManagerBuffer , buffer . Offset , unencryptedBytes . Length ) ; bufferManager . ReturnBuffer ( buffer . Array ) ; return byteArray ; }
DecryptBuffer method implementation (decompress)
DecryptBuffer method implementation ( decompress )
buffer
ArraySegment<byte>
bufferManager
BufferManager