|
||||||||
| 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.EncryptECB
Electronic Codebook Mode simply encrypts each block of plaintext independently. It is not as secure as for example CBC mode.
A padding engine can be passed to the constructor of the EncryptECB 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 no padding is parformed. It is upt to the user to ensure that there is a whole multiple of plaintext blocks (this can, or course, by specifying a padding engine in the constructor). Otherwise PKCS#1 padding is used, which is appropriate for RSA and Diffie-Hellman/El-Gamal.
DecryptECB| Fields inherited from class org.logi.crypto.Crypto |
BIT, cdsPath, EMPTY_ARRAY, FOUR, keySource, NIBBLE, ONE, primeCertainty, random, TWO, ZERO |
| Constructor Summary | |
EncryptECB()
Create a new ECB-mode encrypt session with no key and default padding. |
|
EncryptECB(EncryptionKey key)
Create a new ECB-mode encrypt session with default padding. |
|
EncryptECB(EncryptionKey key,
Padding padding)
Create a new ECB-mode encrypt session. |
|
EncryptECB(Padding padding)
Create a new ECB-mode encrypt session with no key. |
|
| Method Summary | |
void |
close()
|
byte[] |
encrypt(byte[] source,
int i,
int length)
Send bytes to the EncryptECB object for encryption. |
void |
finalize()
|
byte[] |
flush()
Pads the internal buffer, 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 EncryptECB(EncryptionKey key,
Padding padding)
key - The key to use for decryption.padding - The padding engine to use.public EncryptECB(EncryptionKey key)
key - The key to use for decryption.public EncryptECB(Padding padding)
setKey() method has been called.padding - The padding engine to use.public EncryptECB()
setKey()
method has been called.| Method Detail |
public EncryptionKey getKey()
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 int plainBlockSize()
public byte[] flush()
throws PaddingException
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(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