Bouncy Castle Cryptography Library 1.77.0

org.bouncycastle.crypto.engines
Class Zuc128CoreEngine

java.lang.Object
  |
  +--org.bouncycastle.crypto.engines.Zuc128CoreEngine
All Implemented Interfaces:
Memoable, StreamCipher
Direct Known Subclasses:
Zuc128Engine, Zuc256CoreEngine

public class Zuc128CoreEngine
extends java.lang.Object
implements StreamCipher, Memoable

Zuc128Engine implementation. Based on https://www.gsma.com/aboutus/wp-content/uploads/2014/12/eea3eia3zucv16.pdf


Constructor Summary
protected Zuc128CoreEngine()
          Constructor.
protected Zuc128CoreEngine(Zuc128CoreEngine pSource)
          Constructor.
 
Method Summary
 Memoable copy()
          Create a copy of the engine.
static void encode32be(int val, byte[] buf, int off)
          Encode a 32-bit value into a buffer (little-endian).
 java.lang.String getAlgorithmName()
          Obtain Algorithm Name.
protected  int getMaxIterations()
          Obtain Max iterations.
 void init(boolean forEncryption, CipherParameters params)
          initialise a Snow3G cipher.
protected  int makeKeyStreamWord()
          Create the next keyStream word.
 int processBytes(byte[] in, int inOff, int len, byte[] out, int outOff)
          Process bytes.
 void reset()
          Reset the engine.
 void reset(Memoable pState)
          Reset from saved engine state.
 byte returnByte(byte in)
          Process single byte.
protected  void setKeyAndIV(int[] pLFSR, byte[] k, byte[] iv)
          Process key and IV into LFSR.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Zuc128CoreEngine

protected Zuc128CoreEngine()
Constructor.

Zuc128CoreEngine

protected Zuc128CoreEngine(Zuc128CoreEngine pSource)
Constructor.
Parameters:
pSource - the source engine
Method Detail

init

public void init(boolean forEncryption,
                 CipherParameters params)
initialise a Snow3G cipher.
Specified by:
init in interface StreamCipher
Parameters:
forEncryption - whether or not we are for encryption.
params - the parameters required to set up the cipher.
Throws:
java.lang.IllegalArgumentException - if the params argument is inappropriate.

getMaxIterations

protected int getMaxIterations()
Obtain Max iterations.
Returns:
the maximum iterations

getAlgorithmName

public java.lang.String getAlgorithmName()
Obtain Algorithm Name.
Specified by:
getAlgorithmName in interface StreamCipher
Returns:
the name

processBytes

public int processBytes(byte[] in,
                        int inOff,
                        int len,
                        byte[] out,
                        int outOff)
Process bytes.
Specified by:
processBytes in interface StreamCipher
Parameters:
in - the input buffer
inOff - the starting offset in the input buffer
len - the length of data in the input buffer
out - the output buffer
outOff - the starting offset in the output buffer
Returns:
the number of bytes returned in the output buffer

reset

public void reset()
Reset the engine.
Specified by:
reset in interface StreamCipher

returnByte

public byte returnByte(byte in)
Process single byte.
Specified by:
returnByte in interface StreamCipher
Parameters:
in - the input byte
Returns:
the output byte

encode32be

public static void encode32be(int val,
                              byte[] buf,
                              int off)
Encode a 32-bit value into a buffer (little-endian).
Parameters:
val - the value to encode
buf - the output buffer
off - the output offset

setKeyAndIV

protected void setKeyAndIV(int[] pLFSR,
                           byte[] k,
                           byte[] iv)
Process key and IV into LFSR.
Parameters:
pLFSR - the LFSR
k - the key
iv - the iv

makeKeyStreamWord

protected int makeKeyStreamWord()
Create the next keyStream word.
Returns:
the next word

copy

public Memoable copy()
Create a copy of the engine.
Specified by:
copy in interface Memoable
Returns:
the copy

reset

public void reset(Memoable pState)
Reset from saved engine state.
Specified by:
reset in interface Memoable
Parameters:
pState - the state to restore

Bouncy Castle Cryptography Library 1.77.0