|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--org.logi.crypto.Crypto
|
+--org.logi.crypto.modes.EncryptMode
|
+--org.logi.crypto.modes.EncryptCBC
Cipher Block Chaining mode xors each plain block with the previous cipher block before encrypting. See FIPS PUB 81 or ANSI X3.106 or ISO IS8372 for a complete specification.
A padding engine can be passed to the constructor of the EncryptCBC object to allow the encryption of data which is not a whole multiple of plaintext blocks. If no padding engine is given, then the padding used depends on the key class being used.
If the key implements the CipherKey interface, which makes it a key for a symmetric cipher, then PKCS#5 padding is used. Otherwise PKCS#1 padding is used, which is appropriate for RSA and Diffie-Hellman/El-Gamal.
DecryptCBC| Fields inherited from class org.logi.crypto.Crypto |
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO |
| Constructor Summary | |
EncryptCBC()
Create a new CBC-mode encrypt session with no key and PKCS#5 padding. |
|
EncryptCBC(EncryptionKey key)
Create a new CBC-mode encrypt session with the specified key and PKCS#5 padding. |
|
EncryptCBC(EncryptionKey key,
Padding padding)
Create a new CBC-mode encrypt session with the specified key. |
|
EncryptCBC(Padding padding)
Create a new CBC-mode encrypt session with no key. |
|
| Method Summary | |
void |
close()
|
byte[] |
encrypt(byte[] source,
int i,
int length)
Send bytes to the EncryptCBC object for encryption. |
void |
finalize()
|
byte[] |
flush()
Pads the internal buffer acording to PKCS#5 (See RFC 1423, sec 1.1), encrypts it and returns the ciphertext. |
byte[] |
flush(byte[] source,
int i,
int length)
Equivalent to calling encrypt(source,i,length)
followed by flush(). |
EncryptionKey |
getKey()
Return the key used for encryption. |
int |
plainBlockSize()
Return the size of the blocks of plaintext encrypted by this object. |
void |
setKey(EncryptionKey key)
Set the key to use for encryption. |
| Methods inherited from class org.logi.crypto.Crypto |
binString, binString, ensureArrayLength, ensureArrayLength, equal, equalRelaxed, equalSub, fromHexNibble, fromHexString, fromString, fromString, hexString, hexString, hexString, hexString, hexString, initRandom, initRandom, makeClass, makeInt, makeLong, makeSessionKey, pastSpace, pickBits, pickBits, prettyPrint, prettyPrint, readBlock, readInt, trimArrayLength, trimArrayLength, trimLeadingZeroes, writeBytes, writeBytes, writeInt |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public EncryptCBC(EncryptionKey key,
Padding padding)
key - The key to use for encryption.padding - The padding engine to use.public EncryptCBC(EncryptionKey key)
key - The key to use for encryption.public EncryptCBC(Padding padding)
setKey()
method has been called.padding - The padding engine to use.public EncryptCBC()
setKey()
method has been called.padding - The padding engine to use.| Method Detail |
public EncryptionKey getKey()
public int plainBlockSize()
public void setKey(EncryptionKey key)
throws CryptoException
CryptoException - if there is data in the internal buffer
which should be encrypted with the old key.
public byte[] encrypt(byte[] source,
int i,
int length)
Encrypt length bytes from source,
starting at i and return the ciphertext. Data is
encrypted in blocks, so only whole blocks of ciphertext
are written to dest. Any remaining plaintext will be
stored and prepended to source in the next call to
encrypt.
public byte[] flush()
throws PaddingException
public byte[] flush(byte[] source,
int i,
int length)
throws PaddingException
encrypt(source,i,length)
followed by flush().flush in interface EncryptSessionpublic void close()
public void finalize()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
Copyright (c) 1997-2001 Logi Ragnarsson - Distributed under the GPL