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.

Table 5-4. Implementations for the SPC_DO_ENCRYPT macro for each OpenSSL-supported<br />

block cipher (continued)<br />

Cipher OpenSSL-based SPC_DO_ENCRYPT implementation<br />

IDEA idea_ecb_encrypt(in, out, sched);<br />

RC2 RC2_ecb_encrypt(in, out, sched, 1);<br />

RC5 RC5_32_ecb_encrypt(in, out, sched, 1);<br />

Table 5-5. Implementations for the SPC_DO_DECRYPT macro for each OpenSSL-supported<br />

block cipher<br />

Cipher OpenSSL-based SPC_DO_DECRYPT implementation<br />

AES AES_decrypt(in, out, sched)<br />

Blowfish BF_ecb_encrypt(in, out, sched, 0)<br />

CAST5 CAST_ecb_encrypt(in, out, sched, 0)<br />

DES DES_ecb_encrypt(in, out, sched, 0)<br />

3-key Triple-DES DES_ecb3_encrypt((DES_cblock *)in, (DES_cblock *)out, \<br />

&sched->ks1, &sched->ks2, &sched->ks3, 0);<br />

2-key Triple-DES DES_ecb3_encrypt((DES_cblock *)in, (DES_cblock *)out, \<br />

&sched->ks1, &sched->ks2, &sched->ks1, 0);<br />

IDEA idea_ecb_encrypt(in, out, sched);<br />

RC2 RC2_ecb_encrypt(in, out, sched, 0);<br />

RC5 RC5_32_ecb_encrypt(in, out, sched, 0);<br />

See Also<br />

• Brian Gladman’s AES page: http://fp.gladman.plus.com/AES/<br />

• OpenSSL home page: http://www.openssl.org/<br />

• Recipes 5.4, 5.26, 5.27.<br />

5.6 Using a Generic CBC Mode Implementation<br />

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

You want a more high-level interface for CBC mode than your library provides.<br />

Alternatively, you want a portable CBC interface, or you have only a block cipher<br />

implementation and you would like to use CBC mode.<br />

Solution<br />

CBC mode XORs each plaintext block with the previous output block before<br />

encrypting. The first block is XOR’d with the IV. Many libraries provide a CBC<br />

Using a Generic CBC Mode Implementation | 175<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!