Initialize an AES context with just mbedtls_aes_setkey_enc() for both encrypting or decrypting; Put a random value in nonce_counter (This is your nonce + counter within the nonce) Use something like CTR-DRBG. Have a local variable nc_off with a value of 0. the value is updated by the function so it knows where in a 'AES block' it left off.

7620

AES counter-mode (CTR) implementation in JavaScript (c) Chris Veness long; // initialise 1st 8 bytes of counter block with nonce (NIST SP800-38A §B.2): [0-1] 

A keyed hash  Jun 3, 2012 This video is part of an online course, Applied Cryptography. Check out the course here: https://www.udacity.com/course/cs387.