Implemented template class for CTR mode