Re: V3 secret keys

Ben Laurie <ben@algroup.co.uk> Sun, 19 February 2006 16:09 UTC

Received: from [10.91.34.44] (helo=ietf-mx.ietf.org) by megatron.ietf.org with esmtp (Exim 4.43) id 1FAr7u-0002DU-Sm for openpgp-archive@lists.ietf.org; Sun, 19 Feb 2006 11:09:34 -0500
Received: from above.proper.com ([208.184.76.39]) by ietf-mx.ietf.org with esmtp (Exim 4.43) id 1FAr7t-00064O-GR for openpgp-archive@lists.ietf.org; Sun, 19 Feb 2006 11:09:34 -0500
Received: from above.proper.com (localhost.vpnc.org [127.0.0.1]) by above.proper.com (8.12.11/8.12.9) with ESMTP id k1JFlcKU012682; Sun, 19 Feb 2006 07:47:38 -0800 (PST) (envelope-from owner-ietf-openpgp@mail.imc.org)
Received: (from majordom@localhost) by above.proper.com (8.12.11/8.12.9/Submit) id k1JFlcDf012681; Sun, 19 Feb 2006 07:47:38 -0800 (PST)
X-Authentication-Warning: above.proper.com: majordom set sender to owner-ietf-openpgp@mail.imc.org using -f
Received: from mail.links.org (mail.links.org [217.155.92.109]) by above.proper.com (8.12.11/8.12.9) with ESMTP id k1JFlYOG012670 for <ietf-openpgp@imc.org>; Sun, 19 Feb 2006 07:47:35 -0800 (PST) (envelope-from ben@algroup.co.uk)
Received: from [193.133.15.218] (localhost [127.0.0.1]) by mail.links.org (Postfix) with ESMTP id 51A3633C40; Sun, 19 Feb 2006 15:47:33 +0000 (GMT)
Message-ID: <43F89315.3000800@algroup.co.uk>
Date: Sun, 19 Feb 2006 15:47:33 +0000
From: Ben Laurie <ben@algroup.co.uk>
User-Agent: Thunderbird 1.5 (Windows/20051201)
MIME-Version: 1.0
To: Hal Finney <hal@finney.org>
CC: ietf-openpgp@imc.org
Subject: Re: V3 secret keys
References: <20060215201341.0D48557FAE@finney.org>
In-Reply-To: <20060215201341.0D48557FAE@finney.org>
X-Enigmail-Version: 0.93.0.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 7bit
Sender: owner-ietf-openpgp@mail.imc.org
Precedence: bulk
List-Archive: <http://www.imc.org/ietf-openpgp/mail-archive/>
List-Unsubscribe: <mailto:ietf-openpgp-request@imc.org?body=unsubscribe>
List-ID: <ietf-openpgp.imc.org>
X-Spam-Score: 0.1 (/)
X-Scan-Signature: e8a67952aa972b528dd04570d58ad8fe

Hal Finney wrote:
> Ben Laurie writes:
>> No, I can't confirm that. I have code that works as we all expect CFB to
>> work (modulo "resync") on v4 secret keys. I had to make the change I
>> described to decrypt v3 keys. It seems to me rather unlikely that I have
>> it wrong given that I had to reverse engineer and write new code to get
>> a working implementation for v3!
> 
> To clarify, you are claiming that to unlock a V3 secret key, you don't
> use the IV as usual in CFB mode.  Instead, you use an all-zero buffer
> for the IV, and then prepend the IV from the secret key subpacket to
> the data, decrypt that, and discard the first block of output?
> 
> So in other words, to get the first block of plaintext you do, in effect:
> 
> buf1 = Enc (all-zeros);
> buf2 = buf1 xor IV;
> buf3 = Enc (buf2);
> buf4 = buf3 xor ciphertext
> 
> and buf4 will be the first block of plaintext?  You say your code does
> this, and it works????
> 
> My code does this:
> 
> buf1 = Enc (IV);
> buf2 = buf1 xor ciphertext
> 
> and buf2 is the first block of plaintext.
> 
> I just checked GPG and I confirmed that they work the same way I have
> said.
> 
> Could you possibly show a few lines of your code, that does this step?
> It's simply impossible for your code to be working as I have described
> above, and to interoperate with existing V3 keys.  Either I misunderstood
> your claim about the need for an all-zero IV, or you have misunderstood
> what your own code is doing.

In fact, after discussion with Hal, we've established that:

a) Both of us are correct about what our code is doing

b) The two algorithms are effectively the same (for decryption, at least).

c) There was a bug in my code related to resyncing that setting the IV
"the hard way" worked around - which is why it appeared that v3 keys
were crypted differently.

So, we're in agreement about how it works now. My complaint about
"resyncing" stands, however.

Cheers,

Ben.

-- 
http://www.apache-ssl.org/ben.html           http://www.links.org/

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff