generateNewKey now supports any size