keystream handling