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.

Discussion<br />

Particularly when you are implementing another encryption mode, you may always<br />

be operating on block-sized chunks, and it can be inconvenient to deal with padding.<br />

Alternatively, some odd protocol may require a nonstandard padding scheme<br />

that causes you to pad the data manually before encryption (and to remove the pad<br />

manually after encryption).<br />

The second argument of this function should be zero to turn padding off, and nonzero<br />

to turn it on.<br />

5.20 Performing Additional Cipher Setup in<br />

OpenSSL<br />

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

Using OpenSSL, you want to adjust a configurable parameter of a cipher other than<br />

the key length.<br />

Solution<br />

OpenSSLprovides an obtuse, ioctl()-style API for setting uncommon cipher parameters<br />

on a context object:<br />

int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr);<br />

Discussion<br />

OpenSSLdoesn’t provide much flexibility in adjusting cipher characteristics. For<br />

example, the three AES configurations are three specific instantiations of a cipher<br />

called Rijndael, which has nine different configurations. However, OpenSSLsupports<br />

only the three standard ones.<br />

Nevertheless, there are two cases in which OpenSSLdoes allow for configurability.<br />

In the first case, it allows for setting the “effective key bits” in RC2. As a result, the<br />

RC2 key is crippled so that it is only as strong as the effective size set. We feel that<br />

this functionality is completely useless.<br />

In the second case, OpenSSLallows you to set the number of rounds used internally<br />

by the RC5 algorithm. By default, RC5 uses 12 rounds. And while the algorithm<br />

should take absolutely variable-length rounds, OpenSSLallows you to set the number<br />

only to 8, 12, or 16.<br />

228 | 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!