Top Description Inners Fields Constructors Methods
org.bouncycastle.crypto.engines

public Class PhotonBeetleEngine

extends Object
implements AEADCipher
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.modes.AEADCipher
Imports
java.io.ByteArrayOutputStream, org.bouncycastle.crypto.CipherParameters, .CryptoServicesRegistrar, .DataLengthException, .InvalidCipherTextException, .OutputLengthException, org.bouncycastle.crypto.constraints.DefaultServiceProperties, org.bouncycastle.crypto.modes.AEADCipher, org.bouncycastle.crypto.params.KeyParameter, .ParametersWithIV

Photon-Beetle, https://www.isical.ac.in/~lightweight/beetle/ https://csrc.nist.gov/CSRC/media/Projects/lightweight-cryptography/documents/finalist-round/updated-spec-doc/photon-beetle-spec-final.pdf

Photon-Beetle with reference to C Reference Impl from: https://github.com/PHOTON-Beetle/Software

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum

Field Summary

Modifier and TypeField and Description
private byte[]
A

private final ByteArrayOutputStream
private final int
private final int
private final int
D

private final int
private final int
private final int
private boolean
private boolean
private boolean
private boolean
private byte[]
K

private final int
private final ByteArrayOutputStream
private final byte[][]
private byte[]
N

private final int
private final int
private final byte[][]
private final int
private final int
S

private final int
private final byte[]
private byte[]
private byte[][]
private final int
private byte[]
T

private final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
doFinal(byte[]
space for any resulting output data.
output
,
int
offset into out to start copying the data at.
outOff
)

Implements org.bouncycastle.crypto.modes.AEADCipher.doFinal.

Finish the operation either appending or verifying the MAC at the end of the data.
public String
getAlgorithmName()

Implements org.bouncycastle.crypto.modes.AEADCipher.getAlgorithmName.

Return the name of the algorithm.
public int
public int
public int
public byte[]
getMac()

Implements org.bouncycastle.crypto.modes.AEADCipher.getMac.

Return the value of the MAC associated with the last stream processed.
public int
getOutputSize(int
the length of the input.
len
)

Implements org.bouncycastle.crypto.modes.AEADCipher.getOutputSize.

return the size of the output buffer required for a processBytes plus a doFinal with an input of len bytes.
public int
getUpdateOutputSize(int
the length of the input.
len
)

Implements org.bouncycastle.crypto.modes.AEADCipher.getUpdateOutputSize.

return the size of the output buffer required for a processBytes an input of len bytes.
public void
init(boolean
true if we are setting up for encryption, false otherwise.
forEncryption
,
CipherParameters
the necessary parameters for the underlying cipher to be initialised.
params
)

Implements org.bouncycastle.crypto.modes.AEADCipher.init.

initialise the underlying cipher.
private void
public void
processAADByte(byte
the byte to be processed.
input
)

Implements org.bouncycastle.crypto.modes.AEADCipher.processAADByte.

Add a single byte to the associated data check.
public void
processAADBytes(byte[]
the input byte array.
input
,
int
the offset into the in array where the data to be processed starts.
inOff
,
int
the number of bytes to be processed.
len
)

Implements org.bouncycastle.crypto.modes.AEADCipher.processAADBytes.

Add a sequence of bytes to the associated data check.
public int
processByte(byte
the byte to be processed.
input
,
byte[]
the output buffer the processed byte goes into.
output
,
int
the offset into the output byte array the processed data starts at.
outOff
)

Implements org.bouncycastle.crypto.modes.AEADCipher.processByte.

encrypt/decrypt a single byte.
public int
processBytes(byte[]
the input byte array.
input
,
int
the offset into the in array where the data to be processed starts.
inOff
,
int
the number of bytes to be processed.
len
,
byte[]
the output buffer the processed bytes go into.
output
,
int
the offset into the output byte array the processed data starts at.
outOff
)

Implements org.bouncycastle.crypto.modes.AEADCipher.processBytes.

process a block of bytes from in putting the result into out.
public void
private void
reset(boolean clearMac)

private void
rhoohr(byte[] ciphertext, int outOff, byte[] plaintext, int inOff, int DBlen_inbytes)

private byte
select(boolean condition1, boolean condition2, byte option3, byte option4)

private void
XOR(byte[] in_right, int rOff, int iolen_inbytes)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

