21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Therefore, we’ll show you LION, built out of the RC4 implementation from Recipe<br />

5.23 and SHA1 (see Recipe 6.7). The structure of LION is shown in Figure 5-6.<br />

While we cover RC4 because it is popular, we strongly recommend<br />

you use SNOW 2.0 instead, because it seems to have a much more<br />

comfortable security margin.<br />

The one oddity of this technique is that files must be longer than the output size of<br />

the message digest function (20 bytes in the case of SHA1). Therefore, if you have<br />

files that small, you will either need to come up with a nonambiguous padding<br />

scheme, which is quite complicated to do securely, or you’ll need to abandon LION<br />

(either just for small messages or in general).<br />

LION requires a key that is twice as long as the output size of the message digest<br />

function. As with regular CBC-style encryption for files, if you’re using a cipher that<br />

takes fixed-size keys, we expect you’ll generate a key of the appropriate length from a<br />

password.<br />

Plaintext<br />

K 0<br />

K 1<br />

Figure 5-6. The structure of LION<br />

L0 R0 0 20<br />

n<br />

RC4<br />

L0 R1 0 20<br />

n<br />

SHA 1<br />

L1 R1 0 20<br />

n<br />

RC4<br />

Ciphertext L1 R2 0 20<br />

n<br />

Round 1<br />

Round 2<br />

Round 3<br />

We also assume a SHA1 implementation with a very standard API. Here, we use an<br />

API that works with OpenSSL, which should be easily adaptable to other libraries.<br />

Performing File or Disk Encryption | 215<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.<br />

= XOR

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!