Fix encryption pad handling. Fixes #1238.