APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.crypto.provider

pack-priv final Class RC2Crypt

extends SymmetricCipher
Class Inheritance
Imports
java.security.InvalidKeyException

Implementation of the RC2(tm) algorithm as described in RFC 2268. RC2 is a 16-bit based algorithm and not particularly fast on 32/64 bit architectures. Also, note that although the JVM has a 16-bit integer type (short), all expressions are evaluated either in 32 or 64 bit (int or long). Expression such as "s1 = s2 + s3" are implemented by first promoting s2 and s3 to int, performing an int addition, and then demoting the result back to short to store in s1. To avoid this fairly slow process, we use the int type throughout and manually insert "& 0xffff" where necessary.
Author
Andreas Sterbenz
Since
1.5

Field Summary

Modifier and TypeField and Description
private int
private final int[]
private static final int[]

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv static void
checkKey(String algorithm, int keyLength)

pack-priv void
decryptBlock(byte[] in, int inOfs, byte[] out, int outOfs)

Implements abstract com.sun.crypto.provider.SymmetricCipher.decryptBlock.

Decrypt one cipher block.

pack-priv void
encryptBlock(byte[] in, int inOfs, byte[] out, int outOfs)

Implements abstract com.sun.crypto.provider.SymmetricCipher.encryptBlock.

Encrypt a single block.

pack-priv int
getBlockSize()

Implements abstract com.sun.crypto.provider.SymmetricCipher.getBlockSize.

Retrieves this cipher's block size.

pack-priv int
pack-priv void
init(boolean decrypting, String algorithm, byte[] key)

Implements abstract com.sun.crypto.provider.SymmetricCipher.init.

Initializes the cipher in the specified mode with the given key.

pack-priv void
initEffectiveKeyBits(int effectiveKeyBits)

Initializes the effective key bit size.

Field Detail

effectiveKeyBitsback to summary
private int effectiveKeyBits
expandedKeyback to summary
private final int[] expandedKey
PI_TABLEback to summary
private static final int[] PI_TABLE

Constructor Detail

RC2Cryptback to summary
pack-priv RC2Crypt()

Method Detail

checkKeyback to summary
pack-priv static void checkKey(String algorithm, int keyLength) throws InvalidKeyException
decryptBlockback to summary
pack-priv void decryptBlock(byte[] in, int inOfs, byte[] out, int outOfs)

Implements abstract com.sun.crypto.provider.SymmetricCipher.decryptBlock.

Doc from com.sun.crypto.provider.SymmetricCipher.decryptBlock.

Decrypt one cipher block.

The input cipher, starting at cipherOffset and ending at (cipherOffset+blockSize-1), is decrypted. The result is stored in plain, starting at plainOffset.

encryptBlockback to summary
pack-priv void encryptBlock(byte[] in, int inOfs, byte[] out, int outOfs)

Implements abstract com.sun.crypto.provider.SymmetricCipher.encryptBlock.

Encrypt a single block. Note that in a few places we omit a "& 0xffff" and allow variables to become larger than 16 bit. This still works because there is never a 32 bit overflow.

getBlockSizeback to summary
pack-priv int getBlockSize()

Implements abstract com.sun.crypto.provider.SymmetricCipher.getBlockSize.

Doc from com.sun.crypto.provider.SymmetricCipher.getBlockSize.

Retrieves this cipher's block size.

getEffectiveKeyBitsback to summary
pack-priv int getEffectiveKeyBits()
initback to summary
pack-priv void init(boolean decrypting, String algorithm, byte[] key) throws InvalidKeyException

Implements abstract com.sun.crypto.provider.SymmetricCipher.init.

Doc from com.sun.crypto.provider.SymmetricCipher.init.

Initializes the cipher in the specified mode with the given key.

Exceptions
InvalidKeyException:
if the given key is inappropriate for initializing this cipher
initEffectiveKeyBitsback to summary
pack-priv void initEffectiveKeyBits(int effectiveKeyBits)

Initializes the effective key bit size. This method is a hook to allow RC2Cipher to initialize the effective key size.