The encryption library in my programming language does not support CTR, though it supports CBC, CFB, CTS, ECB and OFB. I'm assuming it is theoretically possible to securely implement CTR around one of these other modes.
So I'm wondering, are these quotes describing correct implementation of CTR from a security perspective? As far as I've read I think they are, but I just want to make sure I'm not missing something.
I studied a bit more and found out that the block transform for CTR mode is really just the result of XOR'ing the plaintext with an AES ECB transform of a monotinically-increasing counter. With that understanding, I was able to implement a AES CTR mode pretty easily on top of the AES ECB mode that is built into the .NET BCL.
It is possible to implement AES crypto in CTR mode using the AesManaged class, though it requires some extra work. To implement CTR mode with the .NET AesManaged class, here's what I did: Use CipherMode.ECB, PaddingMode.None. [No padding is necessary in CTR mode because we are always encrypting a 16-byte counter.] When encrypting, call CreateEncryptor(). Using the resulting ICryptoTransform, for each block, transform a nonce of 16-bytes (Same as the AES block size), and then XOR the result of that transform with the plaintext to get the ciphertext. Increment the nonce after each block. Continue until there are no more blocks - don't forget the final block transform, for the last block of 16 or fewer bytes.
For one thing, when the quote says 'increment,' what kind of increment should it be? Surely not linear?