qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v3 6/7] block: convert qcrypto_block_encrypt|dec


From: Max Reitz
Subject: Re: [Qemu-block] [PATCH v3 6/7] block: convert qcrypto_block_encrypt|decrypt to take bytes offset
Date: Sat, 16 Sep 2017 19:13:20 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 2017-09-12 13:28, Daniel P. Berrange wrote:
> Instead of sector offset, take the bytes offset when encrypting
> or decrypting data.
> 
> Signed-off-by: Daniel P. Berrange <address@hidden>
> ---
>  block/crypto.c         | 12 ++++--------
>  block/qcow.c           |  7 +++++--
>  block/qcow2-cluster.c  |  8 +++-----
>  block/qcow2.c          |  4 ++--
>  crypto/block-luks.c    | 12 ++++++++----
>  crypto/block-qcow.c    | 12 ++++++++----
>  crypto/block.c         | 20 ++++++++++++++------
>  crypto/blockpriv.h     |  4 ++--
>  include/crypto/block.h | 14 ++++++++------
>  9 files changed, 54 insertions(+), 39 deletions(-)

[...]

> diff --git a/block/qcow.c b/block/qcow.c
> index f450b00cfc..d242301ed2 100644
> --- a/block/qcow.c
> +++ b/block/qcow.c
> @@ -478,7 +478,9 @@ static int get_cluster_offset(BlockDriverState *bs,
>                      for(i = 0; i < s->cluster_sectors; i++) {
>                          if (i < n_start || i >= n_end) {
>                              memset(s->cluster_data, 0x00, 512);
> -                            if (qcrypto_block_encrypt(s->crypto, start_sect 
> + i,
> +                            if (qcrypto_block_encrypt(s->crypto,
> +                                                      (start_sect + i) *
> +                                                      BDRV_SECTOR_SIZE,
>                                                        s->cluster_data,
>                                                        BDRV_SECTOR_SIZE,
>                                                        NULL) < 0) {
> @@ -668,7 +670,8 @@ static coroutine_fn int qcow_co_readv(BlockDriverState 
> *bs, int64_t sector_num,
>              }
>              if (bs->encrypted) {
>                  assert(s->crypto);
> -                if (qcrypto_block_decrypt(s->crypto, sector_num, buf,
> +                if (qcrypto_block_decrypt(s->crypto,
> +                                          sector_num * BDRV_SECTOR_SIZE, buf,
>                                            n * BDRV_SECTOR_SIZE, NULL) < 0) {
>                      ret = -EIO;
>                      break;

There's another instance of qcrypto_block_encrypt() in qcow_co_writev()
that needs to be changed.

Max

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]