java.lang.Object
com.coderslagoon.crypto.estreamj.ciphers.nil.Nil
All Implemented Interfaces:
ICipher, ICipherMAC

public class Nil extends Object implements ICipherMAC
THIS IS NOT A REAL CIPHER! Just some pass-through implementation for testing and debugging purposes.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
    for checks: each byte of the MAC passed must always contain this value!
    static final int
     
    static final int
     
    static final int
     

    Fields inherited from interface com.coderslagoon.crypto.estreamj.framework.ICipher

    MODE_DECRYPT, MODE_ENCRYPT
  • Constructor Summary

    Constructors
    Constructor
    Description
    Nil()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Erases all sensitive data.
    void
    finalize(byte[] macBuf, int macOfs)
    Finalize and compute the MAC.
    int
     
    int
     
    int
     
    int
     
    boolean
     
    void
    process(byte[] inBuf, int inOfs, byte[] outBuf, int outOfs, int len)
    Processes data.
    void
    processAAD(byte[] buf, int ofs, int len)
    Processes AAD (additional authentication data).
    static void
     
    void
    Resets the instance, so it can be reused.
    void
    setupKey(int mode, byte[] key, int ofs)
    Sets up a new key with the existing instance.
    void
    setupNonce(byte[] nonce, int ofs)
    Sets up a new nonce with the existing cipher instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Nil

      public Nil()
  • Method Details

    • getKeySize

      public int getKeySize()
      Specified by:
      getKeySize in interface ICipher
      Returns:
      key size in bytes
    • getMacSize

      public int getMacSize()
      Specified by:
      getMacSize in interface ICipherMAC
      Returns:
      MAC size in bytes
    • getNonceSize

      public int getNonceSize()
      Specified by:
      getNonceSize in interface ICipher
      Returns:
      nonce size in bytes.
    • getWordSize

      public int getWordSize()
      Specified by:
      getWordSize in interface ICipher
      Returns:
      alignment of data needed during calls into process()
    • isPatented

      public boolean isPatented()
      Specified by:
      isPatented in interface ICipher
      Returns:
      true: algorithm is patented, check with vendor for license details / false: free to use in private and commercial applications
    • reset

      public void reset()
      Description copied from interface: ICipher
      Resets the instance, so it can be reused.
      Specified by:
      reset in interface ICipher
    • setupKey

      public void setupKey(int mode, byte[] key, int ofs) throws ESJException
      Description copied from interface: ICipher
      Sets up a new key with the existing instance.
      Specified by:
      setupKey in interface ICipher
      Parameters:
      mode - see MODE_xxx
      key - buffer with key material
      ofs - where the key starts
      Throws:
      ESJException - if any error occurs
    • setupNonce

      public void setupNonce(byte[] nonce, int ofs) throws ESJException
      Description copied from interface: ICipher
      Sets up a new nonce with the existing cipher instance.
      Specified by:
      setupNonce in interface ICipher
      Parameters:
      nonce - buffer with nonce material
      ofs - where the nonce starts
      Throws:
      ESJException - if any error occurs
    • process

      public void process(byte[] inBuf, int inOfs, byte[] outBuf, int outOfs, int len) throws ESJException
      Description copied from interface: ICipher
      Processes data.
      Specified by:
      process in interface ICipher
      Parameters:
      inBuf - input buffer
      inOfs - where to start reading from the input buffer
      outBuf - output buffer
      outOfs - where to start writing in the output buffer
      len - number of bytes to process, must be aligned to the cipher's word size except on the last call where an arbitrary size can be used
      Throws:
      ESJException - in any error occurred
    • processAAD

      public void processAAD(byte[] buf, int ofs, int len) throws ESJException
      Description copied from interface: ICipherMAC
      Processes AAD (additional authentication data).
      Specified by:
      processAAD in interface ICipherMAC
      Parameters:
      buf - input buffer
      ofs - where to start reading from the input buffer
      len - number of bytes to process, must be aligned to the cipher's word size except on the last call where an arbitrary size can be used
      Throws:
      ESJException - in any error occurred
    • finalize

      public void finalize(byte[] macBuf, int macOfs) throws ESJException
      Description copied from interface: ICipherMAC
      Finalize and compute the MAC.
      Specified by:
      finalize in interface ICipherMAC
      Parameters:
      macBuf - MAC buffer
      macOfs - where to write MAC
      Throws:
      ESJException - if any error occurred
    • erase

      public void erase()
      Description copied from interface: ICipher
      Erases all sensitive data. Instance MUST be abadonned afterwards.
      Specified by:
      erase in interface ICipher
    • register

      public static void register()