Aback to summary
private byte[] A
aadDataback to summary
private final ByteArrayOutputStream aadData
CRYPTO_KEYBYTESback to summary
private final int CRYPTO_KEYBYTES
CRYPTO_NPUBBYTESback to summary
private final int CRYPTO_NPUBBYTES
Dback to summary
private final int D
Dqback to summary
private final int Dq
Drback to summary
private final int Dr
DSquareback to summary
private final int DSquare
encryptedback to summary
private boolean encrypted
forEncryptionback to summary
private boolean forEncryption
initialisedback to summary
private boolean initialised
input_emptyback to summary
private boolean input_empty
Kback to summary
private byte[] K
LAST_THREE_BITS_OFFSETback to summary
private final int LAST_THREE_BITS_OFFSET
messageback to summary
private final ByteArrayOutputStream message
MixColMatrixback to summary
private final byte[][] MixColMatrix
Nback to summary
private byte[] N
RATE_INBYTESback to summary
private final int RATE_INBYTES
RATE_INBYTES_HALFback to summary
private final int RATE_INBYTES_HALF
RCback to summary
private final byte[][] RC
ROUNDback to summary
private final int ROUND
Sback to summary
private final int S
S_1back to summary
private final int S_1
sboxback to summary
private final byte[] sbox
stateback to summary
private byte[] state
state_2dback to summary
private byte[][] state_2d
STATE_INBYTESback to summary
private final int STATE_INBYTES
Tback to summary
private byte[] T
TAG_INBYTESback to summary
private final int TAG_INBYTES

Constructor Detail

PhotonBeetleEngineback to summary
public PhotonBeetleEngine(PhotonBeetleEngine.PhotonBeetleParameters pbp)

Method Detail

doFinalback to summary
public int doFinal(byte[] output, int outOff) throws IllegalStateException, InvalidCipherTextException

Implements org.bouncycastle.crypto.modes.AEADCipher.doFinal.

Doc from org.bouncycastle.crypto.modes.AEADCipher.doFinal.

Finish the operation either appending or verifying the MAC at the end of the data.

Parameters
output:byte[]

space for any resulting output data.

outOff:int

offset into out to start copying the data at.

Returns:int

number of bytes written into out.

Annotations
@Override
Exceptions
IllegalStateException:
if the cipher is in an inappropriate state.
InvalidCipherTextException:
if the MAC fails to match.
getAlgorithmNameback to summary
public String getAlgorithmName()

Implements org.bouncycastle.crypto.modes.AEADCipher.getAlgorithmName.

Doc from org.bouncycastle.crypto.modes.AEADCipher.getAlgorithmName.

Return the name of the algorithm.

Returns:String

the algorithm name.

Annotations
@Override
getBlockSizeback to summary
public int getBlockSize()
getIVBytesSizeback to summary
public int getIVBytesSize()
getKeyBytesSizeback to summary
public int getKeyBytesSize()
getMacback to summary
public byte[] getMac()

Implements org.bouncycastle.crypto.modes.AEADCipher.getMac.

Doc from org.bouncycastle.crypto.modes.AEADCipher.getMac.

Return the value of the MAC associated with the last stream processed.

Returns:byte[]

MAC for plaintext data.

Annotations
@Override
getOutputSizeback to summary
public int getOutputSize(int len)

Implements org.bouncycastle.crypto.modes.AEADCipher.getOutputSize.

Doc from org.bouncycastle.crypto.modes.AEADCipher.getOutputSize.

return the size of the output buffer required for a processBytes plus a doFinal with an input of len bytes.

The returned size may be dependent on the initialisation of this cipher and may not be accurate once subsequent input data is processed - this method should be invoked immediately prior to a call to final processing of input data and a call to doFinal(byte[], int).

Parameters
len:int

the length of the input.

Returns:int

the space required to accommodate a call to processBytes and doFinal with len bytes of input.

Annotations
@Override
getUpdateOutputSizeback to summary
public int getUpdateOutputSize(int len)

Implements org.bouncycastle.crypto.modes.AEADCipher.getUpdateOutputSize.

Doc from org.bouncycastle.crypto.modes.AEADCipher.getUpdateOutputSize.

return the size of the output buffer required for a processBytes an input of len bytes.

The returned size may be dependent on the initialisation of this cipher and may not be accurate once subsequent input data is processed - this method should be invoked immediately prior to input data being processed.

Parameters
len:int

the length of the input.

Returns:int

the space required to accommodate a call to processBytes with len bytes of input.

Annotations
@Override
initback to summary
public void init(boolean forEncryption, CipherParameters params) throws IllegalArgumentException

