Browse code

pdf: empty key safety check

David Raynor authored on 2012/12/18 06:44:16
Showing 1 changed files
... ...
@@ -619,7 +619,9 @@ static void aes_decrypt(const unsigned char *in, off_t *length, unsigned char *q
619 619
     } else
620 620
 	memset(iv, 0, sizeof(iv));
621 621
 
622
+    cli_dbgmsg("aes_decrypt: Calling rijndaelSetupDecrypt\n");
622 623
     nrounds = rijndaelSetupDecrypt(rk, key, key_n*8);
624
+    cli_dbgmsg("aes_decrypt: Beginning rijndaelDecrypt\n");
623 625
     while (len >= 16) {
624 626
 	unsigned i;
625 627
 	rijndaelDecrypt(rk, nrounds, in, q);
... ...
@@ -715,6 +717,10 @@ static char *decrypt_any(struct pdf_struct *pdf, uint32_t id, const char *in, of
715 715
 	    break;
716 716
 	case ENC_AESV3:
717 717
 	    cli_dbgmsg("cli_pdf: enc is aesv3\n");
718
+	    if (pdf->keylen == 0) {
719
+	        cli_dbgmsg("cli_pdf: no key\n");
720
+	        return NULL;
721
+	    }
718 722
 	    aes_decrypt(in, length, q, pdf->key, pdf->keylen, 1);
719 723
 	    noisy_msg(pdf, "decrypted AES(v3) data\n");
720 724
 	    break;