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 ) ; }
Computes the cipher stream for AES CM mode . See section 4 . 1 . 1 in RFC3711 for detailed description .