fixing key/iv generation routines