ndn-lite
Functions
tc_ctr_mode.c File Reference
#include "tc_constants.h"
#include "tc_ctr_mode.h"
#include "tc_utils.h"

Functions

int tc_ctr_mode (uint8_t *out, unsigned int outlen, const uint8_t *in, unsigned int inlen, uint8_t *ctr, const TCAesKeySched_t sched)
 CTR mode encryption/decryption procedure. More...
 

Function Documentation

◆ tc_ctr_mode()

int tc_ctr_mode ( uint8_t *  out,
unsigned int  outlen,
const uint8_t *  in,
unsigned int  inlen,
uint8_t *  ctr,
const TCAesKeySched_t  sched 
)

CTR mode encryption/decryption procedure.

CTR mode encrypts (or decrypts) inlen bytes from in buffer into out buffer

Returns
returns TC_CRYPTO_SUCCESS (1) returns TC_CRYPTO_FAIL (0) if: out == NULL or in == NULL or ctr == NULL or sched == NULL or inlen == 0 or outlen == 0 or inlen != outlen
Note
Assumes:- The current value in ctr has NOT been used with sched
  • out points to inlen bytes
  • in points to inlen bytes
  • ctr is an integer counter in littleEndian format
  • sched was initialized by aes_set_encrypt_key
Parameters
outOUT – produced ciphertext (plaintext)
outlenIN – length of ciphertext buffer in bytes
inIN – data to encrypt (or decrypt)
inlenIN – length of input data in bytes
ctrIN/OUT – the current counter value
schedIN – an initialized AES key schedule