org.keyczar.interfaces
Interface EncryptingStream

All Superinterfaces:
Stream

public interface EncryptingStream
extends Stream

Encrypting streams are able to encrypt and sign data.

Author:
steveweis@gmail.com (Steve Weis)

Method Summary
 int doFinalEncrypt(java.nio.ByteBuffer input, java.nio.ByteBuffer output)
          Do the final encrypt operation.
 SigningStream getSigningStream()
          Returns a Signing Stream able to sign ciphertexts produced by this EncryptingStream.
 int initEncrypt(java.nio.ByteBuffer output)
          Initializes this stream for encryption.
 int maxOutputSize(int inputLen)
          Given the length of an input, return the maximum possible length of the output (including headers, the actual ciphertext, and the signature).
 int updateEncrypt(java.nio.ByteBuffer input, java.nio.ByteBuffer output)
          Update with more input to encrypt.
 

Method Detail

getSigningStream

SigningStream getSigningStream()
                               throws KeyczarException
Returns a Signing Stream able to sign ciphertexts produced by this EncryptingStream.

Returns:
A Signg Stream associated with this stream
Throws:
KeyczarException

initEncrypt

int initEncrypt(java.nio.ByteBuffer output)
                throws KeyczarException
Initializes this stream for encryption. May write some header material to the output, for example an IV. This must be called before updateEncrypt() or doFinalEncrypt().

Parameters:
output - The output where any IV material will be written.
Returns:
The number of bytes written to the output.
Throws:
KeyczarException - If there is any error initializing this Stream; typically this would be a Java JCE exception.

updateEncrypt

int updateEncrypt(java.nio.ByteBuffer input,
                  java.nio.ByteBuffer output)
                  throws KeyczarException
Update with more input to encrypt. Write any encrypted output to the given output buffer. Some encrypted output may be buffered and not written out until the next call to updateEncrypt() or doFinalEncrypt().

Parameters:
input - The input to encrypt.
output - The encrypted output, if any.
Returns:
The number of bytes written to the output.
Throws:
KeyczarException - If a Java JCE error occurs or the output buffer is too small.

doFinalEncrypt

int doFinalEncrypt(java.nio.ByteBuffer input,
                   java.nio.ByteBuffer output)
                   throws KeyczarException
Do the final encrypt operation. Reads any remaining bytes from the input, encrypts them, and writes the ciphertext to the output.

Parameters:
input - The input to encrypt.
output - The encrypted output, if any.
Returns:
The number of bytes written to the output.
Throws:
KeyczarException - If a Java JCE error occurs or the output buffer is too small.

maxOutputSize

int maxOutputSize(int inputLen)
Given the length of an input, return the maximum possible length of the output (including headers, the actual ciphertext, and the signature).

Parameters:
inputLen -
Returns:
maximum length of output