mirror of https://github.com/xqemu/xqemu.git
* crypto fixes
* megasas SIGSEGV fix * memory refcount change to fix virtio hot-unplug -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAABCAAGBQJVty9DAAoJEL/70l94x66DJZ4H/j3ix0YRs/rxQEXuvVTg0NeS abspC2foLAqUbIbeB6ApZBXPZAtIA6mPOm+aK04HuB2K2NXqi57pv6qiJ6LMbVNM NBOfM3qfk/Drt5Sf/4esAbqFaqlkjeKbC7FetZgM4vTZkFK/mfrqUnWGpE7HdRHp ap2R1U9aZrS4V3O7TMLrJumnwLEl0bAZ0JnMPQrtjvHt2NmCHQn+4owUiXB2BmwK xo2pIQeJVYbGpRlUEqkehaHYSZsjrIM/RLRYcHWEA5ucZekQKUgwbgNy4K1/YAT0 /edH0DtkKoSC1eFhS1TKeWm8mCfHp49mAJXlq16zaWrQGItcfYtJ2QLVTdi4Hfc= =IpxH -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging * crypto fixes * megasas SIGSEGV fix * memory refcount change to fix virtio hot-unplug # gpg: Signature made Tue Jul 28 08:29:07 2015 BST using RSA key ID 78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" # gpg: WARNING: This key is not certified with sufficiently trusted signatures! # gpg: It is not certain that the signature belongs to the owner. # Primary key fingerprint: 46F5 9FBD 57D6 12E7 BFD4 E2F7 7E15 100C CD36 69B1 # Subkey fingerprint: F133 3857 4B66 2389 866C 7682 BFFB D25F 78C7 AE83 * remotes/bonzini/tags/for-upstream: memory: do not add a reference to the owner of aliased regions megasas: Add write function to handle write access to PCI BAR 3 crypto: extend unit tests to cover decryption too crypto: fix built-in AES decrypt function Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
5e868d2e5e
|
@ -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;
|
||||
|
|
|
@ -2202,8 +2202,15 @@ static uint64_t megasas_queue_read(void *opaque, hwaddr addr,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void megasas_queue_write(void *opaque, hwaddr addr,
|
||||
uint64_t val, unsigned size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static const MemoryRegionOps megasas_queue_ops = {
|
||||
.read = megasas_queue_read,
|
||||
.write = megasas_queue_write,
|
||||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
.impl = {
|
||||
.min_access_size = 8,
|
||||
|
|
7
memory.c
7
memory.c
|
@ -859,11 +859,6 @@ static void memory_region_destructor_ram(MemoryRegion *mr)
|
|||
qemu_ram_free(mr->ram_addr);
|
||||
}
|
||||
|
||||
static void memory_region_destructor_alias(MemoryRegion *mr)
|
||||
{
|
||||
memory_region_unref(mr->alias);
|
||||
}
|
||||
|
||||
static void memory_region_destructor_ram_from_ptr(MemoryRegion *mr)
|
||||
{
|
||||
qemu_ram_free_from_ptr(mr->ram_addr);
|
||||
|
@ -1272,8 +1267,6 @@ void memory_region_init_alias(MemoryRegion *mr,
|
|||
uint64_t size)
|
||||
{
|
||||
memory_region_init(mr, owner, name, size);
|
||||
memory_region_ref(orig);
|
||||
mr->destructor = memory_region_destructor_alias;
|
||||
mr->alias = orig;
|
||||
mr->alias_offset = offset;
|
||||
}
|
||||
|
|
|
@ -226,12 +226,10 @@ static void test_cipher(const void *opaque)
|
|||
const QCryptoCipherTestData *data = opaque;
|
||||
|
||||
QCryptoCipher *cipher;
|
||||
Error *err = NULL;
|
||||
uint8_t *key, *iv, *ciphertext, *plaintext, *outtext;
|
||||
size_t nkey, niv, nciphertext, nplaintext;
|
||||
char *outtexthex;
|
||||
|
||||
g_test_message("foo");
|
||||
nkey = unhex_string(data->key, &key);
|
||||
niv = unhex_string(data->iv, &iv);
|
||||
nciphertext = unhex_string(data->ciphertext, &ciphertext);
|
||||
|
@ -244,28 +242,42 @@ static void test_cipher(const void *opaque)
|
|||
cipher = qcrypto_cipher_new(
|
||||
data->alg, data->mode,
|
||||
key, nkey,
|
||||
&err);
|
||||
&error_abort);
|
||||
g_assert(cipher != NULL);
|
||||
g_assert(err == NULL);
|
||||
|
||||
|
||||
if (iv) {
|
||||
g_assert(qcrypto_cipher_setiv(cipher,
|
||||
iv, niv,
|
||||
&err) == 0);
|
||||
g_assert(err == NULL);
|
||||
&error_abort) == 0);
|
||||
}
|
||||
g_assert(qcrypto_cipher_encrypt(cipher,
|
||||
plaintext,
|
||||
outtext,
|
||||
nplaintext,
|
||||
&err) == 0);
|
||||
g_assert(err == NULL);
|
||||
&error_abort) == 0);
|
||||
|
||||
outtexthex = hex_string(outtext, nciphertext);
|
||||
|
||||
g_assert_cmpstr(outtexthex, ==, data->ciphertext);
|
||||
|
||||
g_free(outtexthex);
|
||||
|
||||
if (iv) {
|
||||
g_assert(qcrypto_cipher_setiv(cipher,
|
||||
iv, niv,
|
||||
&error_abort) == 0);
|
||||
}
|
||||
g_assert(qcrypto_cipher_decrypt(cipher,
|
||||
ciphertext,
|
||||
outtext,
|
||||
nplaintext,
|
||||
&error_abort) == 0);
|
||||
|
||||
outtexthex = hex_string(outtext, nplaintext);
|
||||
|
||||
g_assert_cmpstr(outtexthex, ==, data->plaintext);
|
||||
|
||||
g_free(outtext);
|
||||
g_free(outtexthex);
|
||||
g_free(key);
|
||||
|
|
Loading…
Reference in New Issue