+static const char *mode_ctr(Byte *data, int blocks,
+ const Byte *iv, Byte *counter,
+ const BlockCipherAlgInfo *alg, int encr,
+ const void *sch) {
+ int blocksize= alg->blocksize;
+ Byte *cipher= counter + blocksize;
+ int byte;
+
+ memcpy(counter, iv, blocksize);
+ while (blocks > 0) {
+ alg->encrypt.crypt(sch, counter, cipher);
+ memxor(data, cipher, blocksize);
+ for (byte=blocksize-1; byte>=0; byte--) {
+ if (++counter[byte]) break;
+ /* new value of zero implies carry, so increment next byte */
+ }
+ blocks--;
+ data += blocksize;
+ }
+ return 0;
+}
+
+const BlockCipherModeInfo cht_blockciphermodeinfo_entries[]= {