1. A method of generating a key stream comprising: applying a cryptographic function on input values selected from a first array of values to generate output values; selecting mask values from a second array of values; and combining the output values with the mask values to generate a key stream block for the key stream; wherein the first and second arrays are finite.