|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.clazzes.optional.sec.GCMCipher
public class GCMCipher
galois counter mode for symmetric ciphers. Copied from bouncycastle.
Constructor Summary | |
---|---|
GCMCipher(BlockCipher c)
|
|
GCMCipher(BlockCipher c,
GCMMultiplier m)
|
Method Summary | |
---|---|
int |
doFinal(byte[] out,
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 the cipher implements. |
int |
getBlockSize()
|
byte[] |
getMac()
Return the value of the MAC associated with the last stream processed. |
int |
getOutputSize(int len)
|
BlockCipher |
getUnderlyingCipher()
return the underlying block cipher that we are wrapping or null , if we do wrap another cipher. |
int |
getUpdateOutputSize(int len)
|
void |
init(byte[] iv,
boolean useForEncryption)
Initialize the block cipher. |
void |
init(byte[] aad,
int macSizeBits,
byte[] iv,
boolean useForEncryption)
Initialize the block cipher. |
int |
processBlock(byte[] in,
int inOff,
byte[] out,
int outOff)
Proceed the next block of BlockCipher.getBlockSize() bytes from the input. |
int |
processBytes(byte[] in,
int inOff,
int inLen,
byte[] out,
int outOff)
Proceed the next block of in_len bytes from the input. |
void |
reset()
Reset this cipher to state of the last call to #init(byte[], byte[], boolean) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GCMCipher(BlockCipher c)
c
- The underlying block cipher, which should have been
initialized in encrypting ("forward") mode regardless
of whether we want to encrypt or decrypt.public GCMCipher(BlockCipher c, GCMMultiplier m)
c
- The underlying block cipher, which should have been
initialized in encrypting ("forward") mode regardless
of whether we want to encrypt or decrypt.m
- A GCM multiplier or null
, if you want to
use the default multiplier implementation.Method Detail |
---|
public BlockCipher getUnderlyingCipher()
BlockCipher
null
, if we do wrap another cipher.
getUnderlyingCipher
in interface BlockCipher
public java.lang.String getAlgorithmName()
BlockCipher
getAlgorithmName
in interface BlockCipher
public void init(byte[] iv, boolean useForEncryption) throws java.lang.IllegalArgumentException
BlockCipher
init
in interface BlockCipher
iv
- The key for basic ciphers or initialization vector for cipher modes
or null
, if no key or initialization vector is needed.useForEncryption
- Whether we want to encrypt. false
means to set up this cipher for decryption.
java.lang.IllegalArgumentException
public void init(byte[] aad, int macSizeBits, byte[] iv, boolean useForEncryption) throws java.lang.IllegalArgumentException
AEADBlockCipher
init
in interface AEADBlockCipher
aad
- The additional authenticated data or
null
, if no additional authenticated data is needed.macSizeBits
- The length of the calculated myac in bits.iv
- The initialization (nonce) vector or
null
, if no initialization vector is needed.useForEncryption
- Whether we want to encrypt. false
means to set up this cipher for decryption.
java.lang.IllegalArgumentException
public byte[] getMac()
AEADBlockCipher
getMac
in interface AEADBlockCipher
public int getOutputSize(int len)
getOutputSize
in interface AEADBlockCipher
len
- The length of the input data.
public int getUpdateOutputSize(int len)
public int processBlock(byte[] in, int inOff, byte[] out, int outOff)
BlockCipher
BlockCipher.getBlockSize()
bytes from the input.
processBlock
in interface BlockCipher
in
- The buffer where the input is stored.
BlockCipher.getBlockSize()
bytes starting with in_off
will be consumed.inOff
- The offset at which the input data starts.out
- The buffer where the output is stored.
BlockCipher.getBlockSize()
bytes starting with out_off
will be written.outOff
- The offset at which the output will be stored.
public int processBytes(byte[] in, int inOff, int inLen, byte[] out, int outOff)
AEADBlockCipher
in_len
bytes from the input.
This complements the functionality of BlockCipher.processBlock(byte[], int, byte[], int)
,
because AEAD ciphers may process arbitrary data length.
processBytes
in interface AEADBlockCipher
in
- The buffer where the input is stored.
BlockCipher.getBlockSize()
bytes starting with in_off
will be consumed.inOff
- The offset at which the input data starts.inLen
- The length of the input data to process.out
- The buffer where the output is stored.
BlockCipher.getBlockSize()
bytes starting with out_off
will be written.outOff
- The offset at which the output will be stored.
public int doFinal(byte[] out, int outOff) throws InvalidCipherTextException
AEADBlockCipher
doFinal
in interface AEADBlockCipher
out
- space for any resulting output data.outOff
- offset into out to start copying the data at.
InvalidCipherTextException
- if the MAC fails to match.public void reset()
BlockCipher
#init(byte[], byte[], boolean)
.
reset
in interface BlockCipher
public int getBlockSize()
getBlockSize
in interface BlockCipher
BlockCipher.processBlock(byte[], int, byte[], int)
operation.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |