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.

public static final Cipher getInstance(String transformation)<br />

throws NoSuchAlgorithmException, NoSuchPaddingException<br />

public static final Cipher getInstance(String transformation, String<br />

provider)<br />

throws NoSuchAlgorithmException, NoSuchProviderException,<br />

NoSuchPaddingException<br />

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

The first argument, transformation, is a string that names the algorithm, mode, and padding<br />

scheme to be used to encrypt or decrypt the data. Examples include "DES",<br />

"PBEWithMD5AndDES", and "DES/ECB/PKCS5Padding". The optional second argument to<br />

getInstance(), provider, names the preferred provider for the requested transformation. If<br />

more than one installed provider supports the transformation, the one named in the second<br />

argument will be used. Otherwise, an implementation will be selected from any available<br />

provider that supports the transformation. If you request a transformation from<br />

getInstance() that the provider does not support, a NoSuchAlgorithmException or<br />

NoSuchPaddingException will be thrown. If you request a provider that is not installed, a<br />

NoSuchProviderException is thrown.<br />

The transformation string always includes the name of a cryptographic algorithm: for<br />

example, DES. The standard names for common algorithms are listed in Table 10.3. Not all of<br />

these algorithms are guaranteed to be available. In fact, JDK 1.2 doesn't supply any of these.<br />

If you install JCE, you get access to Blowfish, DES, Triple DES, and PBEWithMD5AndDES.<br />

You'll need a third-party provider to use RSA, IDEA, RC2, or RC4.<br />

Table 10.3. JCE Standard Algorithm Names<br />

Name Algorithm<br />

The U.S. Federal government's Data Encryption Standard as defined by NIST in FIPS 46-1 and<br />

DES 46-2; a symmetric 64-bit block cipher that uses a 56-bit key; see<br />

DESede<br />

http://www.itl.nist.gov/div897/pubs/fip46-2.htm.<br />

DES e ncryption-d ecryption-e ncryption; triple DES; like DES, a 64-bit symmetric block cipher.<br />

DES encryption with one 56-bit key is followed by decryption with a different 56-bit key, which<br />

is followed by encryption with a third 56-bit key, effectively providing a 168-bit key space. It is<br />

considered possible that the NSA cannot penetrate this algorithm.<br />

PBEWithMD5 Password-Based Encryption as defined in RSA Laboratories, "PKCS #5: Password-Based<br />

Encryption Standard," Version 1.5, Nov. 1993; based on DES; also requires a salt; see<br />

AndDES http://www.rsa.com/rsalabs/pkcs/pkcs-5/index.html.<br />

PBEWithMD5 Password-Based Encryption as defined in RSA Laboratories, "PKCS #5: Password-Based<br />

Encryption Standard," version 1.5, Nov. 1993; based on DES; also requires a salt and an<br />

AndTripleDES initialization vector; see http://www.rsa.com/rsalabs/pkcs/pkcs-5/index.html.<br />

The patented Rivest, Shamir, and Adleman asymmetric cipher algorithm; RSA encryption as<br />

RSA<br />

defined in the RSA Laboratories Technical Note PKCS#1,<br />

http://www.rsa.com/rsalabs/pkcs/pkcs-1/index.html. It is considered possible that the NSA<br />

cannot penetrate this algorithm. [7] The patent expires in 2000.<br />

7 I have a hunch (not necessarily shared by experts in the field) that RSA and similar algorithms will be broken someday by means much less<br />

computationally intensive than brute force search. RSA's strength rests on the difficulty of factoring a large number into two large primes. However, it<br />

is not known whether such factorization is fundamentally hard or whether we just don't yet know the right factoring algorithms. It seems obvious to<br />

me that there's a lot of structure in the prime numbers that has yet to be exploited or understood by number theorists. For instance, the Goldbach<br />

conjecture and the number of prime pairs are still unsolved questions. Therefore, I would not be surprised if far more efficient factorization algorithms<br />

are discovered. Any such algorithm would severely reduce the strength of encryption schemes like RSA. Furthermore, there's been an explosion of<br />

interest and research in quantum computing, following the discovery that RSA would be much more easily cracked by a quantum computer than by a<br />

traditional one. This does not seem to be the case for public-key encryption schemes based on something other than prime factorization, for instance,<br />

discrete logarithms or elliptic curves.<br />

214

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

Saved successfully!

Ooh no, something went wrong!