- SILC_GET32_MSB(ctr[0], iv);
- SILC_GET32_MSB(ctr[1], iv + 4);
- SILC_GET32_MSB(ctr[2], iv + 8);
- SILC_GET32_MSB(ctr[3], iv + 12);
-
- i = twofish->padlen;
- if (!i)
- i = 16;
-
- while (len-- > 0) {
- if (i == 16) {
- if (++ctr[3] == 0)
- if (++ctr[2] == 0)
- if (++ctr[1] == 0)
- ++ctr[0];
-
- tmp[0] = SILC_SWAB_32(ctr[0]);
- tmp[1] = SILC_SWAB_32(ctr[1]);
- tmp[2] = SILC_SWAB_32(ctr[2]);
- tmp[3] = SILC_SWAB_32(ctr[3]);
-
- twofish_encrypt(twofish, tmp, tmp);
-
- SILC_PUT32_LSB(tmp[0], iv);
- SILC_PUT32_LSB(tmp[1], iv + 4);
- SILC_PUT32_LSB(tmp[2], iv + 8);
- SILC_PUT32_LSB(tmp[3], iv + 12);
- i = 0;
- }
- *dst++ = *src++ ^ iv[i++];
- }
- twofish->padlen = i;
+ SILC_CTR_LSB_128_32(iv, ctr, tmp, twofish->padlen, src, dst,
+ twofish_encrypt(twofish, tmp, tmp));
+ break;