21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

out += SPC_BLOCK_SZ;<br />

}<br />

SPC_DO_ENCRYPT(&(ctx->ks), ctx->ctr, ctx->ksm);<br />

ctr_increment(ctx->ctr);<br />

for (i = 0; i ksm[ctx->ix++];<br />

return 1;<br />

}<br />

Note that we simply remove the in argument along with the XOR operation whenever<br />

we write to the output buffer.<br />

5.13 Parallelizing Encryption and Decryption in<br />

Modes That Allow It (Without Breaking<br />

Compatibility)<br />

<strong>Problem</strong><br />

You want to parallelize encryption, decryption, or keystream generation.<br />

Solution<br />

Only some cipher modes are naturally parallelizable in a way that doesn’t break compatibility.<br />

In particular, CTR mode is naturally parallizable, as are decryption with<br />

CBC and CFB. There are two basic strategies: one is to treat the message in an interleaved<br />

fashion, and the other is to break it up into a single chunk for each parallel<br />

process.<br />

The first strategy is generally more practical. However, it is often difficult to make<br />

either technique result in a speed gain when processing messages in software.<br />

Discussion<br />

Parallelizing encryption and decryption does not necessarily result in a<br />

speed improvement. To provide any chance of a speedup, you’ll certainly<br />

need to ensure that multiple processors are working in parallel.<br />

Even in such an environment, data sets may be too small to run faster<br />

when they are processed in parallel.<br />

Some cipher modes can have independent parts of the message operated upon independently.<br />

In such cases, there is the potential for parallelization. For example, with<br />

CTR mode, the keystream is computed in blocks, where each block of keystream is<br />

generated by encrypting a unique plaintext block. Those blocks can be computed in<br />

any order.<br />

208 | Chapter 5: Symmetric Encryption<br />

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

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

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

Saved successfully!

Ooh no, something went wrong!