Can I use AES in CTR mode in .NET?

jnm2 picture jnm2 · Jun 16, 2011 · Viewed 15.9k times · Source

.NET's AES does not implement CTR directly. It only implements CBC, CFB, CTS, ECB and OFB.

Can I use any of these modes and securely implement CTR around them, or do I need to use a different library altogether?

Answer

Cheeso picture Cheeso · Sep 12, 2011

Yes, you can build a CTR using .NET's AES in ECB mode and a counter, that you yourself initialize and increment, for each block encrypted.

An example of this is the WinZipAes encryption stream, which is part of the open-source DotNetZip.
WinZip specifies the use of AES encryption for encrypted ZIP files, using AES in CTR mode. DotNetZip implements the CTR mode using ECB and the counter.

See here for some comments.