qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Laszlo Ersek <lersek@redhat.com>
To: "Benoît Canet" <benoit.canet@irqsave.net>
Cc: Kevin Wolf <kwolf@redhat.com>,
	Paolo Bonzini <pbonzini@redhat.com>,
	qemu-devel@nongnu.org, stefanha@redhat.com,
	Stefan Hajnoczi <stefanha@gmail.com>
Subject: Re: [Qemu-devel] QCOW2 cryptography and secure key handling
Date: Wed, 31 Jul 2013 20:31:14 +0200	[thread overview]
Message-ID: <51F957F2.808@redhat.com> (raw)
In-Reply-To: <51F94EC8.5030203@redhat.com>

On 07/31/13 19:52, Laszlo Ersek wrote:

> You'll end up with two identical sectors in the encrypted image.

Apologies for following up on my own message...

If you want to store an arbitrary N bit long bit-string (a watermark)
that is visible in the encrypted image, then you need:
- a good guess at "sector_num" (like before),
- B1 (like before),
- to compute B_n from B(n-1), like before,
- two different trailing plaintext portions (each containing 496 bytes),
let's call them S0 and S1,
- (N+1) consecutive sectors in total.

You'd write the subject bitstring like this:

void compute_next_B(uint64_t B[2], uint64_t *sector_num)
{
    B[0] ^= (*sector_num ^ (*sector_num + 1));
    ++*sector_num;
}

void write_string(const char unsigned *subject_string, size_t N,
                  uint64_t sector_num)
{
    const char unsigned S[2][496] = {
        /* constant originally drawn from a good pseudo-random source */
    };
    uint64_t B[2] = { /* ditto */ };
    int i = 0;
    size_t n;

    write_sector(sector_num, B, S[i]);
    for (n = 0; n < N; ++n) {
        i ^= is_bit_set(subject_string, n);
        compute_next_B(B, &sector_num);
        write_sector(sector_num, B, S[i]);
    }
}

Just speculating...
Laszlo

  reply	other threads:[~2013-07-31 19:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-23 12:47 [Qemu-devel] QCOW2 cryptography and secure key handling Benoît Canet
2013-07-23 13:00 ` Daniel P. Berrange
2013-07-23 13:21   ` Benoît Canet
2013-07-23 14:40   ` Benoît Canet
2013-07-23 15:22     ` Stefan Hajnoczi
2013-07-23 15:38       ` Kevin Wolf
2013-07-23 15:57         ` Daniel P. Berrange
2013-07-24 13:07           ` Benoît Canet
2013-07-24 15:30           ` Paolo Bonzini
2013-07-24 15:33             ` Daniel P. Berrange
2013-07-24 15:40               ` Paolo Bonzini
2013-07-24 15:46                 ` Daniel P. Berrange
2013-07-29 11:21             ` Markus Armbruster
2013-07-29 11:25               ` Kevin Wolf
2013-07-29 11:32                 ` Daniel P. Berrange
2013-07-29 16:07                   ` Benoît Canet
2013-07-31 15:33               ` Benoît Canet
2013-07-31 15:27             ` Benoît Canet
2013-07-31 17:52               ` Laszlo Ersek
2013-07-31 18:31                 ` Laszlo Ersek [this message]
2013-07-23 15:40       ` Daniel P. Berrange

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=51F957F2.808@redhat.com \
    --to=lersek@redhat.com \
    --cc=benoit.canet@irqsave.net \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=stefanha@redhat.com \
    /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).