Interface ICipher

All Known Subinterfaces:
ICipherMAC
All Known Implementing Classes:
AESCTR, Dragon, Grain128Noopt, GrainP2Noopt, GrainRefNoopt, HC256, Hermes8, LEX, MICKEY, MICKEY128, MICKEYBase, Nil, Phelix, RC4, Salsa20, Sosemanuk, Spritz, Trivium

public interface ICipher
Generic interface every cipher needs to implement, so it can participate in the test framework. If a cipher comes in different flavors (variable key sizes, MAC computation or not, etc.) it should then implement a version for each of them - this keeps the actual testing logic simple. Simple is good.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    mode: instance is used for decryption
    static final int
    mode: instance is used for encryption
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Erases all sensitive data.
    int
     
    int
     
    int
     
    boolean
     
    void
    process(byte[] inBuf, int inOfs, byte[] outBuf, int outOfs, int len)
    Processes data.
    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.
  • Field Details

    • MODE_ENCRYPT

      static final int MODE_ENCRYPT
      mode: instance is used for encryption
      See Also:
    • MODE_DECRYPT

      static final int MODE_DECRYPT
      mode: instance is used for decryption
      See Also:
  • Method Details

    • isPatented

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

      int getKeySize()
      Returns:
      key size in bytes
    • getNonceSize

      int getNonceSize()
      Returns:
      nonce size in bytes.
    • getWordSize

      int getWordSize()
      Returns:
      alignment of data needed during calls into process()
    • reset

      void reset() throws ESJException
      Resets the instance, so it can be reused.
      Throws:
      ESJException - if any error occurs
    • setupKey

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

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

      void process(byte[] inBuf, int inOfs, byte[] outBuf, int outOfs, int len) throws ESJException
      Processes data.
      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
    • erase

      void erase()
      Erases all sensitive data. Instance MUST be abadonned afterwards.