More refactoring of internal cipher API.