Skip to main content

ctr_encrypt

Function ctr_encrypt 

Source
pub fn ctr_encrypt<C: BlockCipher>(cipher: &C, nonce: &[u8], data: &mut [u8])
Expand description

Encrypt (or decrypt) data in CTR mode.

The nonce is used as the initial counter block. For a 128-bit cipher, the nonce should typically be 12 bytes; the remaining 4 bytes are used as a big-endian counter starting from 1. For shorter nonces, the counter occupies the remaining bytes.

CTR mode is symmetric: encrypt and decrypt are the same operation.