23.07.2013 Views

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

<strong>Java</strong> I/O<br />

them your encryption (public) key. Even if the key is intercepted, this only allows the<br />

interceptor to send you encrypted messages. It does not allow them to decode encrypted<br />

messages intended for you.<br />

The most famous public key cipher is the patented [5] RSA cipher, named after its inventors,<br />

Ronald L. Rivest, Adi Shamir, and Leonard M. Adleman. RSA has the particularly nice<br />

property that either key can be used for encryption or decryption. Generally, you'll keep one<br />

key secret (your private key) and publish the corresponding key. People can send encrypted<br />

messages to you using your public key that you decrypt with your private key. Furthermore,<br />

by encrypting either a message or a hash code of the message with your private key, which<br />

may then be decrypted with your public key, you can digitally sign messages. Any message<br />

that can be successfully decrypted with your public key may be presumed to have come from<br />

you, because only you could have encrypted it with your private key in the first place. (Of<br />

course, if someone steals your private key, all bets are off.)<br />

10.4.3 Block Versus Stream Ciphers<br />

Encryption algorithms may also be divided into block and stream ciphers. A block cipher<br />

always encrypts a fixed number of bytes with each pass. For example, DES encrypts eightbyte<br />

blocks. If the data you're encrypting is not an integral multiple of the block size, the data<br />

must be padded with extra bytes to round up to the block size. Stream ciphers, by contrast, act<br />

on each bit or byte individually in the order it appears in the stream; padding is not required.<br />

Block ciphers can operate in a variety of modes that use various algorithms to determine how<br />

the result of the encryption of one block of data influences the encryption of subsequent<br />

blocks. This ensures that identical blocks of plaintext do not produce identical blocks of<br />

ciphertext, a weakness code breakers can exploit. To ensure that messages that start with the<br />

same plaintext (for example, many email messages or form letters) don't also start with the<br />

same ciphertext (also a weakness code breakers can exploit), these modes require a nonsecret<br />

initialization vector, generally of the same size as a block, in order to begin the encoding.<br />

Initialization vectors are not secret and are generally passed in the clear with the encrypted<br />

data.<br />

10.4.4 Key Management<br />

Storing keys securely is a difficult problem. If the key is stored in hardware like a smart card,<br />

it can be stolen. If the key is stored in a file on a disk, the disk can be stolen. Many basic PC<br />

protection schemes are based on OS- or driver-level operations that refuse to mount the disk<br />

without the proper password, but simply using a new OS (or driver or custom hardware)<br />

allows the key or unencrypted data to be read off the disk.<br />

Ideally, keys should not be stored anywhere except in a human being's memory. Human<br />

beings, however, have a hard time remembering arbitrary 56-bit keys like<br />

0x78A53666090BCC, much less more secure 64 -, 112-, or 128-bit keys. Therefore, keys<br />

humans have to remember are generally stored as a string of text called a password. Even<br />

then, the password is vulnerable to a rubber hose attack. Truly secure systems like those used<br />

to protect bank vaults require separate passwords remembered by two or more individuals.<br />

5 The patent expires September 20, 2000.<br />

211

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

Saved successfully!

Ooh no, something went wrong!