Re: how to encrypt and integrity-check with only one key

2009-09-14 Thread Zooko Wilcox-O'Hearn

following-up to my own post:

On Monday,2009-09-14, at 10:22 , Zooko Wilcox-O'Hearn wrote:

David-Sarah Hopwood suggested the improvement that the integrity- 
check value "V" could be computed as an integrity check (i.e. a  
secure hash) on the K1_enc in addition to the file contents.


Oops, that's impossible.  What David-Sarah Hopwood actually said was  
that this would be nice if it were possible, but since it isn't then  
people should pass around the tuple of (v, K1_enc) whenever they want  
to verify the integrity of the ciphertext.


http://allmydata.org/pipermail/tahoe-dev/2009-September/002798.html

Regards,

Zooko


-
The Cryptography Mailing List
Unsubscribe by sending "unsubscribe cryptography" to majord...@metzdowd.com


how to encrypt and integrity-check with only one key

2009-09-14 Thread Zooko Wilcox-O'Hearn

Folks:

I had an idea about how to use a single key to accomplish both  
encryption and integrity checking on an immutable file.  I posted it  
to the tahoe-dev list [1], and David-Sarah Hopwood followed up with  
an interesting new crypto cap design [2].  Here is the basic crypto  
trick, which may be useful in other contexts than Tahoe-LAFS.


Suppose you have some data and you want to control who gets to see  
it, and you also want anyone who sees it to be able to verify its  
integrity.  So far, these requirements are familiar to  
cryptographers.  The obvious answer is to encrypt the data and then  
to MAC (Message Authentication Code) the ciphertext.  There would be  
one key for the encryption and one key for the MAC.  However, this  
has the wrong semantics for our purposes -- anyone who is given the  
ability to check the integrity (by being given the MAC key) is also  
given the ability to create new texts which would verify.  Likewise,  
whoever creates the initial MAC tag can also create other MAC tags  
which would cause others files to also verify.  Instead, we want a  
single file that can pass the integrity check, and nobody -- not a  
reader who is able to verify integrity nor even the writer who  
initially created the file -- is able to make a different file which  
would also pass the integrity check.


Therefore, we want the integrity check value to be the secure hash of  
the file itself.  That's what we currently have in Tahoe-LAFS.  The  
immutable file read cap is a concatenation of two values: the  
decryption key and the secure hash.  The latter is solely for  
integrity-checking.  Actually in Tahoe-LAFS, the integrity check  
value is not just a flat hash of the plaintext, but instead it is the  
hash of the roots of a pair of Merkle Trees, one for verifying the  
correctness of the shares and the other for verifying the correctness  
of the ciphertext (see [3]).


Now, convergent encryption could do both jobs with one value!  If you  
let the symmetric key be the secure hash of the plaintext, then the  
reader could use the symmetric key to decrypt, then verify that the  
key was the hash of the plaintext.  However, you can't always use  
convergent encryption.  Not only because of the security issues [4],  
and not only because it requires two passes over the file which  
prevents "on-line" processing, but also because you might need to  
generate the symmetric key and/or the integrity check value in a  
different way.  For example, the Tahoe-LAFS integrity-check value  
isn't just a secure hash of the plaintext.  It would be inefficient  
to generate the full Tahoe-LAFS integrity check value before  
beginning to encrypt, and we want to be able to give someone the  
integrity check value (in a verify cap) without thus giving them the  
decryption key (i.e. the read cap).


So here is my idea to use a single value to accomplish both  
decryption and integrity checking even when you can't set the  
symmetric key to be the secure hash of the plaintext.  You use the  
encryption key K1 to encrypt the plaintext to produce the ciphertext,  
and in the same pass you compute the integrity-check value V.  Then  
you compute the secure hash of the combination of K1 and V, let's  
call the result R = H(K1, V).  Then you encrypt K1 using R and store  
the encrypted K1_enc with the ciphertext.  Now R is the real key --  
the read cap.  If someone gives you R, the ciphertext, and the  
encrypted K1_enc, then you first use R to decrypt K1, check that R = H 
(K1, V), then perform the decryption and integrity-checking of the  
ciphertext.