Implements org.bouncycastle.crypto.modes.AEADCipher.init.

Doc from org.bouncycastle.crypto.modes.AEADCipher.init.

initialise the underlying cipher. Parameter can either be an AEADParameters or a ParametersWithIV object.

Parameters
forEncryption:boolean

true if we are setting up for encryption, false otherwise.

params:CipherParameters

the necessary parameters for the underlying cipher to be initialised.

Annotations
@Override
Exceptions
IllegalArgumentException:
if the params argument is inappropriate.
PHOTON_Permutationback to summary
private void PHOTON_Permutation()
processAADByteback to summary
public void processAADByte(byte input)

Implements org.bouncycastle.crypto.modes.AEADCipher.processAADByte.

Doc from org.bouncycastle.crypto.modes.AEADCipher.processAADByte.

Add a single byte to the associated data check.
If the implementation supports it, this will be an online operation and will not retain the associated data.

Parameters
input:byte

the byte to be processed.

Annotations
@Override
processAADBytesback to summary
public void processAADBytes(byte[] input, int inOff, int len)

Implements org.bouncycastle.crypto.modes.AEADCipher.processAADBytes.

Doc from org.bouncycastle.crypto.modes.AEADCipher.processAADBytes.

Add a sequence of bytes to the associated data check.
If the implementation supports it, this will be an online operation and will not retain the associated data.

Parameters
input:byte[]

the input byte array.

inOff:int

the offset into the in array where the data to be processed starts.

len:int

the number of bytes to be processed.

Annotations
@Override
processByteback to summary
public int processByte(byte input, byte[] output, int outOff) throws DataLengthException

Implements org.bouncycastle.crypto.modes.AEADCipher.processByte.

Doc from org.bouncycastle.crypto.modes.AEADCipher.processByte.

encrypt/decrypt a single byte.

Parameters
input:byte

the byte to be processed.

output:byte[]

the output buffer the processed byte goes into.

outOff:int

the offset into the output byte array the processed data starts at.

Returns:int

the number of bytes written to out.

Annotations
@Override
Exceptions
DataLengthException:
if the output buffer is too small.
processBytesback to summary
public int processBytes(byte[] input, int inOff, int len, byte[] output, int outOff) throws DataLengthException

Implements org.bouncycastle.crypto.modes.AEADCipher.processBytes.

Doc from org.bouncycastle.crypto.modes.AEADCipher.processBytes.

process a block of bytes from in putting the result into out.

Parameters
input:byte[]

the input byte array.

inOff:int

the offset into the in array where the data to be processed starts.

len:int

the number of bytes to be processed.

output:byte[]

the output buffer the processed bytes go into.

outOff:int

the offset into the output byte array the processed data starts at.

Returns:int

the number of bytes written to out.

Annotations
@Override
Exceptions
DataLengthException:
if the output buffer is too small.
resetback to summary
public void reset()

Implements org.bouncycastle.crypto.modes.AEADCipher.reset.

Doc from org.bouncycastle.crypto.modes.AEADCipher.reset.

Reset the cipher. After resetting the cipher is in the same state as it was after the last init (if there was one).

Annotations
@Override
resetback to summary
private void reset(boolean clearMac)
rhoohrback to summary
private void rhoohr(byte[] ciphertext, int outOff, byte[] plaintext, int inOff, int DBlen_inbytes)
selectback to summary
private byte select(boolean condition1, boolean condition2, byte option3, byte option4)
XORback to summary
private void XOR(byte[] in_right, int rOff, int iolen_inbytes)
org.bouncycastle.crypto.engines back to summary

public final Enum PhotonBeetleEngine.PhotonBeetleParameters

extends Enum<PhotonBeetleEngine.PhotonBeetleParameters>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final PhotonBeetleEngine.PhotonBeetleParameters
public static final PhotonBeetleEngine.PhotonBeetleParameters

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static PhotonBeetleEngine.PhotonBeetleParameters
public static PhotonBeetleEngine.PhotonBeetleParameters[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

pb128back to summary
public static final PhotonBeetleEngine.PhotonBeetleParameters pb128
pb32back to summary
public static final PhotonBeetleEngine.PhotonBeetleParameters pb32

Constructor Detail

PhotonBeetleParametersback to summary
private PhotonBeetleParameters()

Method Detail

valueOfback to summary
public static PhotonBeetleEngine.PhotonBeetleParameters valueOf(String name)
valuesback to summary
public static PhotonBeetleEngine.PhotonBeetleParameters[] values()