Questions tagged [ctr-mode]

CTR is a mode of operation for block ciphers where a nonce and (block-)counter are encrypted together by the block cipher and the result is XORed with the plaintext. This effectively transforms a block cipher into a stream cipher. Questions having this tag should be about the proper use and intricacies associated with the CTR mode.

CTR is a mode of operation for block ciphers where a nonce and (block-)counter are encrypted together by the block cipher and the result is XORed with the plaintext. This effectively transforms a block cipher into a stream cipher where exactly the same algorithm is used for encryption and decryption.

enter image description here

AES for example has a block size of 128-bit. Although the NIST recommendation sp800-38a Appendix B doesn't specify how it is split into nonce and counter, the nonce is usually a 96-bit integer and the counter a 32-bit integer.

When a nonce+counter is reused for the same key, this gives an attacker a non-negligible advantage at recovering the plaintext. That is why only 64 GByte (=block size * counter size) of data can be securely encrypted in case of AES.

References:
Why must IV/key-pairs not be reused in CTR mode?
CTR-mode on Wikipedia
NIST recommendation sp800-38a Appendix B

21 questions
0
votes
2 answers

Best way to replace files in place safely and efficiently?

I am trying to encrypt a file in place using cryptography module, so I dont have to buffer the ciphertext of the file which can be memory intensive and then i will have to replace the original file with it's encrypted one.so my solution is…
KMG
  • 1,433
  • 1
  • 8
  • 19
0
votes
0 answers

should I use aes ctr mode?

I have a question. For example I have text: "The quick brown fox jumps over the dog!" It has 32 letters. If I encrypt the first 16 letters with key: "11111111111111111111111111111111" and nonce: "1111111111111111" and next 16 letters with the…
korozya
  • 17
  • 6
0
votes
2 answers

CCCryptorCreateWithMode ignores padding parameter

I'm trying to use CommonCrypto for crypting with AES-CTR and PKCS7 padding. I am aware that CTR does not need padding in order to work correctly, there are uses for padding beyond that. Quoting RFC 3686: For this reason, AES-CTR does not require…
Raphael
  • 9,779
  • 5
  • 63
  • 94
0
votes
1 answer

Crypto++ CTR mode manual implement

I am trying to make CTR manually on top of ECB mode (but still) using Crypto++. The idea is: For single block: Just use ECB For multiple block, use CTR algorithm (AFAIK): //We have n block of plain data -> M PlainData M[n]; key; iv; char…
Andiana
  • 1,912
  • 5
  • 37
  • 73
0
votes
1 answer

Tinkering with pyDes mode of operation

So, in pyDes, a cryptographic library of DES, there is an API, which goes like this pyDes.des(key, [mode], [IV], [pad], [padmode]). An usage of it goes like this k = des("DESCRYPT", CBC, "\0\0\0\0\0\0\0\0", pad=None, padmode=PAD_PKCS5) - where I can…
motiur
  • 1,640
  • 9
  • 33
  • 61
0
votes
1 answer

Decrypting AES/CTR video while watching

It is possible to decrypt an encrypted video in AES/CTR and and watching as it was being decrypted? I want to decrypt Video hosted on MEGA.co.nz and go watching as that goes down without waiting for the download to complete. I already know how to…
1
2