Gareth Lennox

XTS-AES implementation: SectorStream

As a by-product of the XtsSharp project, I implemented a SectorStream, which is a stream that reads and writes whole sectors (the size of which is configurable) to enable the XTS algorithm to operate on standard .NET streams.

I also implemented another stream based class that provides random access to an underlying SectorStream. This simulates random access by reading and writing entire sectors at once. This stream is called (yep, you guessed it) RandomAccessSectorStream.

The result is that you can use the random access stream to wrap a SectorStream and read and write to it as if it was just a normal .NET stream. It supports seeking to arbitrary points and reading / writing. The class handles the sector by sector reading and writing, which when using an XTSSectorStream, encrypts (when writing) and decrypts (when reading).

I’m not sure if this is usable outside of the XTS project, but it is completely separate code-wise, so maybe someone will find a use for it.

XTS-AES implementation in .NET

I’ve been meaning to write about this for some time, but laziness, procrastination and work have managed to get in the way.

DISCLAIMER: I am not a cryptographer, cryptography is something that interests me and the library is a proof of concept; you use it at your own risk.

I recently (i.e. a year ago!) wrote an implementation of the XTS algorithm in .NET (C#). I had asked a question on stackoverflow, but didn’t get much of a response. The only other implementations I found were in C or C++.

Continue reading →

A new home for my blog

This site has now moved to it’s own domain (, rather than sitting in a subdirectory under another domain.

I managed to move it in the space of a couple of hours, without too many hassles. The main problem was that wordpress doesn’t like to have it’s main url changed from underneath it, so I had to get into the database and tweak some values. There is a good guide in the wordpress codex on how to do this.

Otherwise, marring some obscure file permission problems, it was very straight forward.

One other benefit of having my own domain is that I get to set the favicon for it, which is a smaller version of my logo. I used this handy tool to convert the favicon into a .ico format.