+ assert (f->error);
+ msg (ME, _("%s: encrypted file corrupted (ends in incomplete %u-byte "
+ "ciphertext block)"),
+ fh_get_file_name (f->fh), overhang);
+ f->error = EIO;
+ f->readable -= overhang;
+ }
+
+ /* Decrypt all the blocks we have. */
+ for (size_t ofs = 0; ofs < f->readable; ofs += 16)
+ rijndaelDecrypt (f->rk, f->Nr,
+ CHAR_CAST (const char *, f->ciphertext + ofs),
+ CHAR_CAST (char *, f->plaintext + ofs));
+
+ /* If we're at end of file then check the padding and trim it off. */
+ if (f->error == EOF)
+ {
+ unsigned int pad = check_padding (&f->plaintext[f->n - 16]);
+ if (!pad)
+ {
+ msg (ME, _("%s: encrypted file corrupted (ends with bad padding)"),
+ fh_get_file_name (f->fh));
+ f->error = EIO;
+ return;
+ }
+
+ f->readable -= pad;