From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 1/4] crypto: fix built-in AES decrypt function
Date: Tue, 28 Jul 2015 10:04:52 +0200 [thread overview]
Message-ID: <1438070695-24889-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1438070695-24889-1-git-send-email-pbonzini@redhat.com>
From: "Daniel P. Berrange" <berrange@redhat.com>
The qcrypto_cipher_decrypt_aes method was using the wrong
key material, and passing the wrong mode. This caused it
to incorrectly decrypt ciphertext.
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
Message-Id: <1437740634-6261-1-git-send-email-berrange@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
crypto/cipher-builtin.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/crypto/cipher-builtin.c b/crypto/cipher-builtin.c
index 912c1b9..30f4853 100644
--- a/crypto/cipher-builtin.c
+++ b/crypto/cipher-builtin.c
@@ -117,7 +117,7 @@ static int qcrypto_cipher_decrypt_aes(QCryptoCipher *cipher,
uint8_t *outptr = out;
while (len) {
if (len > AES_BLOCK_SIZE) {
- AES_decrypt(inptr, outptr, &ctxt->state.aes.encrypt_key);
+ AES_decrypt(inptr, outptr, &ctxt->state.aes.decrypt_key);
inptr += AES_BLOCK_SIZE;
outptr += AES_BLOCK_SIZE;
len -= AES_BLOCK_SIZE;
@@ -126,15 +126,15 @@ static int qcrypto_cipher_decrypt_aes(QCryptoCipher *cipher,
memcpy(tmp1, inptr, len);
/* Fill with 0 to avoid valgrind uninitialized reads */
memset(tmp1 + len, 0, sizeof(tmp1) - len);
- AES_decrypt(tmp1, tmp2, &ctxt->state.aes.encrypt_key);
+ AES_decrypt(tmp1, tmp2, &ctxt->state.aes.decrypt_key);
memcpy(outptr, tmp2, len);
len = 0;
}
}
} else {
AES_cbc_encrypt(in, out, len,
- &ctxt->state.aes.encrypt_key,
- ctxt->state.aes.iv, 1);
+ &ctxt->state.aes.decrypt_key,
+ ctxt->state.aes.iv, 0);
}
return 0;
--
2.4.3
next prev parent reply other threads:[~2015-07-28 8:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-28 8:04 [Qemu-devel] [PULL 0/4] Fixes for 2.4.0-rc3 Paolo Bonzini
2015-07-28 8:04 ` Paolo Bonzini [this message]
2015-07-28 8:04 ` [Qemu-devel] [PULL 2/4] crypto: extend unit tests to cover decryption too Paolo Bonzini
2015-07-28 8:04 ` [Qemu-devel] [PULL 3/4] megasas: Add write function to handle write access to PCI BAR 3 Paolo Bonzini
2015-07-28 8:04 ` [Qemu-devel] [PULL 4/4] memory: do not add a reference to the owner of aliased regions Paolo Bonzini
2015-07-28 14:24 ` [Qemu-devel] [PULL 0/4] Fixes for 2.4.0-rc3 Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1438070695-24889-2-git-send-email-pbonzini@redhat.com \
--to=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).