org.bouncycastle.crypto.internal.StreamBlockCipher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bc-fips Show documentation
Show all versions of bc-fips Show documentation
The FIPS 140-3 Bouncy Castle Crypto package is a Java implementation of cryptographic algorithms certified to FIPS 140-3 level 1. This jar contains JCE provider and low-level API for the BC-FJA version 2.0.0, FIPS Certificate #4743. Please see certificate for certified platform details.
/***************************************************************/
/****** DO NOT EDIT THIS CLASS bc-java SOURCE FILE ******/
/***************************************************************/
package org.bouncycastle.crypto.internal;
/**
* A parent class for block cipher modes that do not require block aligned data to be processed, but can function in
* a streaming mode which produces
*/
public abstract class StreamBlockCipher
implements BlockCipher, StreamCipher
{
private final BlockCipher cipher;
protected StreamBlockCipher(BlockCipher cipher)
{
this.cipher = cipher;
}
/**
* return the underlying block cipher that we are wrapping.
*
* @return the underlying block cipher that we are wrapping.
*/
public BlockCipher getUnderlyingCipher()
{
return cipher;
}
public final byte returnByte(byte in)
{
return calculateByte(in);
}
public int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff)
throws DataLengthException
{
if (outOff + len > out.length)
{
throw new DataLengthException("output buffer too short");
}
if (inOff + len > in.length)
{
throw new DataLengthException("input buffer too small");
}
int inStart = inOff;
int inEnd = inOff + len;
int outStart = outOff;
while (inStart < inEnd)
{
out[outStart++] = calculateByte(in[inStart++]);
}
return len;
}
protected abstract byte calculateByte(byte b);
}