code: public void getCipherStream(BlockCipher aesCipher, byte[] out, int length, byte[] iv) {
          System.arraycopy(iv, 0, cipherInBlock, 0, 14);
  
          int ctr;
          for (ctr = 0; ctr < length / BLKLEN; ctr++) {
              // compute the cipher stream
              cipherInBlock[14] = (byte) ((ctr & 0xFF00) >> 8);
              cipherInBlock[15] = (byte) ((ctr & 0x00FF));
  
              aesCipher.processBlock(cipherInBlock, 0, out, ctr * BLKLEN);
          }
  
          // Treat the last bytes:
          cipherInBlock[14] = (byte) ((ctr & 0xFF00) >> 8);
          cipherInBlock[15] = (byte) ((ctr & 0x00FF));
  
          aesCipher.processBlock(cipherInBlock, 0, tmpCipherBlock, 0);
          System.arraycopy(tmpCipherBlock, 0, out, ctr * BLKLEN, length % BLKLEN);
      }
docs: Computes the cipher stream for AES CM mode. See section 4.1.1 in RFC3711
  for detailed description.
  
  @param out
  byte array holding the output cipher stream
  @param length
  length of the cipher stream to produce, in bytes
  @param iv
  initialization vector used to generate this cipher stream