|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ccs.crypt.Cipher ccs.crypt.AbstractBlockCipher ccs.crypt.BCCHBlockCipher
public class BCCHBlockCipher
A block cipher which uses BouncyCastle for the cryptographic primitives, in CBC mode with HMAC authentication.
Nested Class Summary | |
---|---|
static class |
BCCHBlockCipher.AES
|
static class |
BCCHBlockCipher.Blowfish
|
Field Summary |
---|
Fields inherited from class ccs.crypt.AbstractBlockCipher |
---|
buffer |
Fields inherited from class ccs.crypt.Cipher |
---|
passwd |
Constructor Summary | |
---|---|
BCCHBlockCipher(java.lang.Class enginec,
java.lang.Class digestc)
A block cipher using the specified cryptographic primitives. |
Method Summary | |
---|---|
protected void |
bufferDecrypt(int blkleft)
Decrypt the number of blocks specified from the internal buffer, updating the MAC with the result. |
protected void |
bufferEncrypt(int blkleft)
Encrypt the number of blocks specified from the internal buffer, updating the MAC with the result. |
int |
getBlockSizeExp()
The logarithm to base 2 of the block size of the cipher in bytes. |
protected int |
getHeaderLength()
The size of the header, without any self-delimitation info. |
CipherInputStream |
getInputStream(java.io.InputStream is,
boolean isSelfDelimit)
Returns a CipherInputStream that reads ciphertext from the
underlying stream and provides plaintext. |
protected byte[] |
getMAC()
Obtain the MAC for the stream. |
protected int |
getMACLength()
The size of the MAC. |
CipherOutputStream |
getOutputStream(java.io.OutputStream os,
long plainlen)
Returns a CipherOutputStream that accepts plaintext and writes
ciphertext to the underlying stream. |
protected void |
getWhitening(byte[] buf)
Produce and return 8 bytes (exactly) of "whitening". |
void |
setPasswd(byte[] pw)
Sets the password, and should be called at the start of the encryption procedure. |
Methods inherited from class ccs.crypt.AbstractBlockCipher |
---|
checkRegistered, getCiphertextLength, getPlaintextLength, getTrailerLength, register, unregister |
Methods inherited from class ccs.crypt.Cipher |
---|
getPasswd, out |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BCCHBlockCipher(java.lang.Class enginec, java.lang.Class digestc)
enginec
- The class of the encryption primitive engine to use. Must
implement BlockCipher
.digestc
- The class of the crytographic hash function to use. Must
implement Digest
.Method Detail |
---|
public void setPasswd(byte[] pw) throws CipherException
setPasswd
in class Cipher
pw
- the new password. Must be at least 8 bytes. If > 56 bytes, it is hashed
down to 40 bytes; otherwise it is not pre-processed and can be used for verification
using test vectors. (Password length > 56 bytes suggests you're trying
to distil a silk purse out of several sows' ears. :-)
CipherException
- if the pass-string is too short.public CipherOutputStream getOutputStream(java.io.OutputStream os, long plainlen) throws java.io.IOException
CipherOutputStream
that accepts plaintext and writes
ciphertext to the underlying stream.
getOutputStream
in class Cipher
os
- The stream to write ciphertext to.plainlen
- The length of plaintext to be written. If known, this
allows the length to be encrypted as part of the stream itself, and
makes the ciphertext self-delimiting; where many ciphertexts are concatenated
onto a stream, no boundary sequences are required in this mode, which is
preferable. (Such sequences leak information.) Supply -1 if you really
don't know; in this case, you must delimit the ciphertext yourself. Note that
the limit is applied to the ciphertext, not the plaintext; the cipher may allow
you to append a few bytes of garbage without complaining (For a block cipher
with an incomplete last block, this does not change the ciphertext length).
CipherException
- if a cryptographic problem occurs.
java.io.IOException
- if the CipherOutputStream
could not be
created for some reason.public CipherInputStream getInputStream(java.io.InputStream is, boolean isSelfDelimit) throws java.io.IOException
CipherInputStream
that reads ciphertext from the
underlying stream and provides plaintext.
getInputStream
in class Cipher
is
- The stream to read ciphertext from.isSelfDelimit
- Whether the ciphertext is self-delimiting,
ie. it has its own length stored inside itself. If not, the ciphertext
is assumed to extend to EOF.
CipherException
- if a cryptographic problem occurs.
java.io.IOException
- if the CipherInputStream
could not be
created for some reason.protected void bufferEncrypt(int blkleft)
AbstractBlockCipher
bufferEncrypt
in class AbstractBlockCipher
protected void bufferDecrypt(int blkleft)
AbstractBlockCipher
bufferDecrypt
in class AbstractBlockCipher
protected byte[] getMAC()
AbstractBlockCipher
getMAC
in class AbstractBlockCipher
protected void getWhitening(byte[] buf)
AbstractBlockCipher
getWhitening
in class AbstractBlockCipher
buf
- The buffer into the first 8 bytes of which the whitening
should be placed.public int getBlockSizeExp()
AbstractBlockCipher
getBlockSizeExp
in class AbstractBlockCipher
protected int getHeaderLength()
AbstractBlockCipher
getHeaderLength
in class AbstractBlockCipher
protected int getMACLength()
AbstractBlockCipher
getMACLength
in class AbstractBlockCipher
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |