org.keyczar.interfaces
Interface DecryptingStream

All Superinterfaces:
Stream

public interface DecryptingStream
extends Stream

Decrypting streams are able to decrypt and verify data which has been encrypted by EncryptingStream objects.

Author:
steveweis@gmail.com (Steve Weis)

Method Summary
 int doFinalDecrypt(java.nio.ByteBuffer input, java.nio.ByteBuffer output)
          Do the final decrypt operation.
 VerifyingStream getVerifyingStream()
          Returns a Verifying Stream able to verify signatures on ciphertext inputs to this Decrypting Stream
 void initDecrypt(java.nio.ByteBuffer input)
          Initializes this stream for decryption.
 int maxOutputSize(int inputLen)
          Returns the maximum length of the output given the input length.
 int updateDecrypt(java.nio.ByteBuffer input, java.nio.ByteBuffer output)
          Update with more input to decrypt.
 

Method Detail

getVerifyingStream

VerifyingStream getVerifyingStream()
Returns a Verifying Stream able to verify signatures on ciphertext inputs to this Decrypting Stream

Returns:
A Verifying Stream associated with this stream

initDecrypt

void initDecrypt(java.nio.ByteBuffer input)
                 throws KeyczarException
Initializes this stream for decryption. May consume some bytes of the input; typically to read an IV if any exists. This must be called before updateDecrypt() or doFinalDecrypt().

Parameters:
input - The input containing any IV or other header data.
Throws:
KeyczarException - If there is any error initializing this Stream; typically this would be a Java JCE exception.

updateDecrypt

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

Parameters:
input - The input to decrypt.
output - The decrypted 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.

doFinalDecrypt

int doFinalDecrypt(java.nio.ByteBuffer input,
                   java.nio.ByteBuffer output)
                   throws KeyczarException
Do the final decrypt operation. Reads any remaining bytes from the input, decrypts them, and writes the plaintext to the output.

Parameters:
input - The input to decrypt.
output - The decrypted 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)
Returns the maximum length of the output given the input length.

Parameters:
inputLen - The input length
Returns:
The max lenght of the output given the input length