ccm_ctr_mode() function
Variation of CTR mode used in CCM. The CTR mode used by CCM is slightly different than the conventional CTR mode (the counter is increased before encryption, instead of after encryption). Besides, it is assumed that the counter is stored in the last 2 bytes of the nonce.