Fixed key_stream implementation.