|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcryptix.security.BlockCipher
This is an abstract superclass for ciphers that encrypt and decrypt a fixed length block with a secret key.
BlockCipher objects support only the Cryptix v2.2 API.
Note: compatibility with Cryptix 2.2 applies only to clients of this class. Subclasses must be rewritten as JCE algorithms.
Copyright © 1997
Systemics Ltd on behalf of the
Cryptix Development Team.
All rights reserved.
$Revision: 1.5 $
java.security.Cipher
Field Summary | |
protected int |
blockSize
Deprecated. The algorithm's block size in bytes. |
protected xjava.security.Cipher |
cipher
Deprecated. The JCE cipher that is delegated to. |
Constructor Summary | |
protected |
BlockCipher(xjava.security.Cipher cipher,
byte[] userKey)
Deprecated. Constructs a V2.2 block cipher from a JCE cipher. |
Method Summary | |
int |
blockLength()
Deprecated. Use blockSize() ,
getPlaintextBlockSize() or
getCiphertextBlockSize() instead. |
void |
decrypt(byte[] text)
Deprecated. Use initDecrypt(key) and
update(buf, 0, buf.length, text, 0) instead. |
void |
decrypt(byte[] in,
byte[] out)
Deprecated. Use initDecrypt(key) and
update(in, 0, in.length, out, 0) instead. |
void |
decrypt(byte[] in,
int inOffset,
byte[] out,
int outOffset)
Deprecated. Use initDecrypt(key) and update(in, inOffset,
blockSize, out, outOffset) instead. |
void |
encrypt(byte[] buf)
Deprecated. Use initEncrypt(key) and
update(buf, 0, buf.length, text, 0) instead. |
void |
encrypt(byte[] in,
byte[] out)
Deprecated. Use initEncrypt(key) and
update(in, 0, in.length, out, 0) instead. |
void |
encrypt(byte[] in,
int inOffset,
byte[] out,
int outOffset)
Deprecated. Use initEncrypt(key) and update(in, inOffset,
blockSize, out, outOffset) instead. |
int |
keyLength()
Deprecated. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected xjava.security.Cipher cipher
protected int blockSize
Constructor Detail |
protected BlockCipher(xjava.security.Cipher cipher, byte[] userKey)
cipher
- the java.security.Cipher object.Method Detail |
public final int blockLength()
blockSize()
,
getPlaintextBlockSize()
or
getCiphertextBlockSize()
instead.
public final int keyLength()
The JCE equivalent is to call getEncoded()
on the Key
object, and find the length of the resulting byte array. It is not
possible to directly get the key object that has been used to
initialize a Cipher.
public final void encrypt(byte[] buf)
initEncrypt(key)
and
update(buf, 0, buf.length, text, 0)
instead.
buf.length
must be equal to the block size.
buf
- the buffer holding the data
CryptoError
- if the buffer was the wrong lengthpublic final void encrypt(byte[] in, byte[] out)
initEncrypt(key)
and
update(in, 0, in.length, out, 0)
instead.
in.length
and out.length
must be equal to the
block size.
in
- the plaintext to be encryptedout
- the ciphertext result of the encryption
CryptoError
- if a buffer was the wrong lengthpublic void encrypt(byte[] in, int inOffset, byte[] out, int outOffset)
initEncrypt(key)
and update(in, inOffset,
blockSize, out, outOffset)
instead.
in[inOffset..inOffset+blockSize-1]
is encrypted, and the resulting ciphertext is written to
out[outOffset..outOffset+blockSize-1]
.
Note that there must be sufficient bytes left in each array.
The in and out arrays can be the same, in which case the behaviour is the same as if the input array was copied before any output is written.
in
- buffer holding the plaintext to be encryptedinOffset
- the start of plaintext within in
out
- buffer to write the encrypted ciphertext tooutOffset
- the start of ciphertext within out
java.lang.ArrayIndexOutOfBoundsException
- if an offset was invalid.public final void decrypt(byte[] text)
initDecrypt(key)
and
update(buf, 0, buf.length, text, 0)
instead.
buf.length
must be equal to the block size.
CryptoError
- if the buffer was the wrong lengthpublic final void decrypt(byte[] in, byte[] out)
initDecrypt(key)
and
update(in, 0, in.length, out, 0)
instead.
in.length
and out.length
must be equal to the
block size.
in
- the plaintext to be encryptedout
- the ciphertext result of the encryption
CryptoError
- if a buffer was the wrong lengthpublic void decrypt(byte[] in, int inOffset, byte[] out, int outOffset)
initDecrypt(key)
and update(in, inOffset,
blockSize, out, outOffset)
instead.
in[inOffset..inOffset+blockSize-1]
is decrypted, and the resulting plaintext is written to
out[outOffset..outOffset+blockSize-1]
.
Note that there must be sufficient bytes left in each array.
The in and out arrays can be the same, in which case the behaviour is the same as if the input array was copied before any output is written.
in
- buffer holding the ciphertext to be decryptedinOffset
- the start of ciphertext within in
out
- buffer to write the decrypted plaintext tooutOffset
- the start of plaintext within out
java.lang.ArrayIndexOutOfBoundsException
- if an offset was invalid.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |