public class OCBBlockCipher extends java.lang.Object implements AEADBlockCipher
License for Open-Source Software Implementations of OCB (Jan 9, 2013) — “License 1”
Under this license, you are authorized to make, use, and distribute open-source software implementations of OCB. This license terminates for you if you sue someone over their open-source software implementation of OCB claiming that you have a patent covering their implementation. This is a non-binding summary of a legal document (the link above). The parameters of the license are specified in the license document and that document is controlling.
| Constructor and Description |
|---|
OCBBlockCipher(BlockCipher hashCipher,
BlockCipher mainCipher) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
clear(byte[] bs) |
int |
doFinal(byte[] output,
int outOff)
Finish the operation either appending or verifying the MAC at the end of the data.
|
java.lang.String |
getAlgorithmName()
Return the name of the algorithm.
|
protected byte[] |
getLSub(int n) |
byte[] |
getMac()
Return the value of the MAC associated with the last stream processed.
|
int |
getOutputSize(int len)
return the size of the output buffer required for a processBytes plus a
doFinal with an input of len bytes.
|
BlockCipher |
getUnderlyingCipher()
return the cipher this object wraps.
|
int |
getUpdateOutputSize(int len)
return the size of the output buffer required for a processBytes
an input of len bytes.
|
void |
init(boolean forEncryption,
CipherParameters parameters)
initialise the underlying cipher.
|
protected static byte[] |
OCB_double(byte[] block) |
protected static void |
OCB_extend(byte[] block,
int pos) |
protected static int |
OCB_ntz(long x) |
void |
processAADByte(byte input)
Add a single byte to the associated data check.
|
void |
processAADBytes(byte[] input,
int off,
int len)
Add a sequence of bytes to the associated data check.
|
int |
processByte(byte input,
byte[] output,
int outOff)
encrypt/decrypt a single byte.
|
int |
processBytes(byte[] input,
int inOff,
int len,
byte[] output,
int outOff)
process a block of bytes from in putting the result into out.
|
protected void |
processHashBlock() |
protected void |
processMainBlock(byte[] output,
int outOff) |
void |
reset()
Reset the cipher.
|
protected void |
reset(boolean clearMac) |
protected static int |
shiftLeft(byte[] block,
byte[] output) |
protected void |
updateHASH(byte[] LSub) |
protected static void |
xor(byte[] block,
byte[] val) |
public OCBBlockCipher(BlockCipher hashCipher, BlockCipher mainCipher)
public BlockCipher getUnderlyingCipher()
AEADBlockCiphergetUnderlyingCipher in interface AEADBlockCipherpublic java.lang.String getAlgorithmName()
AEADBlockCiphergetAlgorithmName in interface AEADBlockCipherpublic void init(boolean forEncryption,
CipherParameters parameters)
throws java.lang.IllegalArgumentException
AEADBlockCipherinit in interface AEADBlockCipherforEncryption - true if we are setting up for encryption, false otherwise.parameters - the necessary parameters for the underlying cipher to be initialised.java.lang.IllegalArgumentException - if the params argument is inappropriate.public byte[] getMac()
AEADBlockCiphergetMac in interface AEADBlockCipherpublic int getOutputSize(int len)
AEADBlockCiphergetOutputSize in interface AEADBlockCipherlen - the length of the input.public int getUpdateOutputSize(int len)
AEADBlockCiphergetUpdateOutputSize in interface AEADBlockCipherlen - the length of the input.public void processAADByte(byte input)
AEADBlockCipherprocessAADByte in interface AEADBlockCipherinput - the byte to be processed.public void processAADBytes(byte[] input,
int off,
int len)
AEADBlockCipherprocessAADBytes in interface AEADBlockCipherinput - the input byte array.off - the offset into the in array where the data to be processed starts.len - the number of bytes to be processed.public int processByte(byte input,
byte[] output,
int outOff)
throws DataLengthException
AEADBlockCipherprocessByte in interface AEADBlockCipherinput - the byte to be processed.output - the output buffer the processed byte goes into.outOff - the offset into the output byte array the processed data starts at.DataLengthException - if the output buffer is too small.public int processBytes(byte[] input,
int inOff,
int len,
byte[] output,
int outOff)
throws DataLengthException
AEADBlockCipherprocessBytes in interface AEADBlockCipherinput - the input byte array.inOff - the offset into the in array where the data to be processed starts.len - the number of bytes to be processed.output - the output buffer the processed bytes go into.outOff - the offset into the output byte array the processed data starts at.DataLengthException - if the output buffer is too small.public int doFinal(byte[] output,
int outOff)
throws java.lang.IllegalStateException,
InvalidCipherTextException
AEADBlockCipherdoFinal in interface AEADBlockCipheroutput - space for any resulting output data.outOff - offset into out to start copying the data at.java.lang.IllegalStateException - if the cipher is in an inappropriate state.InvalidCipherTextException - if the MAC fails to match.public void reset()
AEADBlockCipherreset in interface AEADBlockCipherprotected void clear(byte[] bs)
protected byte[] getLSub(int n)
protected void processHashBlock()
protected void processMainBlock(byte[] output,
int outOff)
protected void reset(boolean clearMac)
protected void updateHASH(byte[] LSub)
protected static byte[] OCB_double(byte[] block)
protected static void OCB_extend(byte[] block,
int pos)
protected static int OCB_ntz(long x)
protected static int shiftLeft(byte[] block,
byte[] output)
protected static void xor(byte[] block,
byte[] val)