Here is a diagram: [5] (also attached).

David-Sarah Hopwood suggested the improvement that the integrity- 
check value "V" could be computed as an integrity check (i.e. a  
secure hash) on the K1_enc in addition to the file contents.


Regards,

Zooko

[1] http://allmydata.org/pipermail/tahoe-dev/2009-September/002796.html
[2] http://allmydata.org/pipermail/tahoe-dev/2009-September/002848.html
[3] http://allmydata.org/~zooko/lafs.pdf
[4] http://hacktahoe.org/drew_perttula.html
[5] http://zooko.com/imm-short-readcap-simple-drawing.svg


imm-short-readcap-simple-drawing.svg
Description: Binary data


Re: RNG using AES CTR as encryption algorithm

2009-09-14 Thread Damien Miller
On Mon, 14 Sep 2009, Peter Gutmann wrote:

> Damien Miller  writes:
> 
> >The seems unlikely, since we don't use OpenSSL for AES-CTR in OpenSSH. I
> >don't think OpenSSL even supports a CTR mode through its EVP API.
> 
> I first saw it reported on the Putty bugs list [0], a good place to track
> interop problems with implementations since it's so widely used, which in turn
> points to https://bugzilla.mindrot.org/show_bug.cgi?id=1291:

Actually, I'm half-wrong (or half-right) - there was a bug in OpenSSL, just
not in AES-CTR specifically. It was a mildly obscure bug in the EVP interface
that showed up when plugging in one's own ciphers. 

We now have automated interop regression tests againt PuTTY to catch this
sort of thing...

-d

-
The Cryptography Mailing List
Unsubscribe by sending "unsubscribe cryptography" to majord...@metzdowd.com


Re: RNG using AES CTR as encryption algorithm

2009-09-14 Thread Peter Gutmann
Damien Miller  writes:

>The seems unlikely, since we don't use OpenSSL for AES-CTR in OpenSSH. I
>don't think OpenSSL even supports a CTR mode through its EVP API.

I first saw it reported on the Putty bugs list [0], a good place to track
interop problems with implementations since it's so widely used, which in turn
points to https://bugzilla.mindrot.org/show_bug.cgi?id=1291:

  Connections from "OpenSSH_4.5p1, OpenSSL 0.9.8d 28 Sep 2006" to
  "OpenSSH_4.5p1, OpenSSL 0.9.8e 23 Feb 2007" using "aes256-ctr" fail with
  "Bad packet length".  The same problem occurs when using PuTTY 0.59 against
  the newer server.

  PuTTY users have reported this problem too, with servers on both FreeBSD and
  Linux, and with OpenSSH versions back to 4.0.

In fact it was listed as closed and resolved by, uh, one Damien Miller :-).

Peter.

[0] Meaing "bugs encountered while using Putty", not necessarily "bugs in
Putty".

-
The Cryptography Mailing List
Unsubscribe by sending "unsubscribe cryptography" to majord...@metzdowd.com


Re: RNG using AES CTR as encryption algorithm

2009-09-14 Thread Damien Miller
On Wed, 9 Sep 2009, Peter Gutmann wrote:

> I was just going to reply with a variation of this, if you're implementing a
> full protocol that uses AES-CTR (or any algorithm/mode for that matter), find
> other implementations that do it too and make sure that you can talk to them.
> In theory everyone could end up implementing it wrong, but that's somewhat
> unlikely.
> 
> (This has already caught AES-CTR implementation bugs in the past, for example
> one particular version of OpenSSL 0.9.8 got AES-CTR keying wrong and it was
> noticed when SSH users couldn't connect to OpenSSH servers using this mode).

The seems unlikely, since we don't use OpenSSL for AES-CTR in OpenSSH.
I don't think OpenSSL even supports a CTR mode through its EVP API.

Any mistakes in implementing CTR mode in OpenSSH are therefore our own.

-d

-
The Cryptography Mailing List
Unsubscribe by sending "unsubscribe cryptography" to majord...@metzdowd.com